Skip to content

fix: check remote tracking branch when validating merge status for deletion#236

Merged
avihut merged 1 commit intomasterfrom
fix/branch-behind-master-cant-be-deleted
Feb 18, 2026
Merged

fix: check remote tracking branch when validating merge status for deletion#236
avihut merged 1 commit intomasterfrom
fix/branch-behind-master-cant-be-deleted

Conversation

@avihut
Copy link
Owner

@avihut avihut commented Feb 18, 2026

Summary

  • branch-delete now checks merge status against both the local default branch AND its remote tracking branch (e.g., origin/main), fixing false "not merged" errors when the local default branch is behind the remote
  • Since checkout-branch creates branches from origin/main, the new branch can be ahead of local main even with no user changes -- the old validation only checked local main and incorrectly rejected deletion
  • Uses git branch -D (force) for actual deletion since our validation is more comprehensive than git's built-in branch -d check

Fixes #232

Test plan

  • Added integration test branch_delete_local_behind_remote that reproduces the exact scenario
  • All existing branch-delete integration tests still pass (9/9)
  • Unit tests pass (333 passed)
  • Clippy clean, fmt clean

🤖 Generated with Claude Code

@avihut avihut self-assigned this Feb 18, 2026
@avihut avihut added this to the v1.1.0 milestone Feb 18, 2026
@avihut avihut added bug Something isn't working fix Bug fix labels Feb 18, 2026
…letion

When checkout-branch creates a branch from origin/main (because local
main is behind), the new branch ends up ahead of local main. Deleting
it later would fail with "not merged into main" even though the branch
is an ancestor of origin/main and the user made no changes.

Fix by also checking against the remote tracking ref (origin/main) in
is_branch_merged, and always using git branch -D for the actual
deletion since our validation is more comprehensive than git's built-in
branch -d check.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@avihut avihut force-pushed the fix/branch-behind-master-cant-be-deleted branch from 4e8452e to 294a381 Compare February 18, 2026 20:16
@avihut avihut merged commit 05e0279 into master Feb 18, 2026
6 checks passed
@avihut avihut deleted the fix/branch-behind-master-cant-be-deleted branch February 18, 2026 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant