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>
Junio C Hamano committed
Jun 26, 2008 at 15:34 UTC
5ff10dd602f5926f0f5a73ae7de5866713428aa7
1 file changed
+9
-2
diff.c
+9
-2
@@ -1544,8 +1544,9 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
1544
1545
static void builtin_checkdiff(const char *name_a, const char *name_b,
1546
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)
1550
{
1551
mmfile_t mf1, mf2;
1552
struct checkdiff_t data;
@@ -1564,6 +1565,12 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
1565
if (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0)
1566
die("unable to read files to diff");
1567
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
+ */
1574
if (diff_filespec_is_binary(two))
1575
goto free_and_return;
1576
else {