Problem
When creating a worktree from a name that already exists as a branch, wt should not always create a fresh branch from the default base.
Expected behavior:
- If
name matches a local branch, check out that branch in the new worktree.
- If
name matches a remote-tracking branch, create the worktree from that remote branch and track it.
- If multiple remote branches match, prompt the user to choose which remote to use.
Repro
- Have a repo with
origin/feature/remote-worktree-match.
- Run
wt session add feature/remote-worktree-match or wt new feature/remote-worktree-match.
- Observe whether
wt uses the matching branch/ref or falls back to the base branch.
Expected
wt should create the worktree on feature/remote-worktree-match when it exists locally, or on the matching remote branch when only origin/feature/remote-worktree-match exists.
Actual
Before the fix, wt could create a new branch from the base branch instead of using the existing branch/ref.
Acceptance Criteria
- Local branch match reuses the existing branch.
- Remote branch match checks out a tracked branch from that remote ref.
- Ambiguous remote matches prompt the user to choose.
- Tests cover local, remote, and ambiguous remote cases.
Problem
When creating a worktree from a name that already exists as a branch,
wtshould not always create a fresh branch from the default base.Expected behavior:
namematches a local branch, check out that branch in the new worktree.namematches a remote-tracking branch, create the worktree from that remote branch and track it.Repro
origin/feature/remote-worktree-match.wt session add feature/remote-worktree-matchorwt new feature/remote-worktree-match.wtuses the matching branch/ref or falls back to the base branch.Expected
wtshould create the worktree onfeature/remote-worktree-matchwhen it exists locally, or on the matching remote branch when onlyorigin/feature/remote-worktree-matchexists.Actual
Before the fix,
wtcould create a new branch from the base branch instead of using the existing branch/ref.Acceptance Criteria