[PATCH] diff: allow --color-moved with --no-ext-diff
- From
René Scharfe <l.s.r@web.de>
- Date
- Jun 22, 2024, 19:41 UTC
- Message-ID
- <8a8bd51e-9ce5-4a68-bfbe-f16dcbb7e89c@web.de>
- In-Reply-To
- <trinity-acbdb8fc-3dc3-4dca-890c-8bcb37405782-1719050465639@msvc-mesg-gmx004>
Since the option --color-moved was added by 2e2d5ac184 (diff.c: color moved lines differently, 2017-06-30) we have been ignoring it if an external diff program is configured, presumably because its overhead is unnecessary in that case.
Do respect --color-moved if we don't actually use the configured external diff, though.
Reported-by: lolligerhans@gmx.de Signed-off-by: René Scharfe <l.s.r@web.de> --- diff.c | 3 ++- t/t4015-diff-whitespace.sh | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/diff.c b/diff.c index 6e432cb8fc..aa0fb77761 100644 --- a/diff.c +++ b/diff.c @@ -4965,7 +4965,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..a1478680b6 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 "normal red" && + test_config color.diff.newMoved "normal green" && + cp actual.raw expect && + git -c diff.external=false diff HEAD --no-ext-diff \ + --color-moved=zebra --color --no-renames >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" && -- 2.45.2