Repository navigation
fix(diff): review merge commits against their first parent - #450
Merged
Merged
Conversation
Plain `git show` renders a merge commit as a combined diff ("diff --cc"
sections with @@@ hunks), which ParseDiffText does not handle: every
section is silently dropped, so `ocr review --commit <merge>` exits 0
with "No supported files changed" even when the merge contains conflict
resolutions — precisely the content that most needs review. Worse, a
combined section following a regular one is absorbed into the previous
file's diff text.
Pass --diff-merges=first-parent to the ModeCommit git show call so a
merge commit is diffed against its first parent in regular unified
format. Non-merge commits are unaffected (verified: root commits still
diff against the empty tree). The flag requires git >= 2.31; the project
already requires git >= 2.41.
Contributor
|
✅ OpenCodeReview: No comments generated. Looks good to me. |
jassandavisoon-star
approved these changes
Jul 24, 2026
jassandavisoon-star
approved these changes
Jul 24, 2026
9 of 14 tasks
Githab-capibara
added a commit
to Githab-capibara/open-code-review
that referenced
this pull request
Sep 17, 2026
Plain `git show` renders a merge commit as a combined diff ("diff --cc"
sections with @@@ hunks), which ParseDiffText does not handle: every
section is silently dropped, so `ocr review --commit <merge>` exits 0
with "No supported files changed" even when the merge contains conflict
resolutions — precisely the content that most needs review. Worse, a
combined section following a regular one is absorbed into the previous
file's diff text.
Pass --diff-merges=first-parent to the ModeCommit git show call so a
merge commit is diffed against its first parent in regular unified
format. Non-merge commits are unaffected (verified: root commits still
diff against the empty tree). The flag requires git >= 2.31; the project
already requires git >= 2.41.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
ocr review --commit <merge-commit>silently reviews nothing and exits 0 with "No supported files changed", even when the merge commit contains conflict resolutions — precisely the content that most needs review.Root cause:
ModeCommituses plaingit show <commit>(internal/diff/git.go), which renders merge commits as a combined diff (diff --ccsections with@@@hunks and two-column prefixes).ParseDiffTextonly recognizesdiff --git a/... b/...sections, so every combined section is dropped and the parse yields zero diffs. (Worse, a combined section following a regular one would be absorbed into the previous file's diff text.)Reproduced with real git: on a merge commit with a conflict resolution, the provider returns
[](0 diffs) today.Fix
Pass
--diff-merges=first-parentto thegit showcall so a merge commit is diffed against its first parent in regular unified format — the same "what did this change introduce" semantics--commithas for normal commits. Non-merge commits are unaffected (verified: root commits still diff against the empty tree, regular commits unchanged). The flag requires git ≥ 2.31; the project already requires git ≥ 2.41.Type of Change
How Has This Been Tested?
make testpasses locally (go test -race -count=1 ./...)TestCommitDiffMergeCommitReviewsFirstParentDiffbuilds a real repo with a conflicting merge, then asserts the provider returns exactly one diff containing the conflict resolution. Fails onmain(expected exactly 1 diff for the merge commit, got 0: []), passes with the fix.git showwith the exact provider flags on merge and root commits, before/after.Checklist
gofmt -s,go vet)Related Issues
None filed.