Skip to content

Warn when preserved pre-commit hooks do not dispatch pre-commit.d #52

Description

@quick-ricon

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions