diff: allow --no-color-moved-ws
Allow --no-color-moved-ws and --color-moved-ws=no to cancel any previous --color-moved-ws option. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Phillip Wood committed
Nov 23, 2018 at 11:16 UTC
b73bcbac4a9d8c76ccdda0f0ac4b122b8e96e4b7
2 files changed
+12
-1
Documentation/diff-options.txt
+7
@@ -306,6 +306,8 @@ endif::git-diff[]
306
These modes can be given as a comma separated list:
307
+
308
--
309
+no::
310
+ Do not ignore whitespace when performing move detection.
311
ignore-space-at-eol::
312
Ignore changes in whitespace at EOL.
313
ignore-space-change::
@@ -322,6 +324,11 @@ allow-indentation-change::
324
other modes.
325
--
326
327
+--no-color-moved-ws::
328
+ Do not ignore whitespace when performing move detection. This can be
329
+ used to override configuration settings. It is the same as
330
+ `--color-moved-ws=no`.
331
+
332
--word-diff[=<mode>]::
333
Show a word diff, using the <mode> to delimit changed words.
334
By default, words are delimited by whitespace; see
diff.c
+5
-1
@@ -304,7 +304,9 @@ static int parse_color_moved_ws(const char *arg)
304
strbuf_addstr(&sb, i->string);
305
strbuf_trim(&sb);
306
307
- if (!strcmp(sb.buf, "ignore-space-change"))
307
+ if (!strcmp(sb.buf, "no"))
308
+ ret = 0;
309
+ else if (!strcmp(sb.buf, "ignore-space-change"))
310
ret |= XDF_IGNORE_WHITESPACE_CHANGE;
311
else if (!strcmp(sb.buf, "ignore-space-at-eol"))
312
ret |= XDF_IGNORE_WHITESPACE_AT_EOL;
@@ -5036,6 +5038,8 @@ int diff_opt_parse(struct diff_options *options,
5038
if (cm < 0)
5039
die("bad --color-moved argument: %s", arg);
5040
options->color_moved = cm;
5041
+ } else if (!strcmp(arg, "--no-color-moved-ws")) {
5042
+ options->color_moved_ws_handling = 0;
5043
} else if (skip_prefix(arg, "--color-moved-ws=", &arg)) {
5044
options->color_moved_ws_handling = parse_color_moved_ws(arg);
5045
} else if (skip_to_optional_arg_default(arg, "--color-words", &options->word_regex, NULL)) {