Skip to content

Commit

Permalink
Merge branch 'rs/diff-color-moved-w-no-ext-diff-fix'
Browse files Browse the repository at this point in the history
"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
  • Loading branch information
gitster committed Jul 2, 2024
2 parents ca349c3 + 0f4b0d4 commit 2d97b4e
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 @@ -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) {
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 2d97b4e

Please sign in to comment.