fix(server): worktree cleanup removes half-deleted checkouts - #249
Merged
Conversation
A worktree removal that died halfway (a long-path failure before
core.longpaths, a kill mid-delete) leaves the folder without its .git
file. Git then lists the registration as prunable and refuses to remove
it ("validation failed ... '.git' does not exist"), so the cleanup view
offered the worktree for deletion but every attempt failed.
removeWorktree now asks git how it sees the registration when the
remove command fails. A prunable entry is pruned and the leftover folder
is deleted by the server, reusing the retry loop that already handles
folders a shell still holds open. Live registrations and unrelated
failures still surface as before.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
badcuban
enabled auto-merge
September 6, 2026 08:52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The clean up worktrees view listed three worktrees as deletable, but deleting any of them failed with
fatal: validation failed, cannot remove working tree: '.../.git' does not exist. Each folder had been half deleted by an earlier removal: the.gitfile was gone but some files were left behind, so git lists the entry as prunable and refusesgit worktree removeon it.removeWorktreenow asks git how it sees the registration when the remove command fails. A prunable entry getsgit worktree pruneand the server deletes the leftover folder itself, reusing the retry loop that already handles folders a shell still holds open. Live registrations and unrelated failures surface exactly as before. One regression test half-deletes a worktree and checks removal clears both the folder and git's record of it.