Conversation
For bare layouts with BranchSource::Multiple, branch_plan.base is None by design, so the override block in run_clone left bare_result.target_branch pointing at the remote default. Phase 4 then created a worktree for the default branch on top of the requested satellites — e.g. -b feature -b test produced master + feature instead of just feature. Add a bare-specific path that targets branch_plan.cd_target (the first valid requested branch) for Phase 4, falling back to branch_plan.not_found.first() with branch_exists = false when none of the requested branches exist on the remote so no worktree is created. Fixes #451 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
/claude review |
|
Claude finished @avihut's task in 1m 33s —— View job PR Review
SummaryThe fix correctly addresses the root cause: for
|
| Scenario | What it checks |
|---|---|
multi-branch-all-missing.yml (new) |
All-missing fallback: no default-branch or requested-branch dirs created |
multi-branch-contained.yml |
Happy path: main dir absent (regression guard for #451) |
multi-branch-missing.yml |
Mixed valid/missing: main dir absent (regression guard for #451) |
Minor observation on multi-branch-all-missing.yml: The files_not_exist assertions for nope-one and nope-two will trivially pass even without the fix, since those branches don't exist. The load-bearing assertion is files_not_exist: $WORK_DIR/test-repo/main — that's what would have failed before this fix. Consider adding it explicitly (matching the other two scenarios) to make the regression intent clear. That said, the scenario description already calls this out, and the other two strengthened scenarios cover it directly.
Verdict
LGTM. The fix is minimal, correct, and well-scoped. The is_multi_branch && layout.needs_bare() guard correctly separates the two cases that were previously conflated under a single (broken) if let Some(ref base) guard. Regression coverage matches CLAUDE.md requirements.
Per PR review: the nope-* assertions trivially pass even without the fix. Comment the YAML so future readers see that $WORK_DIR/test-repo/main is the actual regression guard, matching the comment style used in the other two #451 scenarios. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
BranchSource::Multiple,branch_plan.baseisNoneby design, so the override atclone.rs:301-306was a no-op and Phase 4 kept the remote-defaulttarget_branchset indetect_branches. That created an unwanted worktree for the default branch on top of the requested satellites (-b feature -b testproducedmaster + featureinstead of justfeature).branch_plan.cd_target(the first valid requested branch) for Phase 4. When all requested branches are missing on the remote, fall back tobranch_plan.not_found.first()withbranch_exists = falseso no worktree is created.filtered_satellitesfilter already prevents duplication oncetarget_branchis one of the requested branches.Test plan
mise run test:unit(1493 passed)mise run clippy(clean)mise run fmt:check(clean)clone:multi-branch-all-missingscenario covers the all-missing case.clone:multi-branch-containedandclone:multi-branch-missingstrengthened withfiles_not_existfor the default-branch path (regression for Clone with multiple -b flags creates extra default-branch worktree (bare layouts) #451).clone:multi-branch-head-token,clone:multi-branch-sibling,clone:multi-branch-hooksall still pass.Fixes #451
🤖 Generated with Claude Code