Skip to content

Commit

Permalink
diff: allow --color-moved with --no-ext-diff
Browse files Browse the repository at this point in the history
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: [email protected]
Helped-by: Junio C Hamano <[email protected]>
Signed-off-by: René Scharfe <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
rscharfe authored and gitster committed Jun 24, 2024
1 parent 786a3e4 commit 0f4b0d4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 9 additions & 0 deletions t/t4015-diff-whitespace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" &&
Expand Down

0 comments on commit 0f4b0d4

Please sign in to comment.