Expand description
The record that turns “a declaration exists” into “the check ran”.
Moving a gate entry to commit time (docs/checks.md, “Moving a gate entry
earlier”) makes the push gate skip a script because a pre-commit
declaration covers it. A declaration is a promise on paper: a commit made
with --no-verify, from a libgit2 client that runs no hooks, or on a
machine without amont was never judged by it — and until this module
existed, push time had no way to tell those commits from checked ones.
Three hooks share one record:
- pre-commit (
record) writes a one-shot marker into$GIT_DIRnaming the gate scripts that actually ran, bound to the tree the commit is about to write (git write-tree— during pre-commit the index IS the commit’s content;staged_onlyparks only the working tree). - post-commit (
bind_to_head) consumes the marker and, when the marker’s tree matchesHEAD^{tree}, stamps the commit in a notes ref.--no-verifyskips pre-commit but NOT post-commit, so an unchecked commit arrives here with no marker and gets no stamp — which is the entire point. The tree comparison makes an aborted commit’s leftover marker harmless, and a retried commit of the SAME tree correctly stamped: the check really did run on exactly that content. - pre-push (
stamps_for) reads the stamps back and suppresses a gate script only for pushes whose relevant commits all carry it.
Every failure mode points the same direction: no marker, a mismatched tree, a missing note, a rewritten hash — all mean “no stamp”, and no stamp means the push gate RUNS. Nothing here can let an unchecked commit through; it can only cost a redundant gate run.
Why a notes ref and not config: notes are keyed by commit, garbage-collect
with unreachable commits (an amont.checked.<hash> config key would
outlive every rebase forever), stay local (notes refs are not pushed by
default), and stay out of git log (only refs/notes/commits displays by
default). amont uninstall deletes the ref; see uninstall_repo_hooks.
Constants§
- FORMAT
- First token of the marker file and of every note body. Versioned like
staged_only::FORMAT: a future amont that changes the shape bumps this, and an old record is ignored rather than misread. - NOTES_
FULL_ REF - The same ref, fully qualified — what
git update-ref -dneeds. - NOTES_
REF - The notes ref, spelled the way
git notes --refwants it.
Functions§
- bind_
to_ head - post-commit: consume the marker; stamp HEAD when the tree still matches.
- forget
- uninstall: forget everything this module ever wrote here.
- record
- pre-commit: record that
scriptsran clean against the tree the commit will carry. - stamps_
for - pre-push: which of
commitscarry a stamp, and for which scripts.