Skip to content

Commit aa14a0c

Browse files
committed
Merge branch 'maint'
* maint: Teach "git diff" to honour --[no-]ext-diff
2 parents 78a0014 + 5aa3bdd commit aa14a0c

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

builtin-diff.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,9 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
290290
/* Otherwise, we are doing the usual "git" diff */
291291
rev.diffopt.skip_stat_unmatch = !!diff_auto_refresh_index;
292292

293+
/* Default to let external be used */
294+
DIFF_OPT_SET(&rev.diffopt, ALLOW_EXTERNAL);
295+
293296
if (nongit)
294297
die("Not a git repository");
295298
argc = setup_revisions(argc, argv, &rev, NULL);
@@ -298,7 +301,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
298301
if (diff_setup_done(&rev.diffopt) < 0)
299302
die("diff_setup_done failed");
300303
}
301-
DIFF_OPT_SET(&rev.diffopt, ALLOW_EXTERNAL);
304+
302305
DIFF_OPT_SET(&rev.diffopt, RECURSIVE);
303306
DIFF_OPT_SET(&rev.diffopt, ALLOW_TEXTCONV);
304307

t/t4020-diff-external.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ test_expect_success 'GIT_EXTERNAL_DIFF environment should apply only to diff' '
4343
4444
'
4545

46+
test_expect_success 'GIT_EXTERNAL_DIFF environment and --no-ext-diff' '
47+
48+
GIT_EXTERNAL_DIFF=echo git diff --no-ext-diff |
49+
grep "^diff --git a/file b/file"
50+
51+
'
52+
4653
test_expect_success 'diff attribute' '
4754
4855
git config diff.parrot.command echo &&
@@ -68,6 +75,13 @@ test_expect_success 'diff attribute should apply only to diff' '
6875
6976
'
7077

78+
test_expect_success 'diff attribute and --no-ext-diff' '
79+
80+
git diff --no-ext-diff |
81+
grep "^diff --git a/file b/file"
82+
83+
'
84+
7185
test_expect_success 'diff attribute' '
7286
7387
git config --unset diff.parrot.command &&
@@ -94,6 +108,13 @@ test_expect_success 'diff attribute should apply only to diff' '
94108
95109
'
96110

111+
test_expect_success 'diff attribute and --no-ext-diff' '
112+
113+
git diff --no-ext-diff |
114+
grep "^diff --git a/file b/file"
115+
116+
'
117+
97118
test_expect_success 'no diff with -diff' '
98119
echo >.gitattributes "file -diff" &&
99120
git diff | grep Binary

0 commit comments

Comments
 (0)