Skip to content

Commit

Permalink
Merge branch 'sb/diff-color-move-more'
Browse files Browse the repository at this point in the history
"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
  • Loading branch information
gitster committed Aug 2, 2018
2 parents 7a13547 + 626c0b5 commit a81575a
Show file tree
Hide file tree
Showing 7 changed files with 489 additions and 88 deletions.
5 changes: 5 additions & 0 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,11 @@ diff.colorMoved::
true the default color mode will be used. When set to false,
moved lines are not colored.

diff.colorMovedWS::
When moved lines are colored using e.g. the `diff.colorMoved` setting,
this option controls the `<mode>` how spaces are treated
for details of valid modes see '--color-moved-ws' in linkgit:git-diff[1].

color.diff.<slot>::
Use customized color for diff colorization. `<slot>` specifies
which part of the patch to use the specified color, and is one
Expand Down
33 changes: 31 additions & 2 deletions Documentation/diff-options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,14 @@ plain::
that are added somewhere else in the diff. This mode picks up any
moved line, but it is not very useful in a review to determine
if a block of code was moved without permutation.
zebra::
blocks::
Blocks of moved text of at least 20 alphanumeric characters
are detected greedily. The detected blocks are
painted using either the 'color.diff.{old,new}Moved' color or
painted using either the 'color.diff.{old,new}Moved' color.
Adjacent blocks cannot be told apart.
zebra::
Blocks of moved text are detected as in 'blocks' mode. The blocks
are painted using either the 'color.diff.{old,new}Moved' color or
'color.diff.{old,new}MovedAlternative'. The change between
the two colors indicates that a new block was detected.
dimmed_zebra::
Expand All @@ -288,6 +292,31 @@ dimmed_zebra::
blocks are considered interesting, the rest is uninteresting.
--

--color-moved-ws=<modes>::
This configures how white spaces are ignored when performing the
move detection for `--color-moved`.
ifdef::git-diff[]
It can be set by the `diff.colorMovedWS` configuration setting.
endif::git-diff[]
These modes can be given as a comma separated list:
+
--
ignore-space-at-eol::
Ignore changes in whitespace at EOL.
ignore-space-change::
Ignore changes in amount of whitespace. This ignores whitespace
at line end, and considers all other sequences of one or
more whitespace characters to be equivalent.
ignore-all-space::
Ignore whitespace when comparing lines. This ignores differences
even if one line has whitespace where the other line has none.
allow-indentation-change::
Initially ignore any white spaces in the move detection, then
group the moved code blocks only into a block if the change in
whitespace is the same per line. This is incompatible with the
other modes.
--

--word-diff[=<mode>]::
Show a word diff, using the <mode> to delimit changed words.
By default, words are delimited by whitespace; see
Expand Down
Loading

0 comments on commit a81575a

Please sign in to comment.