# [PATCH] status: default in-progress color to header color

5 messages from 2012-07-14 to 2012-07-16. Participants: Jeff King, Junio C Hamano, Matthieu Moy.
Thread: https://gitlist.dev/t/31024

## Jeff King, 2012-07-14 12:28

Subject: [PATCH] status: default in-progress color to header color
Message-ID: <20120714122828.GA6259@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20120714122828.GA6259%40sigill.intra.peff.net

```
The "status" command recently learned to describe the
in-progress operation in its long output format (e.g.,
rebasing, am, etc). The color for this message defaults to
"normal" (i.e., no color). However, if the user has set
their default header color to something besides normal, then
the message sticks out. A much saner default is to pick the
user's header color, making this message match the rest of
the header.

We already do the same trick with the "onbranch" message.
Rather than expand the current conditional to list all types
of messages which will default back to the header color, we
can just default all "nil" colors to do so, simplifying the
code. That encompasses all of the current nil color slots,
and will likely cover any future ones that will be added.

Signed-off-by: Jeff King <peff@peff.net>
---
This goes on top of lk/more-helpful-status-hints.

My intent was that this would also let "color.status.inprogress"
override it, in case a user really wanted a green message or something.
However, I notice that the original series did not add such a config
option, so this color cannot be configured at all. Furthermore, I think
the color formatting for this message is somewhat buggy.  Even if we set
it to green, you would end up with (imagine our header color is blue):

  <blue># On branch master<reset>
  <green># You are in the middle of a rebase.<reset>

when what you would probably want is:

  <blue># On branch master<reset>
  <blue># <reset><green>You are in the middle of a rebase.<reset>

I.e., the "#" bit should always be in the header color, and only the
message text should change colors. This is how the "onbranch" message is
handled.

But given that this is not even configurable in the current code, I
really wonder if it needs to have its own color at all. Do people really
want to set the color of this message separately? Maybe we should just
use WT_STATUS_HEADER instead.

 wt-status.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/wt-status.c b/wt-status.c
index c749267..2f724b4 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -24,7 +24,7 @@ static char default_wt_status_colors[][COLOR_MAXLEN] = {
 	GIT_COLOR_GREEN,  /* WT_STATUS_LOCAL_BRANCH */
 	GIT_COLOR_RED,    /* WT_STATUS_REMOTE_BRANCH */
 	GIT_COLOR_NIL,    /* WT_STATUS_ONBRANCH */
-	GIT_COLOR_NORMAL, /* WT_STATUS_IN_PROGRESS */
+	GIT_COLOR_NIL,    /* WT_STATUS_IN_PROGRESS */
 };
 
 static const char *color(int slot, struct wt_status *s)
@@ -32,7 +32,7 @@ static const char *color(int slot, struct wt_status *s)
 	const char *c = "";
 	if (want_color(s->use_color))
 		c = s->color_palette[slot];
-	if (slot == WT_STATUS_ONBRANCH && color_is_nil(c))
+	if (color_is_nil(c))
 		c = s->color_palette[WT_STATUS_HEADER];
 	return c;
 }
-- 
1.7.10.5.40.gbbc17de

```

## Jeff King, 2012-07-14 12:36

Subject: Re: [PATCH] status: default in-progress color to header color
Message-ID: <20120714123638.GA10431@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20120714123638.GA10431%40sigill.intra.peff.net
In-Reply-To: <20120714122828.GA6259@sigill.intra.peff.net>

