fix(worktree): respect active worktrees in existing commands - #1683
Draft
casey-chow wants to merge 1 commit into
Draft
casey-chow wants to merge 1 commit into
casey-chow 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.
This teaches existing branchless commands to respect branches that are currently checked out in linked worktrees.
Before this, commands which rewrote or revisited refs could accidentally move a branch that was active in another worktree, leaving that other checkout inconsistent with its branch. The change adds a shared linked-worktree check before branch moves, makes undo refuse to replay ref updates for branches active elsewhere, and avoids auto-switching onto branches already checked out in a worktree.
This also updates navigation display to include worktree context when selecting commits, and adds regression coverage for restack and undo behavior around active linked worktrees.
Validated locally with
cargo check -p git-branchless-navigation -p git-branchless-undo -p git-branchlessandTEST_GIT=$(which git) TEST_GIT_EXEC_PATH=$(git --exec-path) cargo test -p git-branchless --test test_restack --test test_undo.Prepared with substantial Codex assistance.