Skip to content

Handle merge conflicts gracefully#41

Merged
BHFock merged 5 commits intomainfrom
status
Apr 17, 2026
Merged

Handle merge conflicts gracefully#41
BHFock merged 5 commits intomainfrom
status

Conversation

@BHFock
Copy link
Copy Markdown
Owner

@BHFock BHFock commented Apr 17, 2026

Previously, git-cl commands behaved poorly during unresolved merges: conflicted files were hidden from status, and state-mutating commands either failed with cryptic git errors or proceeded with partial operations.

Changes

  • Refusal guards on stage, unstage, commit, stash, unstash, and checkout. They detect merge-conflict codes (UU, AA, DD, AU, UA, DU, UD) and refuse cleanly, naming the conflicted files and pointing at git merge --abort or manual resolution.
  • Improved status output: conflicts are now part of the default view (previously hidden behind --all), coloured red to match git's own convention, with an advisory line when conflicts are present.
  • add, remove, delete, diff unchanged: users may legitimately reorganise changelists mid-merge.

Implementation

Two new helpers (clutil_detect_merge_conflicts, clutil_refuse_on_merge_conflict) and a two-line guard in each affected command. Around 45 lines added, zero removed.

Tests

New test_merge_conflict.py covers all six refusals, verifies add/remove still work mid-merge, and confirms normal operation resumes after resolution. Uses inline conflict setup so the --export walkthrough shows readers how to reproduce the scenario.

BHFock added 4 commits April 17, 2026 20:39
stage, unstage, commit, stash, unstash, and checkout now detect
unmerged files (UU, AA, DD, AU, UA, DU, UD) and refuse cleanly
with a message pointing the user at git merge --abort or manual
resolution. Previously these commands could either pass the file
to git (which would fail with a cryptic error) or, worse, silently
succeed on a partial operation leaving the repo in an unclear state.

add, remove, delete, status, and diff are unchanged: they either
only touch cl.json or are read-only, and users may legitimately
want to reorganise changelists mid-merge.
Covers the new merge-conflict guards in stage, unstage, commit, stash,
unstash, and checkout. Also verifies that add and remove still work
mid-merge, and that all commands recover after the conflict is resolved.

Conflict setup is done inline (two branches modifying the same file,
then git merge) so the exported shell walkthrough shows the full
reproduction steps.
Before: `git cl status` during a merge hid conflicted files behind
the "uncommon Git status codes" message, requiring --all to see them.
After: conflict codes (UU, AA, DD, AU, UA, DU, UD) are part of the
default status view, coloured red to match git's own convention, and
an advisory line reminds the user to resolve before proceeding.

Complements the refusal guards from the preceding commit: the user
can now see what needs resolving as easily as they are told they
can't proceed without resolving it.
@BHFock BHFock changed the title Check status for merge conflicts Handle merge conflicts gracefully Apr 17, 2026
@BHFock BHFock merged commit 136b8de into main Apr 17, 2026
4 checks passed
@BHFock BHFock deleted the status branch April 17, 2026 21:08
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