Files
Maximilian Roos acdbbb6824 fix(remove): name the detached worktree instead of refusing the removal
The guard this branch added was solving the wrong problem. Detaching a
worktree's HEAD severs the only link git records between it and the
branch, so the branch really has no worktree and deleting the ref alone
is the correct operation — and it never lost anything: `SafeDelete`
retains an unintegrated branch, so the only refs it deleted were ones
worktrunk's own integration test calls lossless, and even a forced `-D`
leaves the commits reachable through the detached worktree's HEAD, which
is a GC root.

What #3769 actually reported was silence. `○ No worktree found for branch
<name>` is true and still reads as "nothing is there" while a directory
sits at exactly that path, so the removal now names it and the `wt remove
<path>` that clears it, on stderr and in `--format=json`'s new
`detached_worktree`. Refusing instead cost a legitimate branch cleanup
and let a branch address a detached worktree — the one thing the worktree
model says a branch cannot name.

`detached_worktree_for` survives to find the path; it no longer decides
whether the command runs, which is also why the guard-scoping it needed
(a branch-existence check, a `deletion_mode` gate) goes with it: an extra
line of output is harmless where a refusal had to be narrowed case by
case.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-11 07:47:21 -07:00
..