All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] status: add color config slots for branch info in "--short --branch"
@ 2017-04-22  5:42 Stephen Kent
  2017-04-27  9:04 ` Jeff King
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen Kent @ 2017-04-22  5:42 UTC (permalink / raw)
  To: git; +Cc: Jeff King, Junio C Hamano

Add color config slots to be used in the status short-format when
displaying local and remote tracking branch information.

Signed-off-by: Stephen Kent <smkent@smkent.net>
---
 Documentation/config.txt               | 5 ++++-
 builtin/commit.c                       | 4 ++++
 contrib/completion/git-completion.bash | 2 ++
 t/t7508-status.sh                      | 5 +++--
 4 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 475e874..96e9cf8 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -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::
diff --git a/builtin/commit.c b/builtin/commit.c
index 4e288bc..43846d5 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 1150164..f0542b6 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2377,7 +2377,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 fb00e6d..7d42085 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -610,7 +610,8 @@ 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
 
 '
 
@@ -675,7 +676,7 @@ test_expect_success 'status -s with color.status' '
 '
 
 cat >expect <<\EOF
-## <GREEN>master<RESET>
+## <YELLOW>master<RESET>
  <RED>M<RESET> dir1/modified
 <GREEN>A<RESET>  dir2/added
 <BLUE>??<RESET> dir1/untracked
-- 
2.10.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] status: add color config slots for branch info in "--short --branch"
  2017-04-22  5:42 [PATCH v2] status: add color config slots for branch info in "--short --branch" Stephen Kent
@ 2017-04-27  9:04 ` Jeff King
  2017-04-28  2:50   ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff King @ 2017-04-27  9:04 UTC (permalink / raw)
  To: Stephen Kent; +Cc: git, Junio C Hamano

On Fri, Apr 21, 2017 at 10:42:02PM -0700, Stephen Kent wrote:

> Add color config slots to be used in the status short-format when
> displaying local and remote tracking branch information.
> 
> Signed-off-by: Stephen Kent <smkent@smkent.net>

This looks good to me, and I'd be happy if we took it as-is.

But...

> diff --git a/t/t7508-status.sh b/t/t7508-status.sh
> index fb00e6d..7d42085 100755
> --- a/t/t7508-status.sh
> +++ b/t/t7508-status.sh
> @@ -610,7 +610,8 @@ 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
>  
>  '
>  
> @@ -675,7 +676,7 @@ test_expect_success 'status -s with color.status' '
>  '
>  
>  cat >expect <<\EOF
> -## <GREEN>master<RESET>
> +## <YELLOW>master<RESET>

As we discussed elsewhere, it would be nice if this tested remoteBranch,
too. IMHO the simplest thing to is to rebase it on the t7508 update I
just posted.

The other option is to add config for remoteBranch which would do
nothing for now, and then resolve it to check the correct colors when
the two topics are merged (since the test will start failing then).
That seems unnecessarily confusing.

-Peff

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] status: add color config slots for branch info in "--short --branch"
  2017-04-27  9:04 ` Jeff King
@ 2017-04-28  2:50   ` Junio C Hamano
  2017-04-28  7:37     ` Jeff King
  0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2017-04-28  2:50 UTC (permalink / raw)
  To: Jeff King; +Cc: Stephen Kent, git

Jeff King <peff@peff.net> writes:

> As we discussed elsewhere, it would be nice if this tested remoteBranch,
> too. IMHO the simplest thing to is to rebase it on the t7508 update I
> just posted.
>
> The other option is to add config for remoteBranch which would do
> nothing for now, and then resolve it to check the correct colors when
> the two topics are merged (since the test will start failing then).
> That seems unnecessarily confusing.

Yes, let's do the former.

This is to be applied on top of your
<20170427090105.vaodugbqdaxunoin@sigill.intra.peff.net>

-- >8 --
From: Stephen Kent <smkent@smkent.net>
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 <smkent@smkent.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 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.<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::
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
-## <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
-- 
2.13.0-rc1-211-gd5d57c8556


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] status: add color config slots for branch info in "--short --branch"
  2017-04-28  2:50   ` Junio C Hamano
@ 2017-04-28  7:37     ` Jeff King
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff King @ 2017-04-28  7:37 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Stephen Kent, git

On Thu, Apr 27, 2017 at 07:50:32PM -0700, Junio C Hamano wrote:

> Jeff King <peff@peff.net> writes:
> 
> > As we discussed elsewhere, it would be nice if this tested remoteBranch,
> > too. IMHO the simplest thing to is to rebase it on the t7508 update I
> > just posted.
> >
> > The other option is to add config for remoteBranch which would do
> > nothing for now, and then resolve it to check the correct colors when
> > the two topics are merged (since the test will start failing then).
> > That seems unnecessarily confusing.
> 
> Yes, let's do the former.
> 
> This is to be applied on top of your
> <20170427090105.vaodugbqdaxunoin@sigill.intra.peff.net>
> 
> -- >8 --
> From: Stephen Kent <smkent@smkent.net>
> Date: Fri, 21 Apr 2017 22:42:02 -0700
> Subject: [PATCH] status: add color config slots for branch info in "--short --branch"

Thanks, the result looks good to me.

-Peff

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-04-28  7:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-22  5:42 [PATCH v2] status: add color config slots for branch info in "--short --branch" Stephen Kent
2017-04-27  9:04 ` Jeff King
2017-04-28  2:50   ` Junio C Hamano
2017-04-28  7:37     ` Jeff King

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.