Skip to content
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
2 changes: 1 addition & 1 deletion src/diff.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ binary_merge_conflict_diff

rename_or_copy_diff
= rename_or_copy_diff_header_line modes:changed_file_modes? similarity:similarity_index copy_from:rename_copy_from copy_to:rename_copy_to
index_modes:index_line? patch:patch?
index_modes:index_line? patch:(binary_declaration / patch)?
{
return postProcessSimilarityDiff(copy_from.operation, similarity, copy_from.file, copy_to.file, modes || index_modes, patch)
}
Expand Down
22 changes: 22 additions & 0 deletions test/diff.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,28 @@ exports.testBinaryFiles = function(test) {
test.done()
}

exports.testBinaryFilesRename = function(test) {
var str = dedent`
diff --git a/dir_a/one.png b/dir_b/one.png
similarity index 100%
rename from dir_a/one.png
rename to dir_b/one.png
Binary files differ
`

const output = diff.parse(str)
assert.deepEqual(output, [
{
oldPath: 'dir_a/one.png',
newPath: 'dir_b/one.png',
hunks: undefined,
status: 'renamed',
similarity: 100
}
])
test.done()
}

exports.testNoPatch = function(test) {
var str = dedent`
diff --git file.txt file.txt
Expand Down