Skip to content

[Bug]: lrc hooks install --local creates an infinite self-chaining pre-commit hook #144

Open

Description

@GRIMDERVALD

Pre-flight checks

  • I searched existing issues and discussions.
  • I read CONTRIBUTING.md.
  • This is not a private security vulnerability report.

Current behavior

On a fresh lrc hooks install --local, every git commit hangs indefinitely
and never completes — no error, no timeout, has to be killed manually.

Found the root cause by reading .git/hooks/pre-commit directly:

GIT_COMMON_DIR="$(git rev-parse --git-common-dir 2>/dev/null || echo "$GIT_DIR")"
LOCAL_HOOK="$GIT_COMMON_DIR/hooks/pre-commit"
...
if [ -x "$LOCAL_HOOK" ]; then
    "$LOCAL_HOOK" "$@"

In --local mode, the dispatcher itself is .git/hooks/pre-commit. So
$LOCAL_HOOK resolves to the dispatcher's own path — after running the lrc
sub-hook, it tries to chain to "the pre-existing local hook" and ends up
re-executing itself. Infinite recursion, no exit condition.

Two more issues found while trying to recover from this:

  • lrc hooks disable does not stop the loop — the disabled-flag check only
    gates the call into the lrc sub-hook, not the $LOCAL_HOOK chaining that
    follows it, so the recursive self-call still fires regardless.
  • lrc hooks uninstall (without --local) does not clean up --local
    installs — it targets the global path (~/.git-hooks), leaving the broken
    repo-local dispatcher files in place. Had to manually remove
    .git/hooks/{pre-commit,prepare-commit-msg,commit-msg,post-commit},
    .git/hooks/lrc/, and .git/lrc/ to fully recover.

Expected behavior

The commit completes normally after the attestation check (lrc review --staged / --skip / --vouch) passes — same as it does with the global
install mode.

Suggested fix: $LOCAL_HOOK resolution should exclude the dispatcher's own
path before chaining (e.g. compare against the currently-executing script
path). lrc hooks uninstall should also detect and clean up --local-mode
installs, not just the global one.

Reproduction steps

1. In any git repo, run `lrc hooks install --local`
2. Stage a change, run `lrc review --staged --skip` to satisfy the attestation requirement
3. Run `git commit -m "test"`
4. Observe: commit hangs indefinitely, never completes or errors

Environment

  • lrc version: v0.6.11
  • OS: Windows 11
  • Shell: Git Bash (MSYS2) and PowerShell — both affected
  • Git version: (colle la sortie de git --version)

Additional context

No response

Activity

  1. added
    bug
    on Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions