Skip to content

Commit 5ff10dd

Browse files
committed
diff --check: explain why we do not care whether old side is binary
All other codepaths refrain from running textual diff when either the old or the new side is binary, but this function only checks the new side. I was almost going to change it to check both, but that would be a bad change. Explain why to prevent future mistakes. Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent c0f5c69 commit 5ff10dd

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

diff.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,8 +1544,9 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
15441544

15451545
static void builtin_checkdiff(const char *name_a, const char *name_b,
15461546
const char *attr_path,
1547-
struct diff_filespec *one,
1548-
struct diff_filespec *two, struct diff_options *o)
1547+
struct diff_filespec *one,
1548+
struct diff_filespec *two,
1549+
struct diff_options *o)
15491550
{
15501551
mmfile_t mf1, mf2;
15511552
struct checkdiff_t data;
@@ -1564,6 +1565,12 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
15641565
if (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0)
15651566
die("unable to read files to diff");
15661567

1568+
/*
1569+
* All the other codepaths check both sides, but not checking
1570+
* the "old" side here is deliberate. We are checking the newly
1571+
* introduced changes, and as long as the "new" side is text, we
1572+
* can and should check what it introduces.
1573+
*/
15671574
if (diff_filespec_is_binary(two))
15681575
goto free_and_return;
15691576
else {

0 commit comments

Comments
 (0)