Skip to content

test(remove): pin the ownership gate's refusal of an emptied worktree directory - #3815

Merged
max-sixty merged 1 commit into
mainfrom
remove-registration-ownership
Aug 13, 2026
Merged

test(remove): pin the ownership gate's refusal of an emptied worktree directory#3815
max-sixty merged 1 commit into
mainfrom
remove-registration-ownership

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Removal's ownership gate (ensure_holds_this_worktree, #3808) reads <dir>/.git and stops there, so a directory that has lost that entry holds no worktree of ours and is refused. Nothing named that: wt remove reaches the same refusal upstream at the prunable check, and the gate's own tests cover the sibling-worktree and foreign-repo cases instead.

The case bites where the emptied directory sits inside a repository — a worktree nested in another, or any worktree under a git-managed ~. git rev-parse --git-dir walks up from it and answers with the enclosing repository's git dir, which is the common dir, so a gate resolving that way reads the directory as the main worktree and accepts it:

$ git -C repo worktree add nested -b nested && rm repo/nested/.git
$ git -C repo/nested rev-parse --git-dir
/…/repo/.git

So the test nests, and asserts that premise before asserting the refusal — otherwise it would go vacuous if the nesting stopped producing that resolution. In the flat sibling layout the walk-up finds no repository at all and resolution simply fails, which is why a sibling-shaped test would pin nothing.

Confirmed discriminating: with resolution swapped back to the GIT_DIRS-cached git_dir(), it fails while ensure_holds_this_worktree_accepts_both_worktree_shapes still passes.

This was written by Claude Code on behalf of max-sixty

@max-sixty
max-sixty merged commit 0a55dcd into main Aug 13, 2026
41 checks passed
@max-sixty
max-sixty deleted the remove-registration-ownership branch August 13, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants