status: add color config slots for branch info in "--short --branch"

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>

Stephen Kent committed Apr 21, 2017 at 22:42 UTC 93fdf301de0daa57fd6a694ad4637ec7a3a1041c
4 files changed +14 -3
Documentation/config.txt
+4 -1
@@ -1137,7 +1137,10 @@ color.status.<slot>::
1137 `untracked` (files which are not tracked by Git),
1138 `branch` (the current branch),
1139 `nobranch` (the color the 'no branch' warning is shown in, defaulting
1140 - to red), or
1140 + to red),
1141 + `localBranch` or `remoteBranch` (the local and remote branch names,
1142 + respectively, when branch and tracking information is displayed in the
1143 + status short-format), or
1144 `unmerged` (files which have unmerged changes).
1145
1146 color.ui::
builtin/commit.c
+4
@@ -1263,6 +1263,10 @@ static int parse_status_slot(const char *slot)
1263 return WT_STATUS_NOBRANCH;
1264 if (!strcasecmp(slot, "unmerged"))
1265 return WT_STATUS_UNMERGED;
1266 + if (!strcasecmp(slot, "localBranch"))
1267 + return WT_STATUS_LOCAL_BRANCH;
1268 + if (!strcasecmp(slot, "remoteBranch"))
1269 + return WT_STATUS_REMOTE_BRANCH;
1270 return -1;
1271 }
1272
contrib/completion/git-completion.bash
+2
@@ -2378,7 +2378,9 @@ _git_config ()
2378 color.status.added
2379 color.status.changed
2380 color.status.header
2381 + color.status.localBranch
2382 color.status.nobranch
2383 + color.status.remoteBranch
2384 color.status.unmerged
2385 color.status.untracked
2386 color.status.updated
t/t7508-status.sh
+4 -2
@@ -661,7 +661,9 @@ test_expect_success 'status --porcelain ignores relative paths setting' '
661 test_expect_success 'setup unique colors' '
662
663 git config status.color.untracked blue &&
664 - git config status.color.branch green
664 + git config status.color.branch green &&
665 + git config status.color.localBranch yellow &&
666 + git config status.color.remoteBranch cyan
667
668 '
669
@@ -730,7 +732,7 @@ test_expect_success 'status -s with color.status' '
732 '
733
734 cat >expect <<\EOF
733 -## <GREEN>master<RESET>...<RED>upstream<RESET> [ahead <GREEN>1<RESET>, behind <RED>2<RESET>]
735 +## <YELLOW>master<RESET>...<CYAN>upstream<RESET> [ahead <YELLOW>1<RESET>, behind <CYAN>2<RESET>]
736 <RED>M<RESET> dir1/modified
737 <GREEN>A<RESET> dir2/added
738 <BLUE>??<RESET> dir1/untracked