Commit Graph
1 Commits
Author SHA1 Message Date
timothyandClaude Opus 5 d05d6623d1 test(785): pin .husky/pre-push's unset GIT_DIR ..., and measure why it matters
The one-line fix at pre-push:11 had nothing pinning it, and #785 ranks it third because
the regression is a relocation rather than a deletion — a tidy-up that reads as a no-op.

What the investigation established, since the comment above it asserts the mechanism
without stating when it applies (git 2.55):

  * git exports GIT_DIR to pre-push when the push comes FROM A WORKTREE, and exports
    nothing from the main tree. `process.shared-tree-readonly` makes the worktree the
    mandated way to work here, so the exposed path is the normal one, not an edge case.
  * with GIT_DIR set and GIT_WORK_TREE unset, git stops discovering the repo and treats
    the CURRENT DIRECTORY as the work tree: `git rev-parse --show-toplevel` from web/
    answers `<wt>/web`.
  * so `cd web && npm run check:api`'s `git diff --exit-code` compares against index
    paths that do not exist there and reports NO DIFF, exit 0. Generated-API drift ships
    and the gate prints success.

The test drives the real pre-push file unedited, in a real worktree, with that exact
environment; the hook calls are stubs (DERIVED from the file, so a new hook cannot leave
the harness dying at a missing script and calling that a red) and `npm` is a stand-in
whose `run check:api` performs the nested diff.

Both mutations witnessed red against the real file: deletion -> 4 failed, 5 passed;
relocation to the end -> 5 failed, 4 passed.

The relocation mutation was wrong in the first draft. Appending the `unset` at the end
also makes it the script's last statement, and a bare `unset` succeeds — so a
`returncode == 0` assertion held for a reason unrelated to the nested git call. The
stand-in npm now records the nested diff's OWN exit code and the mutations assert on
that. Verified by making the mutation a no-op: the test fails, as it must.

Refs: #785
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 21:29:00 +02:00