If deleteBranchesIfNeeded fails during finish (e.g., remote branch deletion fails), the merge state is never cleared. The user is then stuck in a "merge in progress" state even though the merge itself completed successfully.
Root Cause
In cmd/finish.go, ClearMergeState() (line 774) is called after deleteBranchesIfNeeded() (line 761). If delete returns an error, the function returns early and merge state cleanup is skipped:
if err := deleteBranchesIfNeeded(state, cfg.Remote, keepRemote, keepLocal, forceDelete); err != nil {
return err // <-- merge state never cleared
}
// ...
if err := mergestate.ClearMergeState(); err != nil { // <-- never reached
Expected Behavior
Merge state should be cleared after a successful merge regardless of whether branch deletion succeeds. Branch deletion is a cleanup step — its failure should not leave the repository in an inconsistent state.
Suggested Fix
Either clear merge state before attempting branch deletion, or make branch deletion non-fatal (warn and continue). The latter aligns with the direction in #88 and PR #83.
If
deleteBranchesIfNeededfails during finish (e.g., remote branch deletion fails), the merge state is never cleared. The user is then stuck in a "merge in progress" state even though the merge itself completed successfully.Root Cause
In
cmd/finish.go,ClearMergeState()(line 774) is called afterdeleteBranchesIfNeeded()(line 761). If delete returns an error, the function returns early and merge state cleanup is skipped:Expected Behavior
Merge state should be cleared after a successful merge regardless of whether branch deletion succeeds. Branch deletion is a cleanup step — its failure should not leave the repository in an inconsistent state.
Suggested Fix
Either clear merge state before attempting branch deletion, or make branch deletion non-fatal (warn and continue). The latter aligns with the direction in #88 and PR #83.