aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-07-02 09:59:02 -0700
committerJunio C Hamano <gitster@pobox.com>2024-07-02 09:59:02 -0700
commit2d97b4e2358aa528f9406b3ca96981fcf89b0d11 (patch)
tree76a676bb43358f80f27ab3c3d1010b87191388fa
parentMerge branch 'ew/object-convert-leakfix' (diff)
parentdiff: allow --color-moved with --no-ext-diff (diff)
downloadgit-2d97b4e2358aa528f9406b3ca96981fcf89b0d11.tar.gz
git-2d97b4e2358aa528f9406b3ca96981fcf89b0d11.zip
Merge branch 'rs/diff-color-moved-w-no-ext-diff-fix'
"git diff --no-ext-diff" when diff.external is configured ignored the "--color-moved" option. * rs/diff-color-moved-w-no-ext-diff-fix: diff: allow --color-moved with --no-ext-diff
-rw-r--r--diff.c3
-rwxr-xr-xt/t4015-diff-whitespace.sh9
2 files changed, 11 insertions, 1 deletions
diff --git a/diff.c b/diff.c
index 9cbf757b47..7e9041a6a9 100644
--- a/diff.c
+++ b/diff.c
@@ -4968,7 +4968,8 @@ void diff_setup_done(struct diff_options *options)
if (options->flags.follow_renames)
diff_check_follow_pathspec(&options->pathspec, 1);
- if (!options->use_color || external_diff())
+ if (!options->use_color ||
+ (options->flags.allow_external && external_diff()))
options->color_moved = 0;
if (options->filter_not) {
diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh
index b443626afd..851cfe4f32 100755
--- a/t/t4015-diff-whitespace.sh
+++ b/t/t4015-diff-whitespace.sh
@@ -1184,6 +1184,15 @@ test_expect_success 'detect moved code, complete file' '
test_cmp expected actual
'
+test_expect_success '--color-moved with --no-ext-diff' '
+ test_config color.diff.oldMoved "yellow" &&
+ test_config color.diff.newMoved "blue" &&
+ args="--color --color-moved=zebra --no-renames HEAD" &&
+ git diff $args >expect &&
+ git -c diff.external=echo diff --no-ext-diff $args >actual &&
+ test_cmp expect actual
+'
+
test_expect_success 'detect malicious moved code, inside file' '
test_config color.diff.oldMoved "normal red" &&
test_config color.diff.newMoved "normal green" &&