fix(completion): surface unborn worktree branches
Problem
wt switch <TAB> and wt remove <TAB> were silent in repos with no commits. branches_for_completion() sourced its candidates from local_branches(), which runs for-each-ref refs/heads/. On a fresh git init -b main repo, nothing exists under refs/heads/ yet — the unborn default branch is only a symbolic-ref target — so the scan returned an empty Vec and the completer shortcut back with no candidates.
Closes #3094.
Solution
After the existing local-branches pass, iterate list_worktrees() and emit a Worktree-category candidate for each worktree whose branch isn't already in local_names. That covers:
- The primary unborn worktree (e.g.
mainon a freshgit init -b main). - Any linked worktree made by
wt switch --createon the same empty repo (also unborn, also absent fromrefs/heads/).
Unborn entries are pinned to i64::MAX so they sort to the top of the Worktree category — there's no commit timestamp to interleave with, and the user typically just created them. On a born repo every worktree's branch is also in local_names, so the new loop is a no-op and existing completion order is preserved.
Testing
- Two new unit tests in
src/git/repository/branches.rs:branches_for_completion_includes_unborn_default_branch— empty repo returns[main]as aWorktreecandidate.branches_for_completion_includes_unborn_linked_worktree— aftergit worktree add -b feature ../pathon a still-unborn repo, bothmainandfeaturesurface.
- Updated
test_complete_empty_repo(integration): the prior assertion encoded the bug ("only option suggestions"); it now assertsmainis a candidate. - End-to-end sanity check:
wt switch <TAB>against a freshgit init -b mainreturnsmain. - All 57 completion integration tests and 151 remove integration tests pass locally.