Conversation
`--no-checkout` promises a bare clone with no worktree, but for non-bare layouts (sibling, nested, centralized, contained-classic) the resolved repo_path *is* the working tree — there's no separate bare directory to leave behind, so the flag silently degraded to a regular non-bare clone with an empty working tree. Validate after layout resolution and bail with an error naming the resolved layout and pointing to bare-using alternatives. Clean up the bare clone (already on disk from clone_bare_phase) so a rejected clone leaves no orphan directory. Fixes #443 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Previously a successful `--no-checkout` clone left the user in their original directory because the cd-redirect path was gated on `worktree_dir.is_some()` (and `branch_not_found`). Neither branch fires for the bare-only success case, so the cd silently did nothing — the user had to manually `cd` into the new repo to interact with it. Add a third branch that writes the parent_dir (the directory holding the bare `.git`) to DAFT_CD_FILE when the clone succeeds with no_checkout=true. `--no-cd` still suppresses it via the existing `autocd` check inside `output.cd_path`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
/claude review |
|
Claude finished @avihut's task in 2m 29s —— View job PR Review
Overall this is a clean, correct fix with solid test coverage. The two changes are well-scoped and the implementation follows existing patterns throughout the codebase. A few observations below, roughly ordered by priority. CorrectnessCleanup path is correct. The
Minor Issues1. Eager layout validation opportunity (UX improvement, not a bug) When
For the explicit-layout case (most common user error), all that disk/network work is wasted. You could call // In validate_arg_combinations or just after it in run():
if args.no_checkout {
if let Some(ref layout_str) = args.layout {
if let Some(builtin) = BuiltinLayout::from_name(layout_str) {
let layout = builtin.to_layout();
check_no_checkout_compat(true, &layout)?;
}
}
}This is an enhancement, not a blocker — the current behaviour is correct, just slower for the reject path. 2. YAML scenario: orphan-check only covers
3. Custom-layout test asserts fewer properties than the builtin test
Nits
SummaryTwo correct fixes, well-scoped. Test coverage hits all 6 builtin layouts at the unit level and the four non-bare builtins at the YAML integration level. Man pages and CLI docs are updated. The suggestions above are improvements (faster failure, fuller YAML coverage) but nothing here blocks the merge. |
Address PR review feedback by extending coverage of the existing rejection paths: - YAML scenario asserts no orphan directory is left for nested, centralized, and contained-classic rejections (previously only sibling). The cleanup branch is unconditional, but the parallel assertions catch future regressions if the cleanup logic changes. - Custom-layout unit test now mirrors the builtin test's assertions: message includes --no-checkout and the bare-layout suggestions, not just the layout name. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
Two related
--no-checkoutfixes forgit-worktree-clone:--no-checkoutfor non-bare layouts. The flag promises a bare clone with no worktree, but for non-bare layouts (sibling,nested,centralized,contained-classic) the resolvedrepo_pathis the working tree — there's no separate bare directory to leave behind. The flag silently degraded to a regular clone with an empty working tree. Now bails after layout resolution with an error naming the resolved layout and pointing to bare alternatives (contained,contained-flat). Cleans up the bare clone (already on disk fromclone_bare_phase) so a rejected clone leaves no orphan directory.--no-checkout. Previously the cd-redirect was gated onworktree_dir.is_some()(orbranch_not_found), so the bare-only success case fell through and left the user in their original directory. Now writesparent_dirtoDAFT_CD_FILEso the user lands in the new project root immediately.--no-cdstill suppresses via the existingautocdcheck insideoutput.cd_path.Updated
--no-checkouthelp text and regenerated man pages + CLI docs to describe the bare-layout constraint.Fixes #443
Test plan
cargo test --lib commands::clone::tests)clone:no-checkout-non-bare-rejectedcovers each non-bare builtin and asserts no orphan directory is left after rejectionclone:no-checkoutextended to assert cd target is the project root viaDAFT_CD_FILEclone:empty-repo-no-checkoutregression check still passesmise run fmt,mise run clippy,cargo clippy --all-targets -- -D warningsclean🤖 Generated with Claude Code