Skip to content

Commit 9d1f353

Browse files
authored
Merge pull request #63 from zegl/extended-binary-no-index
Support renamed binary files without index-row
2 parents 35b24a7 + c26dd7a commit 9d1f353

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

diff/diff_test.go

+16
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,22 @@ func TestParseFileDiffHeaders(t *testing.T) {
271271
},
272272
},
273273
},
274+
{
275+
filename: "sample_file_extended_binary_rename_no_index.diff",
276+
wantDiff: &FileDiff{
277+
OrigName: "a/data/foo.txt",
278+
OrigTime: nil,
279+
NewName: "b/data/bar.txt",
280+
NewTime: nil,
281+
Extended: []string{
282+
"diff --git a/data/foo.txt b/data/bar.txt",
283+
"similarity index 100%",
284+
"rename from data/foo.txt",
285+
"rename to data/bar.txt",
286+
"Binary files a/data/foo.txt and b/data/bar.txt differ",
287+
},
288+
},
289+
},
274290
}
275291
for _, test := range tests {
276292
t.Run(test.filename, func(t *testing.T) {

diff/parse.go

+1
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ func handleEmpty(fd *FileDiff) (wasEmpty bool) {
489489
(lineCount == 6 && linesHavePrefixes(1, "old mode ", 2, "new mode ") && linesHavePrefixes(4, "copy from ", 5, "copy to "))
490490

491491
isRename := (lineCount == 4 && linesHavePrefixes(2, "rename from ", 3, "rename to ")) ||
492+
(lineCount == 5 && linesHavePrefixes(2, "rename from ", 3, "rename to ") && lineHasPrefix(4, "Binary files ")) ||
492493
(lineCount == 6 && linesHavePrefixes(2, "rename from ", 3, "rename to ") && lineHasPrefix(5, "Binary files ")) ||
493494
(lineCount == 6 && linesHavePrefixes(1, "old mode ", 2, "new mode ") && linesHavePrefixes(4, "rename from ", 5, "rename to "))
494495

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
diff --git a/data/foo.txt b/data/bar.txt
2+
similarity index 100%
3+
rename from data/foo.txt
4+
rename to data/bar.txt
5+
Binary files a/data/foo.txt and b/data/bar.txt differ

0 commit comments

Comments
 (0)