Skip to content

fix: abort handles rebase/cherry-pick/revert, rebase context, regex edge case#3

Open
sulthonzh wants to merge 1 commit into
mainfrom
fix/abort-rebase-conflict-detection
Open

fix: abort handles rebase/cherry-pick/revert, rebase context, regex edge case#3
sulthonzh wants to merge 1 commit into
mainfrom
fix/abort-rebase-conflict-detection

Conversation

@sulthonzh

Copy link
Copy Markdown
Owner

Fixes

1. abortMerge() only handles merge abort

Previously only ran git merge --abort. During a rebase or cherry-pick, this would fail with an error instead of aborting the actual operation.

Fix: Detect which operation is in progress by checking for:

  • rebase-merge/ or rebase-apply/ dirs → git rebase --abort
  • CHERRY_PICK_HEADgit cherry-pick --abort
  • REVERT_HEADgit revert --abort
  • Fall back to git merge --abort

2. getMergeInfo() doesn't detect rebase state

Only read MERGE_MSG and MERGE_HEAD which don't exist during a rebase. The --abort message would show nothing and --status wouldn't show which branch is being rebased.

Fix: Check for rebase-merge/ directory and read head-name + message from it.

3. countConflicts() regex misses bare markers

Regex /<<<<<<<.+\$/gm requires at least one character after <<<<<<<. A bare <<<<<<<\n (no branch name) wouldn't be counted.

Fix: Changed to /<<<<<<<.*\$/gm to match zero or more characters.

…x edge case

- abortMerge() now detects rebase-merge/rebase-apply, CHERRY_PICK_HEAD,
  and REVERT_HEAD to call the correct abort command instead of blindly
  running git merge --abort (which fails during rebase/cherry-pick)
- getMergeInfo() detects rebase-merge state and reads head-name/message
  from .git/rebase-merge/ instead of only MERGE_MSG
- countConflicts() regex changed from /<<<<<<<.+$/ to /<<<<<<<.*$/ to
  correctly count bare <<<<<<< markers without a branch name suffix
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