Skip to content

Commit 61e89ea

Browse files
stefanbellergitster
authored andcommitted
diff: document the new --color-moved setting
Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 86b452e commit 61e89ea

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed

Documentation/config.txt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,14 +1077,25 @@ This does not affect linkgit:git-format-patch[1] or the
10771077
'git-diff-{asterisk}' plumbing commands. Can be overridden on the
10781078
command line with the `--color[=<when>]` option.
10791079

1080+
diff.colorMoved::
1081+
If set to either a valid `<mode>` or a true value, moved lines
1082+
in a diff are colored differently, for details of valid modes
1083+
see '--color-moved' in linkgit:git-diff[1]. If simply set to
1084+
true the default color mode will be used. When set to false,
1085+
moved lines are not colored.
1086+
10801087
color.diff.<slot>::
10811088
Use customized color for diff colorization. `<slot>` specifies
10821089
which part of the patch to use the specified color, and is one
10831090
of `context` (context text - `plain` is a historical synonym),
10841091
`meta` (metainformation), `frag`
10851092
(hunk header), 'func' (function in hunk header), `old` (removed lines),
1086-
`new` (added lines), `commit` (commit headers), or `whitespace`
1087-
(highlighting whitespace errors).
1093+
`new` (added lines), `commit` (commit headers), `whitespace`
1094+
(highlighting whitespace errors), `oldMoved` (deleted lines),
1095+
`newMoved` (added lines), `oldMovedDimmed`, `oldMovedAlternative`,
1096+
`oldMovedAlternativeDimmed`, `newMovedDimmed`, `newMovedAlternative`
1097+
and `newMovedAlternativeDimmed` (See the '<mode>'
1098+
setting of '--color-moved' in linkgit:git-diff[1] for details).
10881099

10891100
color.decorate.<slot>::
10901101
Use customized color for 'git log --decorate' output. `<slot>` is one

Documentation/diff-options.txt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,42 @@ ifdef::git-diff[]
231231
endif::git-diff[]
232232
It is the same as `--color=never`.
233233

234+
--color-moved[=<mode>]::
235+
Moved lines of code are colored differently.
236+
ifdef::git-diff[]
237+
It can be changed by the `diff.colorMoved` configuration setting.
238+
endif::git-diff[]
239+
The <mode> defaults to 'no' if the option is not given
240+
and to 'zebra' if the option with no mode is given.
241+
The mode must be one of:
242+
+
243+
--
244+
no::
245+
Moved lines are not highlighted.
246+
default::
247+
Is a synonym for `zebra`. This may change to a more sensible mode
248+
in the future.
249+
plain::
250+
Any line that is added in one location and was removed
251+
in another location will be colored with 'color.diff.newMoved'.
252+
Similarly 'color.diff.oldMoved' will be used for removed lines
253+
that are added somewhere else in the diff. This mode picks up any
254+
moved line, but it is not very useful in a review to determine
255+
if a block of code was moved without permutation.
256+
zebra::
257+
Blocks of moved code are detected greedily. The detected blocks are
258+
painted using either the 'color.diff.{old,new}Moved' color or
259+
'color.diff.{old,new}MovedAlternative'. The change between
260+
the two colors indicates that a new block was detected. If there
261+
are fewer than 3 adjacent moved lines, they are not marked up
262+
as moved, but the regular colors 'color.diff.{old,new}' will be
263+
used.
264+
dimmed_zebra::
265+
Similar to 'zebra', but additional dimming of uninteresting parts
266+
of moved code is performed. The bordering lines of two adjacent
267+
blocks are considered interesting, the rest is uninteresting.
268+
--
269+
234270
--word-diff[=<mode>]::
235271
Show a word diff, using the <mode> to delimit changed words.
236272
By default, words are delimited by whitespace; see

0 commit comments

Comments
 (0)