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>
This commit is contained in:
@ -290,6 +290,9 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
|
|||||||
/* Otherwise, we are doing the usual "git" diff */
|
/* Otherwise, we are doing the usual "git" diff */
|
||||||
rev.diffopt.skip_stat_unmatch = !!diff_auto_refresh_index;
|
rev.diffopt.skip_stat_unmatch = !!diff_auto_refresh_index;
|
||||||
|
|
||||||
|
/* Default to let external be used */
|
||||||
|
DIFF_OPT_SET(&rev.diffopt, ALLOW_EXTERNAL);
|
||||||
|
|
||||||
if (nongit)
|
if (nongit)
|
||||||
die("Not a git repository");
|
die("Not a git repository");
|
||||||
argc = setup_revisions(argc, argv, &rev, NULL);
|
argc = setup_revisions(argc, argv, &rev, NULL);
|
||||||
@ -298,7 +301,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
|
|||||||
if (diff_setup_done(&rev.diffopt) < 0)
|
if (diff_setup_done(&rev.diffopt) < 0)
|
||||||
die("diff_setup_done failed");
|
die("diff_setup_done failed");
|
||||||
}
|
}
|
||||||
DIFF_OPT_SET(&rev.diffopt, ALLOW_EXTERNAL);
|
|
||||||
DIFF_OPT_SET(&rev.diffopt, RECURSIVE);
|
DIFF_OPT_SET(&rev.diffopt, RECURSIVE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -43,6 +43,13 @@ test_expect_success 'GIT_EXTERNAL_DIFF environment should apply only to diff' '
|
|||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'GIT_EXTERNAL_DIFF environment and --no-ext-diff' '
|
||||||
|
|
||||||
|
GIT_EXTERNAL_DIFF=echo git diff --no-ext-diff |
|
||||||
|
grep "^diff --git a/file b/file"
|
||||||
|
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'diff attribute' '
|
test_expect_success 'diff attribute' '
|
||||||
|
|
||||||
git config diff.parrot.command echo &&
|
git config diff.parrot.command echo &&
|
||||||
@ -68,6 +75,13 @@ test_expect_success 'diff attribute should apply only to diff' '
|
|||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'diff attribute and --no-ext-diff' '
|
||||||
|
|
||||||
|
git diff --no-ext-diff |
|
||||||
|
grep "^diff --git a/file b/file"
|
||||||
|
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'diff attribute' '
|
test_expect_success 'diff attribute' '
|
||||||
|
|
||||||
git config --unset diff.parrot.command &&
|
git config --unset diff.parrot.command &&
|
||||||
@ -94,6 +108,13 @@ test_expect_success 'diff attribute should apply only to diff' '
|
|||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'diff attribute and --no-ext-diff' '
|
||||||
|
|
||||||
|
git diff --no-ext-diff |
|
||||||
|
grep "^diff --git a/file b/file"
|
||||||
|
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'no diff with -diff' '
|
test_expect_success 'no diff with -diff' '
|
||||||
echo >.gitattributes "file -diff" &&
|
echo >.gitattributes "file -diff" &&
|
||||||
git diff | grep Binary
|
git diff | grep Binary
|
||||||
|
Reference in New Issue
Block a user