From 93fdf301de0daa57fd6a694ad4637ec7a3a1041c Mon Sep 17 00:00:00 2001 From: Stephen Kent Date: Fri, 21 Apr 2017 22:42:02 -0700 Subject: [PATCH] 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 Signed-off-by: Junio C Hamano --- Documentation/config.txt | 5 ++++- builtin/commit.c | 4 ++++ contrib/completion/git-completion.bash | 2 ++ t/t7508-status.sh | 6 ++++-- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index 475e874d51..96e9cf8b73 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -1137,7 +1137,10 @@ color.status.:: `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:: diff --git a/builtin/commit.c b/builtin/commit.c index 1d805f5da8..9028bfacf8 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -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; } diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index b617019075..72c6d58965 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -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 diff --git a/t/t7508-status.sh b/t/t7508-status.sh index a000ed4e7f..567c4d4bab 100755 --- a/t/t7508-status.sh +++ b/t/t7508-status.sh @@ -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 ' @@ -730,7 +732,7 @@ test_expect_success 'status -s with color.status' ' ' cat >expect <<\EOF -## master...upstream [ahead 1, behind 2] +## master...upstream [ahead 1, behind 2] M dir1/modified A dir2/added ?? dir1/untracked -- 2.11.4.GIT