Skip to content

Commit f115662

Browse files
committed
merge-tools builtin: omit changes of binary files if hash stayed the same
When the contents of a binary file have not changed (but it appears in the tree diff because its file mode has) the builtin diff tool still presented a `Section::Binary` section to the user, showing identical descriptions for both sides of the diff. Selecting this section should not affect the selected contents, so it does not make much sense. This behavior was not captured by any of the existing snapshot tests but it will be captured by a new regression test added in the next commit.
1 parent 91ffb2a commit f115662

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

cli/src/merge_tools/builtin.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,18 @@ async fn make_diff_files(
341341
sections.extend(make_diff_sections(&old_contents, &new_contents)?);
342342
}
343343

344+
(
345+
FileContents::Binary {
346+
hash: Some(left_hash),
347+
..
348+
},
349+
FileContents::Binary {
350+
hash: Some(right_hash),
351+
..
352+
},
353+
) if left_hash == right_hash => {
354+
// Binary file contents have not changed.
355+
}
344356
(left, right @ FileContents::Binary { .. })
345357
| (left @ FileContents::Binary { .. }, right) => {
346358
sections.push(scm_record::Section::Binary {

0 commit comments

Comments
 (0)