Context
modules#49 made modules install-hooks restore the full hook set: pre-commit dispatcher, pre-commit.d/gitmodules-guard, pre-commit.d/manifest-encryption, stale hook cleanup, and merge driver repair.
The command intentionally preserves an existing executable .git/hooks/pre-commit rather than overwriting user hooks. That matches prior setup behavior, but it leaves a sharp edge: if the existing hook does not dispatch .git/hooks/pre-commit.d/*, then install-hooks can restore the guard files while they still never run.
Proposed behavior
When modules setup or modules install-hooks sees an existing executable pre-commit that it will preserve, warn if it does not appear to dispatch pre-commit.d.
Possible first heuristic:
- if
.git/hooks/pre-commit exists and is executable;
- and its content does not mention
pre-commit.d;
- print a warning explaining that modules guards were installed but may not run until the existing hook dispatches that directory.
Do not overwrite the custom hook automatically.
Acceptance criteria
- Existing custom dispatchers that invoke
pre-commit.d remain quiet and preserved.
- Existing custom hooks that do not mention/dispatch
pre-commit.d produce an actionable warning.
- Tests cover both cases.
- The warning works from normal repos and linked worktrees.
Follow-up shape
This could land either in install-hooks directly or later as part of a modules doctor; the immediate user-risk is that install-hooks now sounds complete, so a warning in the repair command may be most helpful.
Context
modules#49mademodules install-hooksrestore the full hook set: pre-commit dispatcher,pre-commit.d/gitmodules-guard,pre-commit.d/manifest-encryption, stale hook cleanup, and merge driver repair.The command intentionally preserves an existing executable
.git/hooks/pre-commitrather than overwriting user hooks. That matches priorsetupbehavior, but it leaves a sharp edge: if the existing hook does not dispatch.git/hooks/pre-commit.d/*, theninstall-hookscan restore the guard files while they still never run.Proposed behavior
When
modules setupormodules install-hookssees an existing executablepre-committhat it will preserve, warn if it does not appear to dispatchpre-commit.d.Possible first heuristic:
.git/hooks/pre-commitexists and is executable;pre-commit.d;Do not overwrite the custom hook automatically.
Acceptance criteria
pre-commit.dremain quiet and preserved.pre-commit.dproduce an actionable warning.Follow-up shape
This could land either in
install-hooksdirectly or later as part of amodules doctor; the immediate user-risk is thatinstall-hooksnow sounds complete, so a warning in the repair command may be most helpful.