Skip to content

Commit 626c0b5

Browse files
stefanbellergitster
authored andcommitted
diff.c: offer config option to control ws handling in move detection
Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ca1f4ae commit 626c0b5

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

Documentation/config.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,11 @@ diff.colorMoved::
11221122
true the default color mode will be used. When set to false,
11231123
moved lines are not colored.
11241124

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+
11251130
color.diff.<slot>::
11261131
Use customized color for diff colorization. `<slot>` specifies
11271132
which part of the patch to use the specified color, and is one

Documentation/diff-options.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,11 @@ dimmed_zebra::
294294

295295
--color-moved-ws=<modes>::
296296
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:
299302
+
300303
--
301304
ignore-space-at-eol::

diff.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ static int diff_rename_limit_default = 400;
3535
static int diff_suppress_blank_empty;
3636
static int diff_use_color_default = -1;
3737
static int diff_color_moved_default;
38+
static int diff_color_moved_ws_default;
3839
static int diff_context_default = 3;
3940
static int diff_interhunk_context_default;
4041
static const char *diff_word_regex_cfg;
@@ -332,6 +333,13 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
332333
diff_color_moved_default = cm;
333334
return 0;
334335
}
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+
}
335343
if (!strcmp(var, "diff.context")) {
336344
diff_context_default = git_config_int(var, value);
337345
if (diff_context_default < 0)
@@ -4327,6 +4335,7 @@ void diff_setup(struct diff_options *options)
43274335
}
43284336

43294337
options->color_moved = diff_color_moved_default;
4338+
options->color_moved_ws_handling = diff_color_moved_ws_default;
43304339
}
43314340

43324341
void diff_setup_done(struct diff_options *options)

0 commit comments

Comments
 (0)