Better handling of "Binary files differ" and git index lines#19
Open
sourcefrog wants to merge 2 commits intogitpatch-rs:mainfrom
Open
Better handling of "Binary files differ" and git index lines#19sourcefrog wants to merge 2 commits intogitpatch-rs:mainfrom
sourcefrog wants to merge 2 commits intogitpatch-rs:mainfrom
Conversation
91ca5b4 to
3aad6a2
Compare
3aad6a2 to
4f70fef
Compare
4f70fef to
33ee9bf
Compare
There was a problem hiding this comment.
Pull request overview
This PR enhances the diff parser to correctly handle binary file diffs that include git's "diff --git" and "index" lines. The implementation adds support for parsing these metadata lines before the "Binary files differ" message, enabling proper roundtrip parsing of git-generated binary diffs.
Changes:
- Added parsing for optional
diff --gitcommand lines and gitindexlines before binary file indicators - Introduced a new
binaryfield to thePatchstruct to distinguish binary patches from regular ones - Updated the
Displayimplementation to output binary patch format appropriately
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/wild-samples/gitsmallbinary.patch | Test case for minimal binary diff with git metadata |
| tests/wild-samples/gitbinary.patch | Test case for binary diff with longer file paths |
| tests/regressions.rs | Updated test to include new binary: false field |
| tests/parse_samples.rs | Improved error messages and comments |
| src/parser.rs | Added diff_command and git_index_line parsers; enhanced binary diff parsing; improved error messages |
| src/ast.rs | Added binary field to Patch struct and updated Display implementation |
| CHANGELOG.md | Documented the new binary field |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
33ee9bf to
71af640
Compare
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.
With this changed we can correctly parse and, to some extent roundtrip, diffs like this:
diff --git a/bin b/bin index 4805bf6..e807873 100644 Binary files a/bin and b/bin differ