fix(hooks): skip post-checkout rebuild when PREV_HEAD equals NEW_HEAD (#2421) - #2422
fix(hooks): skip post-checkout rebuild when PREV_HEAD equals NEW_HEAD (#2421)#2422nothariharan wants to merge 1 commit into
Conversation
git checkout -b with no start point reports a branch switch but leaves the tree unchanged. PREV_HEAD/NEW_HEAD were assigned and never read, so every new branch still launched a full background rebuild (Graphify-Labs#2421).
There was a problem hiding this comment.
Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).
Graphify reviewed this change.
Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).
Graphify review — findings
This PR modifies the git post-checkout hook script in graphify/hooks.py to add an early exit when PREV_HEAD equals NEW_HEAD, intended to short-circuit the rebuild logic for no-op checkouts (e.g. git checkout -b with no start point). It also adds a new test, test_checkout_hook_skips_same_head_noop, in tests/test_hooks.py that asserts the checkout script contains the head-assignment lines and the new same-head guard string. The surface area is limited to the checkout hook shell template and its corresponding test coverage.
No blocking issues surfaced.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 278 functions depend on the 145 functions this change touches.
Health — grade A; 6 existing hotspot(s) in the area this change touches (pre-existing, not introduced here):
dispatch_command()— 2 callers, 110 callees (high)install()— 25 callers, 6 callees (high)dispatch_install_cli()— 2 callers, 31 callees (high)uninstall()— 9 callers, 5 callees (high)uninstall_all()— 2 callers, 12 callees (high)status()— 6 callers, 4 callees (medium)
Verification — 278 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 151 function(s) in the blast radius were not formally verified this run
Fixes #2421
Problem
_CHECKOUT_SCRIPTingraphify/hooks.pyassignsPREV_HEAD=andNEW_HEAD=but never reads either variable.git checkout -b <new>with no start point reports a branch switch (BRANCH_SWITCH=1) while leaving the tree byte-identical — git passes the same SHA asand. That still launched_REBUILD_BODY_CHECKOUT, a full background rebuild (nochanged_paths), mutatinggraphify-out/seconds later.The
GRAPHIFY_SKIP_HOOKhalf of #1809 already landed; the same-head short-circuit did not. The unused assignments were the tell.Fix
After the existing branch-switch guard, short-circuit when the heads match:
Real branch switches (
PREV_HEAD != NEW_HEAD) are unchanged. Rebase/merge/cherry-pick, missinggraphify-out/, worktree, andGRAPHIFY_SKIP_HOOKguards are untouched.Testing
test_checkout_hook_skips_same_head_noopasserting the short-circuit is present in_CHECKOUT_SCRIPTuv run pytest tests/test_hooks.py::test_checkout_hook_skips_same_head_noop tests/test_hooks.py::test_hooks_honor_skip_env -q→ passedpython -m tools.skillgen --check→ OK (no skill artifacts touched)Notes
CI runs on Ubuntu. Local Windows full-suite noise (path separators /
geteuid/ env backends) is unrelated to this one-line hook-template change.