Skip to content

fix(worktrees): preserve recoverable work during removal and retries - #6823

Closed
joeyfrasier wants to merge 1 commit into
get-bb:mainfrom
joeyfrasier:fix/preserve-worktree-on-retirement
Closed

joeyfrasier wants to merge 1 commit into
get-bb:mainfrom
joeyfrasier:fix/preserve-worktree-on-retirement

Conversation

@joeyfrasier

@joeyfrasier joeyfrasier commented Nov 2, 2026 •

Copy link
Copy Markdown

Human comments

What was wrong

Keep unfinished Git work recoverable when a managed worktree retires. The remover used forced Git removal and a recursive-deletion fallback, so clean-looking or uninspectable worktrees could lose files or private refs. Provisioning retries could also remove an old worktree and reset the branch retaining its commits.

What changed

Removal now checks tracked, untracked, ignored, hidden-index, private-ref, in-progress-operation, and retained-commit state before stopping processes and again under mutation locks. Git removal runs without force, has no recursive fallback, and preserves recovery markers on failure. Retries refuse branch resets with commits outside the selected base. Updated the worktree and CLI guides. No wire fields changed.

How you verified

  • 136 worktree-plugin tests and Turbo typechecking pass.
  • New disposable-Git preservation cases fail against the original remover. Three private-ref cases also reproduced removal before the added guard.
  • Existing clean removal, provisioning, process cleanup, and recovery tests pass.

Refs #5952. This adds removal protection; archive-dialog warnings and atomic protection against unrelated external writers remain separate work.

Fixes #6824

AGENT GENERATED

@github-actions github-actions Bot added needs-approval PR author is not on the approved contributor list needs-issue PR does not close an open issue labels Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Thanks for the pull request, @joeyfrasier. It was closed automatically because it does not meet the requirements below yet. This is an automated check, not a review of the change.

Contributor approval. bb reviews pull requests only from approved contributors, and you are not on the list yet. Join the #contributors channel in Discord (https://discord.gg/kvBU6tJhcJ), post a link to your pull request, and explain what it changes and why. A maintainer then adds you to the list and reopens the pull request.

Linked issue. Every pull request must close an open issue in this repository. The issue keeps the problem tracked even if this pull request closes or we take a different approach. Open an issue for the change, or find an existing one, and add Fixes #<number> to the pull request description. Feature requests and UI changes need a maintainer's sign-off on the issue first. Link the issue before you ask for approval.

See CONTRIBUTING.md for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-approval PR author is not on the approved contributor list needs-issue PR does not close an open issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Worktree removal discards private refs and clean in-progress Git state

1 participant