git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Add color slots for branch names in "git status --short --branch"

From
Jeff King <peff@peff.net>
Date
Apr 20, 2017, 06:16 UTC
Message-ID
<20170420061653.y3bhdzw6sx5zavfc@sigill.intra.peff.net>
In-Reply-To
<201704556286334.8b7dc718029e6dd189dadb3703bfa@localhost>
Overall this looks good. A few minor nits:
On Wed, Apr 19, 2017 at 10:57:08PM -0700, Stephen Kent wrote:
> Subject: Re: [PATCH] Add color slots for branch names in "git status --short

We usually try to use "subsystem: blah" for our subjects, which makes them easy to parse when you're looking through a oneline. So probably:

  status: add color config slots for branch names
or something.
Show 13 quoted lines
> 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

I wondered if this "short-format" was accurate. But indeed, we do not seem to color the local/remote branch specially in long-format mode, so it really is only the short format that is affected.

Show 12 quoted lines
> 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;

Normally we match config names in the code as all lowercase, since the key names we get from the config parser will be normalized. Here it works with your mixed-case because you're using strcasecmp(). Obviously that was picked up from the surrounding code, but I think those existing strcasecmp() calls could (and perhaps should) just be strcmp().

I don't know if it's worth converting them or not. If we leave them all as strcasecmp(), I don't mind your camelCase names, for readability.

-Peff
Previous: Stephen KentNext: Junio C Hamano
Message 2 of 5 in “Add color slots for branch names in "git status --short --branch"”
  1. Add color slots for branch names in "git status --short --branch"Stephen Kent, Apr 20, 2017
  2. Jeff KingApr 20, 2017
  3. Junio C HamanoApr 20, 2017
  4. Stephen KentApr 22, 2017
  5. Jeff KingApr 27, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.