```
On Sat, Jul 14, 2012 at 08:28:28AM -0400, Jeff King wrote:

> My intent was that this would also let "color.status.inprogress"
> override it, in case a user really wanted a green message or something.
> However, I notice that the original series did not add such a config
> option, so this color cannot be configured at all. Furthermore, I think
> the color formatting for this message is somewhat buggy.  Even if we set
> it to green, you would end up with (imagine our header color is blue):
> 
>   <blue># On branch master<reset>
>   <green># You are in the middle of a rebase.<reset>
> 
> when what you would probably want is:
> 
>   <blue># On branch master<reset>
>   <blue># <reset><green>You are in the middle of a rebase.<reset>
> 
> I.e., the "#" bit should always be in the header color, and only the
> message text should change colors. This is how the "onbranch" message is
> handled.
> 
> But given that this is not even configurable in the current code, I
> really wonder if it needs to have its own color at all. Do people really
> want to set the color of this message separately? Maybe we should just
> use WT_STATUS_HEADER instead.

And that patch would look like this (directly on top of
lk/more-helpful-status-hints):

-- >8 --
Subject: [PATCH] status: color in-progress message like other header messages

The "status" command recently learned to describe the
in-progress operation in its long output format (e.g.,
rebasing, am, etc). This message gets its own slot in the
color table, even though it is not configurable. As a
result, if the user has set color.status.header to a
non-default value, this message will not match (and cannot
be made to match, as there is no config option).

It is probably more sane to just color it like the rest of
the text (i.e., just use color.status.header). This would
not allow users to customize the color of this message
independently, but it is not likely that anyone will want to
(and they cannot with the current code, anyway).

Signed-off-by: Jeff King <peff@peff.net>
---
 wt-status.c | 3 +--
 wt-status.h | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/wt-status.c b/wt-status.c
index c749267..c110cbc 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -24,7 +24,6 @@ static char default_wt_status_colors[][COLOR_MAXLEN] = {
 	GIT_COLOR_GREEN,  /* WT_STATUS_LOCAL_BRANCH */
 	GIT_COLOR_RED,    /* WT_STATUS_REMOTE_BRANCH */
 	GIT_COLOR_NIL,    /* WT_STATUS_ONBRANCH */
-	GIT_COLOR_NORMAL, /* WT_STATUS_IN_PROGRESS */
 };
 
 static const char *color(int slot, struct wt_status *s)
@@ -931,7 +930,7 @@ static void show_bisect_in_progress(struct wt_status *s,
 
 static void wt_status_print_state(struct wt_status *s)
 {
-	const char *state_color = color(WT_STATUS_IN_PROGRESS, s);
+	const char *state_color = color(WT_STATUS_HEADER, s);
 	struct wt_status_state state;
 	struct stat st;
 
diff --git a/wt-status.h b/wt-status.h
index c1066a0..f8fc58c 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -15,7 +15,6 @@ enum color_wt_status {
 	WT_STATUS_LOCAL_BRANCH,
 	WT_STATUS_REMOTE_BRANCH,
 	WT_STATUS_ONBRANCH,
-	WT_STATUS_IN_PROGRESS,
 	WT_STATUS_MAXSLOT
 };
 
-- 
1.7.10.5.40.gbbc17de

```

## Junio C Hamano, 2012-07-14 20:20

Subject: Re: [PATCH] status: default in-progress color to header color
Message-ID: <7vvchq5c3c.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vvchq5c3c.fsf%40alter.siamese.dyndns.org
In-Reply-To: <20120714122828.GA6259@sigill.intra.peff.net>

```
Jeff King <peff@peff.net> writes:

> But given that this is not even configurable in the current code, I
> really wonder if it needs to have its own color at all. Do people really
> want to set the color of this message separately? Maybe we should just
> use WT_STATUS_HEADER instead.

I would prefer that myself, but let's see if Matthieu's folks have
opinions on this or something you and I overlooked.

Thanks.

```

## Matthieu Moy, 2012-07-16 09:59

Subject: Re: [PATCH] status: default in-progress color to header color
Message-ID: <vpq8vek10xa.fsf@bauges.imag.fr>
URL: https://gitlist.dev/e/vpq8vek10xa.fsf%40bauges.imag.fr
In-Reply-To: <20120714123638.GA10431@sigill.intra.peff.net>

```
Jeff King <peff@peff.net> writes:

> Subject: [PATCH] status: color in-progress message like other header messages

My feeling is that these "in progress" messages would deserve to be more
visible than the usual headers (like "Not currently on any branch.",
which is both legit and likely to be a user-error). For example, the
other day, the patch told me I was bisecting. I thought it was a bug in
the patch, but it was indeed a user-error of mine, I did not end this
bisect session properly around a month ago ;-).

This would argue in favor of having a different, configurable color.

But as the code currently does not allow user-configuration anyway, it's
probably best to make the code clean and uniform. If someone wants to
add customizability afterwards, it won't be that hard (it's probably a
good idea to have people leave with these messages for a while before
deciding what color it should be).

This second patch looks better to me, but no strong opinion here.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```

