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
This commit is contained in:
Junio C Hamano 2020-02-14 12:54:22 -08:00
Родитель 433b8aac2e da8063522f
Коммит df04a31617
2 изменённых файлов: 21 добавлений и 8 удалений

16
diff.c
Просмотреть файл

@ -414,14 +414,6 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
return 0;
}
if (!strcmp(var, "diff.wserrorhighlight")) {
int val = parse_ws_error_highlight(value);
if (val < 0)
return -1;
ws_error_highlight_default = val;
return 0;
}
if (git_color_config(var, value, cb) < 0)
return -1;
@ -450,6 +442,14 @@ int git_diff_basic_config(const char *var, const char *value, void *cb)
return color_parse(value, diff_colors[slot]);
}
if (!strcmp(var, "diff.wserrorhighlight")) {
int val = parse_ws_error_highlight(value);
if (val < 0)
return -1;
ws_error_highlight_default = val;
return 0;
}
/* like GNU diff's --suppress-blank-empty option */
if (!strcmp(var, "diff.suppressblankempty") ||
/* for backwards compatibility */

Просмотреть файл

@ -553,6 +553,19 @@ test_expect_success 'diffs can be colorized' '
grep "$(printf "\\033")" output
'
test_expect_success 'colorized diffs respect diff.wsErrorHighlight' '
git reset --hard &&
echo "old " >test &&
git add test &&
echo "new " >test &&
printf y >y &&
force_color git -c diff.wsErrorHighlight=all add -p >output.raw 2>&1 <y &&
test_decode_color <output.raw >output &&
grep "old<" output
'
test_expect_success 'diffFilter filters diff' '
git reset --hard &&