Skip to main content

Module ref_cmd

Module ref_cmd 

Source
Expand description

mkit ref list [--pattern <glob>] / mkit ref cat <name> — stable ref-inspection plumbing (#652).

The epic (#634) settled on keeping refs as plain loose files rather than migrating them to a denser storage primitive, but that decision only holds up if “ls-able” is satisfied by a stable command surface rather than by shelling out to ls/cat on .mkit/refs/. These two commands are that surface, modeled on git’s for-each-ref/show-ref plumbing:

  • ref list prints every ref’s full name and resolved hash, one per line as <refname> <hash>, sorted lexicographically by name. Covers refs/heads/*, refs/tags/*, and refs/remotes/*/* — the same read scope as show-ref/for-each-ref. An empty repo prints nothing and still exits 0 (unlike show-ref, whose “nothing matched” exit-1 convention is a git-inherited existence test, not what a structured listing command should do). --pattern <glob> filters to full ref names matching a shell glob (* spans /, ?/[...] supported — see super::branch::glob_match).
  • ref cat <name> prints the resolved hash for exactly one ref, following HEAD’s symbolic indirection (HEAD is mkit’s only symbolic ref: it either names a branch or holds a detached hash). <name> must be a fully-qualified ref name — refs/heads/<b>, refs/tags/<t>, refs/remotes/<r>/<b> — or the literal HEAD; these are exactly the names ref list prints, so the two commands round-trip.

Both commands are read-only and reuse mkit-core::refs’s existing read/list helpers (read_ref, read_tag, read_remote_ref, resolve_head, list_refs, list_tags, list_remote_refs, list_remote_names) — no new storage-layer code.

Functions§

run