## Jeff King, 2012-07-16 11:39

Subject: Re: [PATCH] status: default in-progress color to header color
Message-ID: <20120716113954.GB4962@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20120716113954.GB4962%40sigill.intra.peff.net
In-Reply-To: <vpq8vek10xa.fsf@bauges.imag.fr>

```
On Mon, Jul 16, 2012 at 11:59:45AM +0200, Matthieu Moy wrote:

> Jeff King <peff@peff.net> writes:
> 
> > Subject: [PATCH] status: color in-progress message like other header messages
> 
> My feeling is that these "in progress" messages would deserve to be more
> visible than the usual headers (like "Not currently on any branch.",
> which is both legit and likely to be a user-error). For example, the
> other day, the patch told me I was bisecting. I thought it was a bug in
> the patch, but it was indeed a user-error of mine, I did not end this
> bisect session properly around a month ago ;-).
> 
> This would argue in favor of having a different, configurable color.

Sure, I have no problem with that reasoning. Only the half-done
implementation. :)

> But as the code currently does not allow user-configuration anyway, it's
> probably best to make the code clean and uniform. If someone wants to
> add customizability afterwards, it won't be that hard (it's probably a
> good idea to have people leave with these messages for a while before
> deciding what color it should be).
> 
> This second patch looks better to me, but no strong opinion here.

Let's go with the second patch for now, then. It fixes the immediate
problem, and it does not make it much harder for somebody to do a
separate configurable color on top if they want to do so (now or later).
They would have to re-add the slot, but that is the least of the effort
involved; handling the partial-line coloring and the default-to-header
as ONBRANCH does is the more interesting bit, and the current code does
not do that at all.

Here's a repost with a slightly modified commit message (on top of
lk/more-helpful-status-hints, as before).

-- >8 --
Subject: status: color in-progress message like other header messages

The "status" command recently learned to describe the
in-progress operation in its long output format (e.g.,
rebasing, am, etc). This message gets its own slot in the
color table, even though it is not configurable. As a
result, if the user has set color.status.header to a
non-default value, this message will not match (and cannot
be made to match, as there is no config option).

It is probably more sane to just color it like the rest of
the text (i.e., just use color.status.header). This would
not allow users to customize the color of this message
independently, but they cannot do that with the current code
anyway, and if somebody wants to build customizable
colorization later, this patch does not make it much harder
to do so.

Signed-off-by: Jeff King <peff@peff.net>
---
 wt-status.c | 3 +--
 wt-status.h | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/wt-status.c b/wt-status.c
index c749267..c110cbc 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -24,7 +24,6 @@ static char default_wt_status_colors[][COLOR_MAXLEN] = {
 	GIT_COLOR_GREEN,  /* WT_STATUS_LOCAL_BRANCH */
 	GIT_COLOR_RED,    /* WT_STATUS_REMOTE_BRANCH */
 	GIT_COLOR_NIL,    /* WT_STATUS_ONBRANCH */
-	GIT_COLOR_NORMAL, /* WT_STATUS_IN_PROGRESS */
 };
 
 static const char *color(int slot, struct wt_status *s)
@@ -931,7 +930,7 @@ static void show_bisect_in_progress(struct wt_status *s,
 
 static void wt_status_print_state(struct wt_status *s)
 {
-	const char *state_color = color(WT_STATUS_IN_PROGRESS, s);
+	const char *state_color = color(WT_STATUS_HEADER, s);
 	struct wt_status_state state;
 	struct stat st;
 
diff --git a/wt-status.h b/wt-status.h
index c1066a0..f8fc58c 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -15,7 +15,6 @@ enum color_wt_status {
 	WT_STATUS_LOCAL_BRANCH,
 	WT_STATUS_REMOTE_BRANCH,
 	WT_STATUS_ONBRANCH,
-	WT_STATUS_IN_PROGRESS,
 	WT_STATUS_MAXSLOT
 };
 
-- 
1.7.10.5.40.gbbc17de

```
