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 <gitster@pobox.com> Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Jun 24, 2024 at 21:15 UTC
0f4b0d4cf0e192b770529b97712f31dcf365e118
2 files changed
+11
-1
diff.c
+2
-1
@@ -4926,7 +4926,8 @@ void diff_setup_done(struct diff_options *options)
4926
if (options->flags.follow_renames)
4927
diff_check_follow_pathspec(&options->pathspec, 1);
4928
4929
- if (!options->use_color || external_diff())
4929
+ if (!options->use_color ||
4930
+ (options->flags.allow_external && external_diff()))
4931
options->color_moved = 0;
4932
4933
if (options->filter_not) {
t/t4015-diff-whitespace.sh
+9
@@ -1184,6 +1184,15 @@ test_expect_success 'detect moved code, complete file' '
1184
test_cmp expected actual
1185
'
1186
1187
+test_expect_success '--color-moved with --no-ext-diff' '
1188
+ test_config color.diff.oldMoved "yellow" &&
1189
+ test_config color.diff.newMoved "blue" &&
1190
+ args="--color --color-moved=zebra --no-renames HEAD" &&
1191
+ git diff $args >expect &&
1192
+ git -c diff.external=echo diff --no-ext-diff $args >actual &&
1193
+ test_cmp expect actual
1194
+'
1195
+
1196
test_expect_success 'detect malicious moved code, inside file' '
1197
test_config color.diff.oldMoved "normal red" &&
1198
test_config color.diff.newMoved "normal green" &&