Skip to content

Commit df04a31

Browse files
committed
Merge branch 'jk/diff-honor-wserrhighlight-in-plumbing'
The diff-* plumbing family of subcommands now pay attention to the diff.wsErrorHighlight configuration, which has been ignored before; this allows "git add -p" to also show the whitespace problems to the end user. * jk/diff-honor-wserrhighlight-in-plumbing: diff: move diff.wsErrorHighlight to "basic" config
2 parents 433b8aa + da80635 commit df04a31

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

diff.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -414,14 +414,6 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
414414
return 0;
415415
}
416416

417-
if (!strcmp(var, "diff.wserrorhighlight")) {
418-
int val = parse_ws_error_highlight(value);
419-
if (val < 0)
420-
return -1;
421-
ws_error_highlight_default = val;
422-
return 0;
423-
}
424-
425417
if (git_color_config(var, value, cb) < 0)
426418
return -1;
427419

@@ -450,6 +442,14 @@ int git_diff_basic_config(const char *var, const char *value, void *cb)
450442
return color_parse(value, diff_colors[slot]);
451443
}
452444

445+
if (!strcmp(var, "diff.wserrorhighlight")) {
446+
int val = parse_ws_error_highlight(value);
447+
if (val < 0)
448+
return -1;
449+
ws_error_highlight_default = val;
450+
return 0;
451+
}
452+
453453
/* like GNU diff's --suppress-blank-empty option */
454454
if (!strcmp(var, "diff.suppressblankempty") ||
455455
/* for backwards compatibility */

t/t3701-add-interactive.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,19 @@ test_expect_success 'diffs can be colorized' '
553553
grep "$(printf "\\033")" output
554554
'
555555

556+
test_expect_success 'colorized diffs respect diff.wsErrorHighlight' '
557+
git reset --hard &&
558+
559+
echo "old " >test &&
560+
git add test &&
561+
echo "new " >test &&
562+
563+
printf y >y &&
564+
force_color git -c diff.wsErrorHighlight=all add -p >output.raw 2>&1 <y &&
565+
test_decode_color <output.raw >output &&
566+
grep "old<" output
567+
'
568+
556569
test_expect_success 'diffFilter filters diff' '
557570
git reset --hard &&
558571

0 commit comments

Comments
 (0)