From: René Scharfe Date: Mon, 24 Jun 2024 19:15:45 +0000 (+0200) Subject: diff: allow --color-moved with --no-ext-diff X-Git-Tag: v2.46.0-rc0~15^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0f4b0d4cf0e192b770529b97712f31dcf365e118;p=thirdparty%2Fgit.git diff: allow --color-moved with --no-ext-diff 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 Signed-off-by: René Scharfe Signed-off-by: Junio C Hamano --- diff --git a/diff.c b/diff.c index 108c187577..a22d61a5c4 100644 --- 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) { 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" &&