diff-highlight: allow configurable colors
Until now, the highlighting colors were hard-coded in the script (as "reverse" and "noreverse"), and you had to edit the script to change them. This patch teaches diff-highlight to read from color.diff-highlight.* to set them. In addition, it expands the possiblities considerably by adding two features: 1. Old/new lines can be colored independently (so you can use a color scheme that complements existing line coloring). 2. Normal, unhighlighted parts of the lines can be colored, too. Technically this can be done by separately configuring color.diff.old/new and matching it to your diff-highlight colors. But you may want a different look for your highlighted diffs versus your regular diffs. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
ff40d185d2
commit
bca45fbc1f
@ -58,6 +58,47 @@ following in your git configuration:
|
||||
diff = diff-highlight | less
|
||||
---------------------------------------------
|
||||
|
||||
|
||||
Color Config
|
||||
------------
|
||||
|
||||
You can configure the highlight colors and attributes using git's
|
||||
config. The colors for "old" and "new" lines can be specified
|
||||
independently. There are two "modes" of configuration:
|
||||
|
||||
1. You can specify a "highlight" color and a matching "reset" color.
|
||||
This will retain any existing colors in the diff, and apply the
|
||||
"highlight" and "reset" colors before and after the highlighted
|
||||
portion.
|
||||
|
||||
2. You can specify a "normal" color and a "highlight" color. In this
|
||||
case, existing colors are dropped from that line. The non-highlighted
|
||||
bits of the line get the "normal" color, and the highlights get the
|
||||
"highlight" color.
|
||||
|
||||
If no "new" colors are specified, they default to the "old" colors. If
|
||||
no "old" colors are specified, the default is to reverse the foreground
|
||||
and background for highlighted portions.
|
||||
|
||||
Examples:
|
||||
|
||||
---------------------------------------------
|
||||
# Underline highlighted portions
|
||||
[color "diff-highlight"]
|
||||
oldHighlight = ul
|
||||
oldReset = noul
|
||||
---------------------------------------------
|
||||
|
||||
---------------------------------------------
|
||||
# Varying background intensities
|
||||
[color "diff-highlight"]
|
||||
oldNormal = "black #f8cbcb"
|
||||
oldHighlight = "black #ffaaaa"
|
||||
newNormal = "black #cbeecb"
|
||||
newHighlight = "black #aaffaa"
|
||||
---------------------------------------------
|
||||
|
||||
|
||||
Bugs
|
||||
----
|
||||
|
||||
|
Reference in New Issue
Block a user