Skip to content

Fix ambiguous git worktree start points#2864

Open
tonymmm1 wants to merge 2 commits into
pingdotgg:mainfrom
tonymmm1:fix-qualify-worktree-start-point
Open

Fix ambiguous git worktree start points#2864
tonymmm1 wants to merge 2 commits into
pingdotgg:mainfrom
tonymmm1:fix-qualify-worktree-start-point

Conversation

@tonymmm1
Copy link
Copy Markdown

@tonymmm1 tonymmm1 commented May 29, 2026

Summary

  • Qualify local branch start points as refs/heads before git worktree add.
  • Resolve explicit remote branch start points as refs/remotes//.
  • Add regression coverage for a branch name that is also a remote ref.

Checks

  • bun fmt
  • bun lint (passes with existing warnings)
  • bun typecheck
  • cd apps/server && bun run test src/vcs/GitVcsDriverCore.test.ts

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 qualifyWorktreeStartPoint helper in GitVcsDriverCore leaves fully qualified refs/… names unchanged, maps existing local branches to refs/heads/<name>, and when the name parses as a remote ref and that remote branch exists, maps to refs/remotes/<remote>/<branch>; otherwise it passes the original string through. createWorktree uses this qualified value as the start point for both worktree add and worktree add -b instead of the raw refName.

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

  • Introduces qualifyWorktreeStartPoint in GitVcsDriverCore.ts to resolve ambiguous ref names before calling git worktree add. It prefers refs/heads/<branch> for local branches, falls back to refs/remotes/<remote>/<branch> for remote refs, and passes the original input if neither matches.
  • createWorktree now passes the qualified ref instead of the raw refName, fixing failures when a local and remote branch share the same name.
  • Adds an integration test covering the case where the base branch name exists as both a local and remote-tracking ref.

Macroscope summarized ef3c08c.

@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels May 29, 2026
@tonymmm1
Copy link
Copy Markdown
Author

tonymmm1 commented May 29, 2026

Noticed an issue with the t3-code client unable to make new threads with workspaces and would quickly close the new thread window.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1b8d4ebf-8329-4ccc-bce1-bf692b8cab5f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented May 29, 2026

Approvability

Verdict: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant