Block chained Git worktree mutations in the original checkout - #37
Open
kvandre12-commits wants to merge 1 commit into
Open
Block chained Git worktree mutations in the original checkout#37kvandre12-commits wants to merge 1 commit into
kvandre12-commits wants to merge 1 commit into
Conversation
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.
Summary
Add a deterministic shell-safety guard for a subtle Git worktree failure mode:
git worktree add ../new-tree -b topic main && git cherry-pick abc123git worktree addcreates the new checkout but does not change the shell's working directory, so the chained mutation still runs in the original checkout.Behavior
The shell-safety callback now blocks a mutating Git command chained after
git worktree addunless the command explicitly changes repository context.Blocked:
git worktree add ... && git cherry-pick ...git worktree add ...; git reset --hard ...Allowed:
git worktree add ...by itselfgit statuscd ../new-tree && git cherry-pick ...git -C ../new-tree cherry-pick ...The rejection instructs callers to run a second shell tool call with
cwdset to the new worktree. It runs before YOLO/manual-mode and OAuth-model bypasses because this is deterministic execution-context validation, not an LLM risk assessment.Validation
git diff --checkpassed