]> git.ipfire.org Git - thirdparty/git.git/commitdiff
diff: allow --color-moved with --no-ext-diff
authorRené Scharfe <l.s.r@web.de>
Mon, 24 Jun 2024 19:15:45 +0000 (21:15 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 24 Jun 2024 20:49:41 +0000 (13:49 -0700)
We ignore the option --color-moved if an external diff program is
configured, presumably because its overhead is unnecessary in that case.
Respect the option if we don't actually use the external diff, though.

Reported-by: lolligerhans@gmx.de
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c
t/t4015-diff-whitespace.sh

diff --git a/diff.c b/diff.c
index 108c1875775df223c4ca4f9dec27194033a7cfaa..a22d61a5c458039acef88f375ae3fe2109f8feb7 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -4926,7 +4926,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) {
index b443626afd7271a6e58ccfc45429759b9b8c00ca..851cfe4f32cd8d906a91b848443c9c27db1b6e69 100755 (executable)
@@ -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" &&