Skip to content

Commit a81575a

Browse files
committed
Merge branch 'sb/diff-color-move-more'
"git diff --color-moved" feature has further been tweaked. * sb/diff-color-move-more: diff.c: offer config option to control ws handling in move detection diff.c: add white space mode to move detection that allows indent changes diff.c: factor advance_or_nullify out of mark_color_as_moved diff.c: decouple white space treatment from move detection algorithm diff.c: add a blocks mode for moved code detection diff.c: adjust hash function signature to match hashmap expectation diff.c: do not pass diff options as keydata to hashmap t4015: avoid git as a pipe input xdiff/xdiffi.c: remove unneeded function declarations xdiff/xdiff.h: remove unused flags
2 parents 7a13547 + 626c0b5 commit a81575a

File tree

7 files changed

+489
-88
lines changed

7 files changed

+489
-88
lines changed

Documentation/config.txt

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

1155+
diff.colorMovedWS::
1156+
When moved lines are colored using e.g. the `diff.colorMoved` setting,
1157+
this option controls the `<mode>` how spaces are treated
1158+
for details of valid modes see '--color-moved-ws' in linkgit:git-diff[1].
1159+
11551160
color.diff.<slot>::
11561161
Use customized color for diff colorization. `<slot>` specifies
11571162
which part of the patch to use the specified color, and is one

Documentation/diff-options.txt

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,14 @@ plain::
276276
that are added somewhere else in the diff. This mode picks up any
277277
moved line, but it is not very useful in a review to determine
278278
if a block of code was moved without permutation.
279-
zebra::
279+
blocks::
280280
Blocks of moved text of at least 20 alphanumeric characters
281281
are detected greedily. The detected blocks are
282-
painted using either the 'color.diff.{old,new}Moved' color or
282+
painted using either the 'color.diff.{old,new}Moved' color.
283+
Adjacent blocks cannot be told apart.
284+
zebra::
285+
Blocks of moved text are detected as in 'blocks' mode. The blocks
286+
are painted using either the 'color.diff.{old,new}Moved' color or
283287
'color.diff.{old,new}MovedAlternative'. The change between
284288
the two colors indicates that a new block was detected.
285289
dimmed_zebra::
@@ -288,6 +292,31 @@ dimmed_zebra::
288292
blocks are considered interesting, the rest is uninteresting.
289293
--
290294

295+
--color-moved-ws=<modes>::
296+
This configures how white spaces are ignored when performing the
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::
305+
Ignore changes in whitespace at EOL.
306+
ignore-space-change::
307+
Ignore changes in amount of whitespace. This ignores whitespace
308+
at line end, and considers all other sequences of one or
309+
more whitespace characters to be equivalent.
310+
ignore-all-space::
311+
Ignore whitespace when comparing lines. This ignores differences
312+
even if one line has whitespace where the other line has none.
313+
allow-indentation-change::
314+
Initially ignore any white spaces in the move detection, then
315+
group the moved code blocks only into a block if the change in
316+
whitespace is the same per line. This is incompatible with the
317+
other modes.
318+
--
319+
291320
--word-diff[=<mode>]::
292321
Show a word diff, using the <mode> to delimit changed words.
293322
By default, words are delimited by whitespace; see

0 commit comments

Comments
 (0)