Harden git hook matchers against -C bypass #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "harden-git-hook-matchers"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The three git-triggered PreToolUse hooks anchored on
git <flags> <verb>, so thegit -C <path> <verb>form (and-c,--git-dir,--work-tree) slipped past every matcher. History rewrites andworktree creation went ungated and the decision nudge never fired
whenever git ran with a global option.
Add a shared prefix that consumes git's global options before the
subcommand, so the flag forms match like the bare command. While
here, inject-operating-standards now skips read-only queries and bare
branch/tag/remote/worktree listings instead of over-firing on them,
and nudge-decision-on-commit no longer false-matches commit-tree.
Verified with a 48-case matcher suite, all passing. Design notes for
operating-standards, the bootstrap plan, and decision-engine record
the normalization and the wider read-only skip.
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com