Skip to content

Commit b73bcba

Browse files
phillipwoodgitster
authored andcommitted
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>
1 parent 748aa1a commit b73bcba

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Documentation/diff-options.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,8 @@ endif::git-diff[]
306306
These modes can be given as a comma separated list:
307307
+
308308
--
309+
no::
310+
Do not ignore whitespace when performing move detection.
309311
ignore-space-at-eol::
310312
Ignore changes in whitespace at EOL.
311313
ignore-space-change::
@@ -322,6 +324,11 @@ allow-indentation-change::
322324
other modes.
323325
--
324326

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+
325332
--word-diff[=<mode>]::
326333
Show a word diff, using the <mode> to delimit changed words.
327334
By default, words are delimited by whitespace; see

diff.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,9 @@ static int parse_color_moved_ws(const char *arg)
304304
strbuf_addstr(&sb, i->string);
305305
strbuf_trim(&sb);
306306

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"))
308310
ret |= XDF_IGNORE_WHITESPACE_CHANGE;
309311
else if (!strcmp(sb.buf, "ignore-space-at-eol"))
310312
ret |= XDF_IGNORE_WHITESPACE_AT_EOL;
@@ -5036,6 +5038,8 @@ int diff_opt_parse(struct diff_options *options,
50365038
if (cm < 0)
50375039
die("bad --color-moved argument: %s", arg);
50385040
options->color_moved = cm;
5041+
} else if (!strcmp(arg, "--no-color-moved-ws")) {
5042+
options->color_moved_ws_handling = 0;
50395043
} else if (skip_prefix(arg, "--color-moved-ws=", &arg)) {
50405044
options->color_moved_ws_handling = parse_color_moved_ws(arg);
50415045
} else if (skip_to_optional_arg_default(arg, "--color-words", &options->word_regex, NULL)) {

0 commit comments

Comments
 (0)