Skip to content

fix: improve error message when checking out a branch used by another worktree#700

Merged
aviator-app[bot] merged 1 commit intomasterfrom
worktree-checkout-error
Apr 5, 2026
Merged

fix: improve error message when checking out a branch used by another worktree#700
aviator-app[bot] merged 1 commit intomasterfrom
worktree-checkout-error

Conversation

@draftcode
Copy link
Copy Markdown
Collaborator

@draftcode draftcode commented Apr 5, 2026

Summary

  • When CheckoutBranch() fails because the target branch is already checked out in another worktree, detect the git error and return a user-friendly message suggesting git worktree list and cd <worktree-path>
  • This improves the error for all commands that use CheckoutBranch(): av switch, av next, av prev, av stack foreach, etc.

Test plan

  • Existing unit tests pass (go test ./internal/git/...)
  • In a repo with a worktree, try av switch <branch-checked-out-in-worktree> and verify the improved error message appears
  • Verify normal checkout (non-worktree) errors are unaffected

🤖 Generated with Claude Code

@draftcode draftcode requested a review from a team as a code owner April 5, 2026 11:01
@aviator-app
Copy link
Copy Markdown
Contributor

aviator-app bot commented Apr 5, 2026

Current Aviator status

Aviator will automatically update this comment as the status of the PR changes.
Comment /aviator refresh to force Aviator to re-examine your PR (or learn about other /aviator commands).

This PR was merged using Aviator.


See the real-time status of this PR on the Aviator webapp.
Use the Aviator Chrome Extension to see the status of your PR within GitHub.

@aviator-app
Copy link
Copy Markdown
Contributor

aviator-app bot commented Apr 5, 2026

✅ FlexReview Status

Common Owner: aviator-co/engineering (expert-load-balance assignment)
Owner and Assignment:

  • aviator-co/engineering (expert-load-balance assignment)
    Owned Files
    • 🔒 internal/git/git.go

Review SLO: 7 business hours if PR size is <= 200 LOC for the first response.

@aviator-app aviator-app bot requested a review from simsinght April 5, 2026 11:01
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces automated worktree management for the restack sequencer, enabling it to detach and restore branches in external worktrees and skip branches with dirty working trees. The review feedback suggests improving error diagnostics in IsWorktreeClean by capturing stderr and refactoring the sequencer to store worktree preparation messages in its state so they can be properly displayed in the UI rather than being discarded.

… worktree

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@draftcode draftcode marked this pull request as draft April 5, 2026 11:16
@draftcode draftcode force-pushed the worktree-checkout-error branch from d83fb75 to 60e8c42 Compare April 5, 2026 11:16
@draftcode draftcode marked this pull request as ready for review April 5, 2026 11:16
@draftcode
Copy link
Copy Markdown
Collaborator Author

/aviator merge

@aviator-app
Copy link
Copy Markdown
Contributor

aviator-app bot commented Apr 5, 2026

Aviator has accepted the merge request. It will enter the queue when all of the required status checks have passed. Aviator will update the sticky status comment as the pull request moves through the queue.

@aviator-app aviator-app bot merged commit 0059d63 into master Apr 5, 2026
5 checks passed
@aviator-app aviator-app bot deleted the worktree-checkout-error branch April 5, 2026 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants