Skip to content

Commit

Permalink
status: add color config slots for branch info in "--short --branch"
Browse files Browse the repository at this point in the history
Add color config slots to be used in the status short-format when
displaying local and remote tracking branch information.

[jc: rebased on top of Peff's fix to 'git status' and tweaked the
test to check both local and remote-tracking branch output]

Signed-off-by: Stephen Kent <smkent@smkent.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
smkent authored and gitster committed Apr 28, 2017
1 parent 75177c8 commit 93fdf30
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Documentation/config.txt
Expand Up @@ -1137,7 +1137,10 @@ color.status.<slot>::
`untracked` (files which are not tracked by Git),
`branch` (the current branch),
`nobranch` (the color the 'no branch' warning is shown in, defaulting
to red), or
to red),
`localBranch` or `remoteBranch` (the local and remote branch names,
respectively, when branch and tracking information is displayed in the
status short-format), or
`unmerged` (files which have unmerged changes).

color.ui::
Expand Down
4 changes: 4 additions & 0 deletions builtin/commit.c
Expand Up @@ -1263,6 +1263,10 @@ static int parse_status_slot(const char *slot)
return WT_STATUS_NOBRANCH;
if (!strcasecmp(slot, "unmerged"))
return WT_STATUS_UNMERGED;
if (!strcasecmp(slot, "localBranch"))
return WT_STATUS_LOCAL_BRANCH;
if (!strcasecmp(slot, "remoteBranch"))
return WT_STATUS_REMOTE_BRANCH;
return -1;
}

Expand Down
2 changes: 2 additions & 0 deletions contrib/completion/git-completion.bash
Expand Up @@ -2378,7 +2378,9 @@ _git_config ()
color.status.added
color.status.changed
color.status.header
color.status.localBranch
color.status.nobranch
color.status.remoteBranch
color.status.unmerged
color.status.untracked
color.status.updated
Expand Down
6 changes: 4 additions & 2 deletions t/t7508-status.sh
Expand Up @@ -661,7 +661,9 @@ test_expect_success 'status --porcelain ignores relative paths setting' '
test_expect_success 'setup unique colors' '
git config status.color.untracked blue &&
git config status.color.branch green
git config status.color.branch green &&
git config status.color.localBranch yellow &&
git config status.color.remoteBranch cyan
'

Expand Down Expand Up @@ -730,7 +732,7 @@ test_expect_success 'status -s with color.status' '
'

cat >expect <<\EOF
## <GREEN>master<RESET>...<RED>upstream<RESET> [ahead <GREEN>1<RESET>, behind <RED>2<RESET>]
## <YELLOW>master<RESET>...<CYAN>upstream<RESET> [ahead <YELLOW>1<RESET>, behind <CYAN>2<RESET>]
<RED>M<RESET> dir1/modified
<GREEN>A<RESET> dir2/added
<BLUE>??<RESET> dir1/untracked
Expand Down

0 comments on commit 93fdf30

Please sign in to comment.