diff.c: offer config option to control ws handling in move detection

Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stefan Beller committed Jul 18, 2018 at 12:31 UTC 626c0b5d395196ddabcf9b9a430db385722689d4
3 files changed +19 -2
Documentation/config.txt
+5
@@ -1122,6 +1122,11 @@ diff.colorMoved::
1122 true the default color mode will be used. When set to false,
1123 moved lines are not colored.
1124
1125 +diff.colorMovedWS::
1126 + When moved lines are colored using e.g. the `diff.colorMoved` setting,
1127 + this option controls the `<mode>` how spaces are treated
1128 + for details of valid modes see '--color-moved-ws' in linkgit:git-diff[1].
1129 +
1130 color.diff.<slot>::
1131 Use customized color for diff colorization. `<slot>` specifies
1132 which part of the patch to use the specified color, and is one
Documentation/diff-options.txt
+5 -2
@@ -294,8 +294,11 @@ dimmed_zebra::
294
295 --color-moved-ws=<modes>::
296 This configures how white spaces are ignored when performing the
297 - move detection for `--color-moved`. These modes can be given
298 - as a comma separated list:
297 + move detection for `--color-moved`.
298 +ifdef::git-diff[]
299 + It can be set by the `diff.colorMovedWS` configuration setting.
300 +endif::git-diff[]
301 + These modes can be given as a comma separated list:
302 +
303 --
304 ignore-space-at-eol::
diff.c
+9
@@ -35,6 +35,7 @@ static int diff_rename_limit_default = 400;
35 static int diff_suppress_blank_empty;
36 static int diff_use_color_default = -1;
37 static int diff_color_moved_default;
38 +static int diff_color_moved_ws_default;
39 static int diff_context_default = 3;
40 static int diff_interhunk_context_default;
41 static const char *diff_word_regex_cfg;
@@ -332,6 +333,13 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
333 diff_color_moved_default = cm;
334 return 0;
335 }
336 + if (!strcmp(var, "diff.colormovedws")) {
337 + int cm = parse_color_moved_ws(value);
338 + if (cm < 0)
339 + return -1;
340 + diff_color_moved_ws_default = cm;
341 + return 0;
342 + }
343 if (!strcmp(var, "diff.context")) {
344 diff_context_default = git_config_int(var, value);
345 if (diff_context_default < 0)
@@ -4327,6 +4335,7 @@ void diff_setup(struct diff_options *options)
4335 }
4336
4337 options->color_moved = diff_color_moved_default;
4338 + options->color_moved_ws_handling = diff_color_moved_ws_default;
4339 }
4340
4341 void diff_setup_done(struct diff_options *options)