Repository navigation
Report conflicted binary files and modify/delete conflicts as unmerged in Patch() - #192
Merged
Merged
Conversation
…d in Patch() GitPatchParser marked a file conflicted only when a @@@ line followed its header. A conflicted binary file stops at "Binary files differ", so it came back as an ordinary binary modification, and a modify/delete conflict is printed only as "* Unmerged path <path>", which the parser skipped. Every diff --cc / diff --combined header is now conflicted, and each "* Unmerged path" line becomes a conflicted file with no hunks, so Patch() and Diff() agree on the set of unmerged paths. Fixes #123 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JgoVAth3nGZUgbKrSgVCYX
|
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.



Fixes #123
What changed
GitPatchParserused to mark a file as conflicted only when a@@@line followed its header. Two kinds of unmerged output that git produces have no such line:diff --cc bin.dat/index …/Binary files differ.Patch()returned it asKind = Modified, IsConflicted = false.* Unmerged path d.txt. The top-level loop skipped that line, so the path was missing fromPatch()entirely.The fix:
diff --cc/diff --combinedheader now counts as conflicted, withKind = Unmergedand no hunks, whether or not a@@@line follows. The kind is set after the header lines are read, so a mode line can't turn it back into Added or Deleted.* Unmerged path <path>line becomes a conflictedGitFilePatchwith no hunks. A file's header and its combined body both stop at such a line, so it can't be swallowed by the file before it.Tests
GitPatchParserTests.FlagsAConflictedBinaryFileAndAModifyDeleteConflictreads a new fixture,patch-unmerged-binary-and-deleted.txt, captured with git 2.43.0 from a real merge that leaves both kinds of conflict.GitPatchParserTests.FlagsALongFormCombinedHeaderAsConflictedcovers adiff --combinedheader.GitPatchRoundTripTests.PatchAndDiffAgreeOnUnmergedPathsAfterABinaryAndAModifyDeleteConflictAsyncis an integration test. It runs a real merge and checks thatPatch()andDiff()report the same unmerged paths.I checked that the tests catch the bug: with the parser change reverted, all three fail, and with it they pass. The full suite passes locally (749 tests, 0 failed).
🤖 Generated with Claude Code
https://claude.ai/code/session_01JgoVAth3nGZUgbKrSgVCYX
Generated by Claude Code