push_branch: refuse commits that leave git conflict markers #44

Merged
dario merged 1 commit from dario/push-conflict-markers into main 2026-11-20 14:28:49 +01:00 AGit
Owner

Evidence

On #28, the local model pushed merge commit 4e3f0a9 with a <<<<<<< HEAD block in internal/dispatch/dispatch_test.go. The next commit (9a1606b) fixed it, so the branch tip built, but 4e3f0a9 does not compile. No review noticed it. Without a squash merge it would end up in main's history.

Changes

  • internal/gitpush: before pushing, checkConflictMarkers checks every commit the push would publish: the commits not yet on the remote branch or the base branch, at most 200. It reports files that commit changes and that contain a line starting with <<<<<<< or >>>>>>> .
    • It ignores files identical to a parent's (a merge took them unchanged from one side) or to the published branches'. A marker-like fixture the default branch already has doesn't block anyone.
    • It works on the private bare copy the push already uses, never in the agent's working copy.
    • The refusal says nothing was pushed, and how to fix it without forcing: git commit --amend for the last commit, otherwise squash the unpublished commits with git reset --soft to the last pushed commit.
  • The push_branch tool description and README.

Test evidence

  • just check: passes
  • TestRefusesConflictMarkers (real git), a re-enactment of 4e3f0a9 → 9a1606b:
    • the merge commits the conflict, the next commit fixes it, and the push is refused naming a.txt in commit <merge>;
    • main's own fixture with marker lines isn't reported;
    • nothing reaches the remote;
    • after reset --soft to the last pushed commit and one clean commit, the push goes through.

🤖 Generated with Claude Code

## Evidence On #28, the local model pushed merge commit `4e3f0a9` with a `<<<<<<< HEAD` block in `internal/dispatch/dispatch_test.go`. The next commit (`9a1606b`) fixed it, so the branch tip built, but `4e3f0a9` does not compile. No review noticed it. Without a squash merge it would end up in main's history. ## Changes - `internal/gitpush`: before pushing, `checkConflictMarkers` checks every commit the push would publish: the commits not yet on the remote branch or the base branch, at most 200. It reports files that commit changes and that contain a line starting with `<<<<<<< ` or `>>>>>>> `. - It ignores files identical to a parent's (a merge took them unchanged from one side) or to the published branches'. A marker-like fixture the default branch already has doesn't block anyone. - It works on the private bare copy the push already uses, never in the agent's working copy. - The refusal says nothing was pushed, and how to fix it without forcing: `git commit --amend` for the last commit, otherwise squash the unpublished commits with `git reset --soft` to the last pushed commit. - The `push_branch` tool description and README. ## Test evidence - `just check`: passes - `TestRefusesConflictMarkers` (real git), a re-enactment of `4e3f0a9` → `9a1606b`: - the merge commits the conflict, the next commit fixes it, and the push is refused naming `a.txt in commit <merge>`; - main's own fixture with marker lines isn't reported; - nothing reaches the remote; - after `reset --soft` to the last pushed commit and one clean commit, the push goes through. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dario merged commit e8e198fa59 into main 2026-11-20 14:28:49 +01:00
Sign in to join this conversation.
No reviewers
No labels
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.

Dependencies

No dependencies set.

Reference
dario/factory!44
No description provided.