Skip to content

fix(finish): always clear merge state even when git abort reports no-op#111

Open
SAY-5 wants to merge 1 commit intogittower:mainfrom
SAY-5:fix/handleAbort-stale-merge-state-110
Open

fix(finish): always clear merge state even when git abort reports no-op#111
SAY-5 wants to merge 1 commit intogittower:mainfrom
SAY-5:fix/handleAbort-stale-merge-state-110

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented Apr 23, 2026

Fixes #110.

Problem

handleAbort called git merge --abort (or rebase --abort) first and bailed early on error. The common sequence — feature finish → merge conflict → user manually resolves and commits (bypassing --continue) → --abort — then leaves merge.json on disk because merge --abort exits 128 (MERGE_HEAD missing) and ClearMergeState is never reached. Every subsequent feature finish is permanently blocked until the user deletes .git/gitflow/state/merge.json by hand.

Fix

Treat the abort error as informational, continue cleanup, and always reach mergestate.ClearMergeState so the repo is unblocked. Warn to stderr when git had nothing to abort so operators still see it. The checkout-original-branch step only fails the whole operation when abort itself succeeded (preserving the happy-path behavior).

Test

go build clean. The integration suite in test/cmd has a pre-existing hang on this machine (confirmed by running it against a stash of my change — same timeout), but the code path is covered in test/internal/git/worktree_test.go which continues to pass.

handleAbort called git merge/rebase --abort first and bailed early on
error, so a common real-world sequence — conflict, manual resolve+
commit (bypassing --continue), then --abort — left merge.json on disk
after 'merge --abort' returned exit 128 ('MERGE_HEAD missing'). Every
subsequent 'feature finish' was permanently blocked until the user
deleted .git/gitflow/state/merge.json by hand.

Treat the abort error as informational, continue cleanup, and still
call mergestate.ClearMergeState so the repo is unblocked. A warning
is printed to stderr when git had nothing to abort so operators can
see it. The checkout-original-branch step only fails the whole
operation when abort itself succeeded (the previously exercised
happy path).

Refs gittower/git-flow-next issue 110.

Signed-off-by: SAY-5 <say.apm35@gmail.com>
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.

bug: stale merge.json blocks all future feature finish when --abort is called without MERGE_HEAD

1 participant