Repository navigation
fix: chain repository hooks under git -c overrides - #5877
kunchenguid merged 2 commits into
Conversation
…task hooksPath The per-task hooks wrappers cleared only the GIT_CONFIG_COUNT override before looking up the repository's own hooks directory. When core.hooksPath reached git through git -c (GIT_CONFIG_PARAMETERS), directly or inherited by a child process, the lookup found the wrapper directory again and exited 0, so the repository's real hook - such as a pre-push publish guard - never ran and the push succeeded. The lookup now ignores GIT_CONFIG_PARAMETERS too, so only the repository's config files decide its hooks directory, and a failed lookup exits nonzero instead of skipping the hook. AI-trailer stripping is unchanged. Fixes kunchenguid#5871
|
Speaking as Kun's firstmate: this is merged. Thank you @FocalFactotum — really appreciate you taking the time on this. Closes #5871 — verified GitHub closing link ( Contract-class: restore — pane hooksPath already promised to chain the repository's real hooks ( Inspected tip vs main
VISION
CI green (36302881942) · NM SUCCESS · attestation MATCH |
* fix(bin): run the repository's own hooks when git -c carries the per-task hooksPath The per-task hooks wrappers cleared only the GIT_CONFIG_COUNT override before looking up the repository's own hooks directory. When core.hooksPath reached git through git -c (GIT_CONFIG_PARAMETERS), directly or inherited by a child process, the lookup found the wrapper directory again and exited 0, so the repository's real hook - such as a pre-push publish guard - never ran and the push succeeded. The lookup now ignores GIT_CONFIG_PARAMETERS too, so only the repository's config files decide its hooks directory, and a failed lookup exits nonzero instead of skipping the hook. AI-trailer stripping is unchanged. Fixes kunchenguid#5871 * no-mistakes(document): Document git hook chaining and lookup failure behavior
* fix(bin): run the repository's own hooks when git -c carries the per-task hooksPath The per-task hooks wrappers cleared only the GIT_CONFIG_COUNT override before looking up the repository's own hooks directory. When core.hooksPath reached git through git -c (GIT_CONFIG_PARAMETERS), directly or inherited by a child process, the lookup found the wrapper directory again and exited 0, so the repository's real hook - such as a pre-push publish guard - never ran and the push succeeded. The lookup now ignores GIT_CONFIG_PARAMETERS too, so only the repository's config files decide its hooks directory, and a failed lookup exits nonzero instead of skipping the hook. AI-trailer stripping is unchanged. Fixes kunchenguid#5871 * no-mistakes(document): Document git hook chaining and lookup failure behavior
* fix(bin): run the repository's own hooks when git -c carries the per-task hooksPath The per-task hooks wrappers cleared only the GIT_CONFIG_COUNT override before looking up the repository's own hooks directory. When core.hooksPath reached git through git -c (GIT_CONFIG_PARAMETERS), directly or inherited by a child process, the lookup found the wrapper directory again and exited 0, so the repository's real hook - such as a pre-push publish guard - never ran and the push succeeded. The lookup now ignores GIT_CONFIG_PARAMETERS too, so only the repository's config files decide its hooks directory, and a failed lookup exits nonzero instead of skipping the hook. AI-trailer stripping is unchanged. Fixes kunchenguid#5871 * no-mistakes(document): Document git hook chaining and lookup failure behavior
* fix(bin): run the repository's own hooks when git -c carries the per-task hooksPath The per-task hooks wrappers cleared only the GIT_CONFIG_COUNT override before looking up the repository's own hooks directory. When core.hooksPath reached git through git -c (GIT_CONFIG_PARAMETERS), directly or inherited by a child process, the lookup found the wrapper directory again and exited 0, so the repository's real hook - such as a pre-push publish guard - never ran and the push succeeded. The lookup now ignores GIT_CONFIG_PARAMETERS too, so only the repository's config files decide its hooks directory, and a failed lookup exits nonzero instead of skipping the hook. AI-trailer stripping is unchanged. Fixes kunchenguid#5871 * no-mistakes(document): Document git hook chaining and lookup failure behavior
Intent
Offer the per-task git hooks wrapper fix upstream as a pull request that resolves #5871: when core.hooksPath reaches git through git -c (GIT_CONFIG_PARAMETERS or GIT_CONFIG_COUNT), the per-task hooks wrapper looks up the repository's real hooks with that injected setting still active, finds itself, and skips the real hooks. A proven fix already exists on the local branch fm/git-hooks-wrapper-guard-fix-v1 at commit 25e38060 (changes to bin/fm-git-strip-ai-trailers.sh and tests/fm-git-strip-ai-trailers.test.sh): the wrapper removes both injected-config channels for the real-hook lookup, and fails instead of silently succeeding when that lookup fails.
What Changed
core.hooksPathis supplied throughgit -c.git -coverrides, and document the behavior.Risk Assessment
✅ Low: The focused change clears both injected Git config channels during the real-hook lookup, fails when lookup fails, and adds behavioral coverage for the reported bypass.
Testing
The focused test passed using real Git commits and pushes. Manual evidence reproduced the skipped guard on the base commit, showed both override channels blocked by the changed wrapper, and confirmed a failed hook lookup exits nonzero. Temporary fixtures were removed and the worktree is clean.
bash tests/fm-git-strip-ai-trailers.test.shbash tests/fm-git-strip-ai-trailers.test.shEvidence: Live hook behavior
Evidence: Before-fix reproduction
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-git-strip-ai-trailers.test.shbash tests/fm-git-strip-ai-trailers.test.shbash tests/fm-git-strip-ai-trailers.test.shManual isolated Git pushes usinggit -c core.hooksPathandGIT_CONFIG_COUNT, with a refusing repository pre-push hookManual invocation of the installed pre-push wrapper outside a Git repositoryManual before-fix push using the base-commit wrapper✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.