Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix binary headers in formatted patches #56

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion gitdiff/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,11 @@ func (fm *formatter) FormatFile(f *File) {

if f.IsBinary {
if f.BinaryFragment == nil {
fm.WriteString("Binary files fmer\n")
fm.WriteString("Binary files ")
fm.WriteQuotedName("a/" + aName)
fm.WriteString(" and ")
fm.WriteQuotedName("b/" + bName)
fm.WriteString(" differ\n")
} else {
fm.WriteString("GIT binary patch\n")
fm.FormatBinaryFragment(f.BinaryFragment)
Expand Down
1 change: 1 addition & 0 deletions gitdiff/format_roundtrip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func TestFormatRoundtrip(t *testing.T) {
// data is slightly different when re-encoded by Go.
{File: "binary_modify.patch", SkipTextCompare: true},
{File: "binary_new.patch", SkipTextCompare: true},
{File: "binary_modify_nodata.patch"},
}

for _, patch := range patches {
Expand Down
3 changes: 3 additions & 0 deletions gitdiff/testdata/string/binary_modify_nodata.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
diff --git a/file.bin b/file.bin
index a7f4d5d..bdc9a70 100644
Binary files a/file.bin and b/file.bin differ
Loading