Skip to content

fix(worktree): allow exit_worktree remove when branch is already merged#248

Merged
Fullstop000 merged 1 commit into
masterfrom
fix-exit-worktree-merged
Jul 10, 2026
Merged

fix(worktree): allow exit_worktree remove when branch is already merged#248
Fullstop000 merged 1 commit into
masterfrom
fix-exit-worktree-merged

Conversation

@Fullstop000

Copy link
Copy Markdown
Owner

Problem

After a worktree branch is merged into the base branch (e.g. via a PR), exit_worktree remove still complains that there are commits not on the base branch and requires discard_changes=true.

Fix

  • Record the base ref/branch name in ActiveWorktree.
  • When checking for unsaved commits, use git merge-base --is-ancestor to detect whether the worktree branch has already been merged into the current base branch.
  • Add a regression test that simulates a merge commit into main and verifies remove succeeds without discard_changes.

Version

Bumps to v0.45.5 and updates CHANGELOG.

…ed into base

- Record the base branch ref in ActiveWorktree.
- Use git merge-base --is-ancestor to detect already-merged worktree branches.
- Leave base_ref empty for detached HEAD bases to avoid incorrectly treating
  the worktree branch as merged.
- Add regression tests for merged commits and detached HEAD safety.

Also bumps version to 0.45.5 and updates CHANGELOG.
@Fullstop000
Fullstop000 force-pushed the fix-exit-worktree-merged branch from d23aea2 to e0c87c5 Compare July 10, 2026 06:15
@Fullstop000
Fullstop000 merged commit 2f63a00 into master Jul 10, 2026
6 checks passed
@Fullstop000
Fullstop000 deleted the fix-exit-worktree-merged branch July 10, 2026 06: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.

1 participant