Skip to content

fix(hooks): skip post-checkout rebuild when PREV_HEAD equals NEW_HEAD (#2421) - #2422

Open
nothariharan wants to merge 1 commit into
Graphify-Labs:v8from
nothariharan:fix/issue-2421-checkout-same-head
Open

fix(hooks): skip post-checkout rebuild when PREV_HEAD equals NEW_HEAD (#2421)#2422
nothariharan wants to merge 1 commit into
Graphify-Labs:v8from
nothariharan:fix/issue-2421-checkout-same-head

Conversation

@nothariharan

Copy link
Copy Markdown

Fixes #2421

Problem

_CHECKOUT_SCRIPT in graphify/hooks.py assigns PREV_HEAD= and NEW_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 as and. That still launched _REBUILD_BODY_CHECKOUT, a full background rebuild (no changed_paths), mutating graphify-out/ seconds later.

The GRAPHIFY_SKIP_HOOK half 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:

# A no-op checkout (e.g. `git checkout -b` with no start point) reports a
# branch switch but leaves the tree unchanged — nothing to rebuild (#2421).
[ "$PREV_HEAD" = "$NEW_HEAD" ] && exit 0

Real branch switches (PREV_HEAD != NEW_HEAD) are unchanged. Rebase/merge/cherry-pick, missing graphify-out/, worktree, and GRAPHIFY_SKIP_HOOK guards are untouched.

Testing

  • Added test_checkout_hook_skips_same_head_noop asserting the short-circuit is present in _CHECKOUT_SCRIPT
  • uv run pytest tests/test_hooks.py::test_checkout_hook_skips_same_head_noop tests/test_hooks.py::test_hooks_honor_skip_env -q → passed
  • python -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.

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).

@graphify-labs graphify-labs Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

post-checkout: PREV_HEAD/NEW_HEAD are assigned but never read, so git checkout -b full-rebuilds an unchanged tree

1 participant