Skip to content

Commit f367398

Browse files
BenabikJunio C Hamano
authored andcommitted
Add documentation for git-branch's color configuration.
Added color.branch and color.branch.<slot> to configuration list. Style copied from color.status and meanings derived from the code. Moved the color meanings from color.diff.<slot> to color.branch.<slot> since the latter comes first alphabetically. Added --color and --no-color to git-branch's usage and documentation. Signed-off-by: Brian Gernhardt <benji@silverinsanity.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 956259e commit f367398

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

Documentation/config.txt

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,21 @@ branch.<name>.merge::
145145
this option, `git pull` defaults to merge the first refspec fetched.
146146
Specify multiple values to get an octopus merge.
147147

148+
color.branch::
149+
A boolean to enable/disable color in the output of
150+
gitlink:git-branch[1]. May be set to `true` (or `always`),
151+
`false` (or `never`) or `auto`, in which case colors are used
152+
only when the output is to a terminal. Defaults to false.
153+
154+
color.branch.<slot>::
155+
Use customized color for branch coloration. `<slot>` is one of
156+
`current` (the current branch), `local` (a local branch),
157+
`remote` (a tracking branch in refs/remotes/), `plain` (other
158+
refs), or `reset` (the normal terminal color). The value for
159+
these configuration variables can be one of: `normal`, `bold`,
160+
`dim`, `ul`, `blink`, `reverse`, `reset`, `black`, `red`,
161+
`green`, `yellow`, `blue`, `magenta`, `cyan`, or `white`.
162+
148163
color.diff::
149164
When true (or `always`), always use colors in patch.
150165
When false (or `never`), never. When set to `auto`, use
@@ -155,11 +170,8 @@ color.diff.<slot>::
155170
specifies which part of the patch to use the specified
156171
color, and is one of `plain` (context text), `meta`
157172
(metainformation), `frag` (hunk header), `old` (removed
158-
lines), or `new` (added lines). The value for these
159-
configuration variables can be one of: `normal`, `bold`,
160-
`dim`, `ul`, `blink`, `reverse`, `reset`, `black`,
161-
`red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, or
162-
`white`.
173+
lines), or `new` (added lines). The values of these
174+
variables may be specified as in color.branch.<slot>.
163175

164176
color.pager::
165177
A boolean to enable/disable colored output when the pager is in
@@ -177,7 +189,7 @@ color.status.<slot>::
177189
`added` or `updated` (files which are added but not committed),
178190
`changed` (files which are changed but not added in the index),
179191
or `untracked` (files which are not tracked by git). The values of
180-
these variables may be specified as in color.diff.<slot>.
192+
these variables may be specified as in color.branch.<slot>.
181193

182194
diff.renameLimit::
183195
The number of files to consider when performing the copy/rename

Documentation/git-branch.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ git-branch - List, create, or delete branches.
88
SYNOPSIS
99
--------
1010
[verse]
11-
'git-branch' [-r | -a] [-v [--abbrev=<length>]]
11+
'git-branch' [--color | --no-color] [-r | -a] [-v [--abbrev=<length>]]
1212
'git-branch' [-l] [-f] <branchname> [<start-point>]
1313
'git-branch' (-m | -M) [<oldbranch>] <newbranch>
1414
'git-branch' (-d | -D) [-r] <branchname>...
@@ -60,6 +60,13 @@ OPTIONS
6060
-M::
6161
Move/rename a branch even if the new branchname already exists.
6262

63+
--color::
64+
Color branches to highlight current, local, and remote branches.
65+
66+
--no-color::
67+
Turn off branch colors, even when the configuration file gives the
68+
default to color output.
69+
6370
-r::
6471
List or delete (if used with -d) the remote-tracking branches.
6572

builtin-branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "builtin.h"
1313

1414
static const char builtin_branch_usage[] =
15-
"git-branch [-r] (-d | -D) <branchname> | [-l] [-f] <branchname> [<start-point>] | (-m | -M) [<oldbranch>] <newbranch> | [-r | -a] [-v [--abbrev=<length>]]";
15+
"git-branch [-r] (-d | -D) <branchname> | [-l] [-f] <branchname> [<start-point>] | (-m | -M) [<oldbranch>] <newbranch> | [--color | --no-color] [-r | -a] [-v [--abbrev=<length>]]";
1616

1717
#define REF_UNKNOWN_TYPE 0x00
1818
#define REF_LOCAL_BRANCH 0x01

0 commit comments

Comments
 (0)