Repository navigation
fix(git): a worktree that lost its .git no longer fails the gather (#368) - #372
Conversation
) git lists such a record as prunable. It is now read from the porcelain output and treated as a missing path, so no probe runs in the directory and list, remove and cleanup no longer fail on it. Removal prunes git's record and deletes the branch; the directory is left on disk and is labelled "Not a git checkout (.git missing), directory kept". Closes #368
There was a problem hiding this comment.
code-reviewer: minor issues
This change reads git's prunable annotation so a worktree whose directory has lost its .git is treated as a missing path. As a result, list, remove and cleanup no longer run git probes in it. On removal it prunes the record instead of running git worktree remove, and leaves the directory in place. The fix for the reported failure looks correct, and the parser and nuke changes are tested. The main concern is that cleanup (including --force) will now sweep such a worktree and git branch -D its branch without counting unpushed commits, even though they could be counted from the main repository. Two smaller points: the removal progress bar measures a directory it never deletes, and a few doc sentences outside the edited rows are now out of date.
Reviewed f79c1a9 for baldurpan · claude-opus-5-5 · 10 files · $0.44
…368) Review of #372: treating a prunable record as a missing path let cleanup `branch -D` it without counting its commits. Its branch and HEAD are still in git's records, so the commits are now counted from the repository, and the record clears isSafeToRemove only on that count. Removal progress no longer walks a directory it keeps, and the docs that still said "gone" or "present" are brought in line.
There was a problem hiding this comment.
code-reviewer follow-up: minor issues
Since the last review, this push takes the ahead count for prunable records from the repository (branch ref, upstream, or the recorded HEAD for a detached record) and runs the merged probe the same way. isSafeToRemove no longer waves prunable entries through, removal progress skips a kept directory, and the docs are reworded to match. All three earlier comments are addressed, and the new tests pin the held-back, upstream and detached cases. One thing remains: git also marks a worktree whose directory is gone entirely as prunable, which widens the behaviour change beyond the .git-only case and leaves parts of the docs untrue.
Earlier comments
- Fixed; yours to resolve: Risk: A prunable worktree's branch is deleted by
cleanupwithout counting its commits - Fixed; yours to resolve: Suggestion: Removal progress measures a directory that will not be deleted
- Fixed; yours to resolve: Suggestion: Other sentences in list.mdx still say "directory is gone" or "present"
Reviewed b27ff5e (changes since f79c1a9) for baldurpan · claude-opus-5-5 · 6 files · $0.27
…368) Review of #372: git also marks a record prunable when its whole directory is gone, so b27ff5e started counting and holding back deleted directories too, against what the docs say. Only a prunable record whose directory is still on disk is marked now; a gone one is uncounted and safe, as before.
There was a problem hiding this comment.
code-reviewer follow-up: looks good
Since the last review, gitGetWorktrees marks a record prunable (and carries its head) only when git calls it prunable and its directory is still on disk. A worktree whose directory is gone therefore keeps its old verdict: no probe, ahead undefined, safe to remove. New tests cover both cases at the gitGetWorktrees level, and one checks at the gather level that no rev-list runs and the entry stays safe. The comments in git.ts and types.ts now match, and I found nothing new to raise.
Earlier comments
- Fixed; yours to resolve: Risk:
prunablealso covers a directory that is gone, so missing worktrees now get counted and held back too
Reviewed bd1e559 (changes since b27ff5e) for baldurpan · claude-opus-5-5 · 3 files · $0.16
#372's cleanup.mdx edit ranks /commands/cleanup/ first for reworded-cleanup-merged-prs (was second), so retrieval.mrr moves 0.7 -> 0.719.
Closes #368
What changed
parseWorktreeRecords(src/lib/git.ts) now reads git'sprunableline.gitGetWorktreesreports a prunable record aspathExists: false, so none of the git probes (status -s, ahead and behind counts, churn) run in a directory with no.git. One broken entry no longer failslist,removeorcleanup.gitNukeWorktreeCmdrunsgit worktree pruneinstead ofgit worktree removewhen the directory has no.git, then deletes the branch. The directory is left on disk: without.gitits contents can't be checked for uncommitted work.missingPathDetail(src/lib/utils.ts), used bylistand bycleanup's reasons: such an entry readsNot a git checkout (.git missing), directory kept. A directory that is really gone still readsPath does not exist.list.mdx(thepathExistsanduncommittedChangesrows),cleanup.mdx(the reason vocabulary) and a new section inremove.mdx..changeset/prunable-worktree-entry.md(patch).The issue left one decision open: whether
removeshould also delete the directory. This change answers no, and drops only git's record and the branch.Gates
context/verify.mdpassed:pnpm check,typecheck, docs typecheck,build,docs:build,worker:bundle-check,docs:audit-dist,test(4,132 passed),docs:test, and the test-marker check.reviewersubagent. Loop 1 failed because the docs no longer matched the code; fixed. Loop 2 passed with notes. Two of its notes are fixed here: the "five reasons" count incleanup.mdx, and a test that pins the new label.Out of scope (from the review, not fixed here)
.gitis not markedprunableby git, so it would still fail the gather.gitFindBranchCheckoutdoes not readprunable, soworktree branch <name>on such a record still treats the broken directory as a checkout.