fix(plan): abort git merge on conflict and restore clean repo state #7250

Closed
opened 2026-04-10 11:39:23 +00:00 by hamza.khyari · 0 comments
Member

Summary

When plan apply encounters a git merge conflict (user edited the same file between execute and apply), the merge leaves conflict markers (<<<<<<<, =======, >>>>>>>) in the project files and the repo in an unmerged state.

Metadata

  • Commit Message: fix(plan): abort git merge on conflict and restore clean repo state
  • Branch: bugfix/merge-conflict-abort

Current Behavior

  1. git merge fails with conflict (RC=1)
  2. _apply_sandbox_changes catches CalledProcessError but prints merge_err.stderr which is empty (git writes conflict info to stdout)
  3. Function returns without calling git merge --abort
  4. Project files contain conflict markers, git status shows UU (unmerged)

Expected Behavior

  1. Detect merge conflict
  2. Print the actual conflict message (from stdout)
  3. Run git merge --abort to restore the repo to a clean state
  4. Print user-friendly message: "Merge aborted — project is unchanged"
  5. Project files remain as the user left them, no conflict markers

Subtasks

  • Read conflict detail from CalledProcessError.stdout instead of .stderr
  • Run git merge --abort after failed merge to restore clean state
  • Print user-friendly guidance message
  • Add scenario-3 (merge conflict) to agents-test suite

Definition of Done

  • Merge conflict leaves project files unchanged (no conflict markers)
  • git status is clean after failed apply (no UU entries)
  • User sees clear error message with conflict details
  • Scenario-3 end-to-end test passes

Spec Reference

specification.md §18334-18336 (Apply phase constraint handling)

## Summary When `plan apply` encounters a git merge conflict (user edited the same file between execute and apply), the merge leaves conflict markers (`<<<<<<<`, `=======`, `>>>>>>>`) in the project files and the repo in an unmerged state. ## Metadata - **Commit Message**: `fix(plan): abort git merge on conflict and restore clean repo state` - **Branch**: `bugfix/merge-conflict-abort` ## Current Behavior 1. `git merge` fails with conflict (RC=1) 2. `_apply_sandbox_changes` catches `CalledProcessError` but prints `merge_err.stderr` which is **empty** (git writes conflict info to stdout) 3. Function returns without calling `git merge --abort` 4. Project files contain conflict markers, git status shows `UU` (unmerged) ## Expected Behavior 1. Detect merge conflict 2. Print the actual conflict message (from stdout) 3. Run `git merge --abort` to restore the repo to a clean state 4. Print user-friendly message: "Merge aborted — project is unchanged" 5. Project files remain as the user left them, no conflict markers ## Subtasks - [ ] Read conflict detail from `CalledProcessError.stdout` instead of `.stderr` - [ ] Run `git merge --abort` after failed merge to restore clean state - [ ] Print user-friendly guidance message - [ ] Add scenario-3 (merge conflict) to agents-test suite ## Definition of Done - Merge conflict leaves project files unchanged (no conflict markers) - `git status` is clean after failed apply (no `UU` entries) - User sees clear error message with conflict details - Scenario-3 end-to-end test passes ## Spec Reference `specification.md` §18334-18336 (Apply phase constraint handling)
hamza.khyari added this to the v3.5.0 milestone 2026-04-10 11:39:39 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
cleveragents/cleveragents-core#7250
No description provided.