Skip to content

Commit adb3356

Browse files
peffgitster
authored andcommitted
doc: refactor description of color format
This is a general cleanup of the description of colors in git-config, mostly to address inaccuracies and confusion that had grown over time: - you can have many attributes, not just one - the discussion flip-flopped between colors and attributes; now we discuss everything about colors, then everything about attributes - many concepts were lumped into the first paragraph, making it hard to read, and especially to find the actual lists of colors and attributes. I stopped short of breaking those out into their own lists, as it seemed like an excessive use of vertical screen real estate. - we introduced negated attributes, but then the next paragraph basically explains how each item starts off with no attributes. So why would one need negated attributes? We now explain. - minor typo, language, and typography fixes Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 0111681 commit adb3356

File tree

1 file changed

+26
-21
lines changed

1 file changed

+26
-21
lines changed

Documentation/config.txt

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -147,27 +147,32 @@ integer::
147147
1024", "by 1024x1024", etc.
148148

149149
color::
150-
The value for a variables that takes a color is a list of
151-
colors (at most two) and attributes (at most one), separated
152-
by spaces. The colors accepted are `normal`, `black`,
153-
`red`, `green`, `yellow`, `blue`, `magenta`, `cyan` and
154-
`white`; the attributes are `bold`, `dim`, `ul`, `blink` and
155-
`reverse`. The first color given is the foreground; the
156-
second is the background. The position of the attribute, if
157-
any, doesn't matter. Attributes may be turned off specifically
158-
by prefixing them with `no` (e.g., `noreverse`, `noul`, etc).
159-
+
160-
Colors (foreground and background) may also be given as numbers between
161-
0 and 255; these use ANSI 256-color mode (but note that not all
162-
terminals may support this). If your terminal supports it, you may also
163-
specify 24-bit RGB values as hex, like `#ff0ab3`.
164-
+
165-
The attributes are meant to be reset at the beginning of each item
166-
in the colored output, so setting color.decorate.branch to `black`
167-
will paint that branch name in a plain `black`, even if the previous
168-
thing on the same output line (e.g. opening parenthesis before the
169-
list of branch names in `log --decorate` output) is set to be
170-
painted with `bold` or some other attribute.
150+
The value for a variable that takes a color is a list of
151+
colors (at most two, one for foreground and one for background)
152+
and attributes (as many as you want), separated by spaces.
153+
+
154+
The basic colors accepted are `normal`, `black`, `red`, `green`, `yellow`,
155+
`blue`, `magenta`, `cyan` and `white`. The first color given is the
156+
foreground; the second is the background.
157+
+
158+
Colors may also be given as numbers between 0 and 255; these use ANSI
159+
256-color mode (but note that not all terminals may support this). If
160+
your terminal supports it, you may also specify 24-bit RGB values as
161+
hex, like `#ff0ab3`.
162+
+
163+
The accepted attributes are `bold`, `dim`, `ul`, `blink`, and `reverse`.
164+
The position of any attributes with respect to the colors (before, after,
165+
or in between), doesn't matter. Specific attributes may be turned off
166+
by prefixing them with `no` (e.g., `noreverse`, `noul`, etc).
167+
+
168+
For git's pre-defined color slots, the attributes are meant to be reset
169+
at the beginning of each item in the colored output. So setting
170+
`color.decorate.branch` to `black` will paint that branch name in a
171+
plain `black`, even if the previous thing on the same output line (e.g.
172+
opening parenthesis before the list of branch names in `log --decorate`
173+
output) is set to be painted with `bold` or some other attribute.
174+
However, custom log formats may do more complicated and layered
175+
coloring, and the negated forms may be useful there.
171176

172177

173178
Variables

0 commit comments

Comments
 (0)