Skip to main content

Module update_ref

Module update_ref 

Source
Expand description

mkit update-ref [-d] <ref> [<newvalue> [<oldvalue>]] — low-level guarded ref write/delete, like git update-ref.

Supports refs/heads/<branch> and refs/tags/<name> (the namespaces mkit manages); other namespaces (HEAD, refs/remotes/…) are rejected. <newvalue> / <oldvalue> resolve through the shared revspec grammar (ref, full/short hash, HEAD~n). Without <oldvalue> the write is unconditional; with one it is a compare-and-swap that fails unless the ref currently holds that value. In update mode an all-zero <oldvalue> means “the ref must not already exist” (git’s create-only convention); in -d (delete) mode <oldvalue>, if given, must be a concrete value the ref currently holds (an all-zero value is rejected — you cannot delete a ref asserted to be absent).

Safety divergence: -d on a branch uses the same guard as branch -d — it refuses to delete the currently checked-out branch (git’s plumbing would, leaving HEAD dangling).

Functions§

run