Skip to content

Prevent automatic hook maintenance from modifying working-tree hooks - #1178

Merged
wesm merged 1 commit into
kenn-io:mainfrom
subaru-ye:codex/fix-auto-hook-worktree
Sep 17, 2026
Merged

wesm merged 1 commit into
kenn-io:mainfrom
subaru-ye:codex/fix-auto-hook-worktree

Conversation

@subaru-ye

Copy link
Copy Markdown
Contributor

In a repository already using roborev hooks, when core.hooksPath points to a
tracked .githooks directory, a non-quiet review can upgrade existing hooks or
inject missing companion hooks into the working tree. From a linked worktree,
relative hook paths resolve to the main checkout, so that checkout can become
dirty even though the review was started elsewhere. The CLI auto-installer lacked the Git-directory check already used
by daemon startup repair.

Apply the existing HooksDirInsideGitDir policy to automatic CLI installation
and post-update repair. The updater passes an internal --git-dir-only option
to the new binary's repair command, preserving the distinction between
automatic maintenance and an explicit repair request. Normal .git/hooks and
linked worktrees' shared Git hooks continue to receive automatic maintenance.

Hooks in working trees or external shared directories now require an explicit
roborev init, roborev install-hook, or roborev install-hook repair to be
installed or updated. Those explicit operations retain their existing behavior,
including editing tracked hook files when requested.

Related to #1165. This addresses
the reproduced automatic writes. The separately reported repeated injection and
shell syntax corruption have not been reproduced with the available hook
fixtures, so this change does not alter the snippet parser or claim to resolve
that symptom.

@roborev-ci

roborev-ci Bot commented Sep 14, 2026

Copy link
Copy Markdown

roborev: Combined Review (3e98c41)

Verdict: No findings at or above medium severity.


Reviewers: 2 done | Synthesis: codex | Total: 4m32s

@wesm wesm self-assigned this Sep 14, 2026
@wesm
wesm merged commit a034a97 into kenn-io:main Sep 17, 2026
20 checks passed
wesm added a commit that referenced this pull request Sep 19, 2026
Automatic hook maintenance now leaves tracked files behind hook symlinks unchanged. Previously, `.git/hooks/pre-push` could point to a tracked `.githooks/pre-push`; the directory check passed and automatic maintenance rewrote the target.

The shared guard skips automatic maintenance for the repository when a hook points outside Git metadata or its symlink target cannot be resolved, including dangling links. Hooks that resolve within Git metadata remain eligible. Explicit install and repair retain their existing behavior.

Follow-up to #1178.


Co-authored-by: Wes McKinney <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants