Fix ambiguous git worktree start points#2864
Conversation
|
Noticed an issue with the t3-code client unable to make new threads with workspaces and would quickly close the new thread window. |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Approved This is a straightforward bug fix that disambiguates git ref names when creating worktrees, preventing errors when a branch name matches both local and remote refs. The change has clear intent, limited scope, and includes a comprehensive test. You can customize Macroscope's approvability policy. Learn more. |
Summary
Checks
Note
Low Risk
Scoped to worktree creation ref resolution in the VCS driver with a targeted integration test; no auth, data, or broad API surface changes.
Overview
Git worktree creation now resolves ambiguous start refs before
git worktree add, so a short branch name that exists as both a local branch and a remote-tracking ref no longer breaks worktree setup.A new
qualifyWorktreeStartPointhelper inGitVcsDriverCoreleaves fully qualifiedrefs/…names unchanged, maps existing local branches torefs/heads/<name>, and when the name parses as a remote ref and that remote branch exists, maps torefs/remotes/<remote>/<branch>; otherwise it passes the original string through.createWorktreeuses this qualified value as the start point for bothworktree addandworktree add -binstead of the rawrefName.An integration test covers creating a new worktree when the base branch name is also present as a remote ref (local +
refs/remotes/<remote>/<same name>).Reviewed by Cursor Bugbot for commit ef3c08c. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix ambiguous git worktree start points when branch name conflicts with remote ref
qualifyWorktreeStartPointin GitVcsDriverCore.ts to resolve ambiguous ref names before callinggit worktree add. It prefersrefs/heads/<branch>for local branches, falls back torefs/remotes/<remote>/<branch>for remote refs, and passes the original input if neither matches.createWorktreenow passes the qualified ref instead of the rawrefName, fixing failures when a local and remote branch share the same name.Macroscope summarized ef3c08c.