Skip to content

Conversation

@sourcefrog
Copy link
Collaborator

@sourcefrog sourcefrog commented Dec 8, 2025

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

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 --git command lines and git index lines before binary file indicators
  • Introduced a new binary field to the Patch struct to distinguish binary patches from regular ones
  • Updated the Display implementation 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant