Fix: prevent hook reinstall loop when luca install runs inside a git worktree#12
Merged
albertodebortoli merged 1 commit intomainfrom Apr 10, 2026
Merged
Conversation
Pass --no-install-post-checkout-git-hook to `luca install` invoked by the post-checkout hook, so that hook execution never triggers a redundant re-installation of itself.
8 tasks
Member
Author
|
Accidentally closed by LucaTools/Luca#57. |
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.
Problem
When
luca installis run from within a git worktree, the post-checkout hook triggers a failure cascade:How git worktrees work
In a normal repository,
.gitis a directory. When you usegit worktree add, each worktree gets a.gitthat is a regular file containing a pointer likegitdir: /path/to/main/repo/.git/worktrees/<name>. The actual hooks live only in the main repo's.git/hooks/and are shared across all worktrees.The failure cascade
.git/hooks/post-checkout.luca install --quiet, which (without this fix) attempts to re-install the post-checkout hook.luca installcallsGitHookInstaller.installPostCheckoutHook(), which tries to write to.git/hooks/post-checkout— but in a worktree.gitis a file, not a directory, so the path.git/hooks/post-checkoutis invalid and the write fails.luca installexits non-zero, the hook logs a warning, and tool synchronisation may be skipped or incomplete.This happens on every branch switch in every worktree, making the hook unreliable for anyone using
git worktree.Root Cause
The post-checkout hook calls
luca installunconditionally without telling it to skip hook (re-)installation. Since the hook is already installed (it's the thing running right now), trying to install it again on every checkout is both unnecessary and broken in worktrees.Fix
Pass
--no-install-post-checkout-git-hookto theluca installinvocation in the post-checkout script. This tells the CLI not to attempt hook installation during a hook-triggered run — the hook is already in place.Test Plan
luca install: called with correct args on happy pathupdated to assert the new flag is passed — all 13 tests inpost_checkout.batspass.