fix(laws): three git detectors were blind to linked worktrees - #8
Merged
Merged
Conversation
In a linked worktree (`git worktree add`) `<root>/.git` is a FILE holding `gitdir: …`; the shared config and hooks live in the main repository's git directory. Three laws joined `.git/hooks` and `.git/config` onto the project root and found nothing: - Git Hooks Standards — "Git hooks directory missing" - Branch Protection Standards — "Unable to read Git configuration" - Git Hook Compliance — "Git hooks directory not found" A consumer hit this in a worktree whose husky hooks had just blocked a push: the concern was met and the law said otherwise. The same HEAD scored 100/100 in the primary checkout and 90/100 in the worktree. A new shared resolver asks git (`rev-parse --git-common-dir`) instead of guessing the layout, and honours `core.hooksPath` — a second trap, since husky moves hooks to `.husky`, which makes `<gitdir>/hooks` the default rather than the answer. A relative hooksPath resolves against the working tree top level, which is what git itself does. Verified with real `git worktree add` fixtures: the three laws now score 100/100 from a worktree, identical to the primary checkout. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In a linked worktree (
git worktree add)<root>/.gitis a FILE holdinggitdir: …; the shared config and hooks live in the main repository's git directory. Three laws joined.git/hooksand.git/configonto the project root and found nothing:A consumer hit this in a worktree whose husky hooks had just blocked a push: the concern was met and the law said otherwise. The same HEAD scored 100/100 in the primary checkout and 90/100 in the worktree.
A new shared resolver asks git (
rev-parse --git-common-dir) instead of guessing the layout, and honourscore.hooksPath— a second trap, since husky moves hooks to.husky, which makes<gitdir>/hooksthe default rather than the answer. A relative hooksPath resolves against the working tree top level, which is what git itself does.Verified with real
git worktree addfixtures: the three laws now score 100/100 from a worktree, identical to the primary checkout.What this changes
Verdict impact
(then: state the before/after values and what a consumer must do)
Evidence
tests/detectionLimitsupdated if what the detector cannot see has changedGate
npm run lint— 0 errorsnpx jest— full suite greennpm run canary— red/green proven across stacksnode dist/cli.js audit— RuleOfCode still passes its own lawNotes for the reviewer