Teach "git diff" to honour --[no-]ext-diff
The original intention of 72909be (Add diff-option --ext-diff, 2007-06-30) was to optionally allow the use of external diff viewer in "git log" family (while keeping them disabled by default). It exposed the "allow external diff" bit to the UI, but forgot to adjust the "git diff" codepath that was set up to always allow use of the external diff viewer. Noticed by Nazri Ramliy; tests by René Scharfe squashed in. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Nov 26, 2008 at 09:58 UTC
61af494ca4e63cdc484ea091617ab5f3974f2f9c
2 files changed
+25
-1
builtin-diff.c
+4
-1
@@ -290,6 +290,9 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
290
/* Otherwise, we are doing the usual "git" diff */
291
rev.diffopt.skip_stat_unmatch = !!diff_auto_refresh_index;
292
293
+ /* Default to let external be used */
294
+ DIFF_OPT_SET(&rev.diffopt, ALLOW_EXTERNAL);
295
+
296
if (nongit)
297
die("Not a git repository");
298
argc = setup_revisions(argc, argv, &rev, NULL);
@@ -298,7 +301,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
301
if (diff_setup_done(&rev.diffopt) < 0)
302
die("diff_setup_done failed");
303
}
301
- DIFF_OPT_SET(&rev.diffopt, ALLOW_EXTERNAL);
304
+
305
DIFF_OPT_SET(&rev.diffopt, RECURSIVE);
306
307
/*
t/t4020-diff-external.sh
+21
@@ -43,6 +43,13 @@ test_expect_success 'GIT_EXTERNAL_DIFF environment should apply only to diff' '
43
44
'
45
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
+
53
test_expect_success 'diff attribute' '
54
55
git config diff.parrot.command echo &&
@@ -68,6 +75,13 @@ test_expect_success 'diff attribute should apply only to diff' '
75
76
'
77
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
+
85
test_expect_success 'diff attribute' '
86
87
git config --unset diff.parrot.command &&
@@ -94,6 +108,13 @@ test_expect_success 'diff attribute should apply only to diff' '
108
109
'
110
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
+
118
test_expect_success 'no diff with -diff' '
119
echo >.gitattributes "file -diff" &&
120
git diff | grep Binary