anchor rm: remove an anchor worktree and dissolve its anchor#1303
Open
ed-irl wants to merge 4 commits into
Open
anchor rm: remove an anchor worktree and dissolve its anchor#1303ed-irl wants to merge 4 commits into
ed-irl wants to merge 4 commits into
Conversation
Collaborator
Author
|
This change is part of the following stack: Change managed by git-spice. |
This was referenced Jun 23, 2026
'gs anchor rm <path>' removes an anchor worktree and dissolves its anchor: direct child branches are retargeted onto the anchor's base (left needing a restack), the anchor branch is deleted, and the worktree directory is removed. Adds the git WorktreeRemove primitive.
Fixes from adversarial review (anchor-rm layer): - remove the worktree before retargeting children, so a failed removal (a dirty tree without --force) leaves no half-applied state to clean up; the command is safe to retry (B5) - refuse early when asked to remove the current worktree, instead of mutating state and then hitting Git's raw refusal - fall back to the checked-out anchor branch when the registry's recorded worktree path is stale (a moved worktree)
45c0956 to
62aa054
Compare
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.
Adds
gs anchor rm <path>, the counterpart toanchor create/track, for tearing down an anchor worktree once its work is done.The command resolves the path to an anchor (matching the registry's recorded worktree path, then falling back to the branch checked out there), then:
--force) — so a failure leaves all state untouched and the command is safe to retry.--forceremoves a worktree with uncommitted changes.Includes a test script covering self-removal refusal, the dirty-tree no-op-on-failure guarantee, successful removal with child retargeting, and the non-anchor-path error, plus help golden files.