# rfe: git-config: lack of color reset option

3 messages from 2012-02-20 to 2012-02-20. Participants: Jan Engelhardt, Jeff King, Junio C Hamano.
Thread: https://gitlist.dev/t/29673

## Jan Engelhardt, 2012-02-20 20:50

Subject: rfe: git-config: lack of color reset option
Message-ID: <alpine.LNX.2.01.1202202142160.31585@frira.zrqbmnf.qr>
URL: https://gitlist.dev/e/alpine.LNX.2.01.1202202142160.31585%40frira.zrqbmnf.qr

```
Hi,


given the following config:

[color "diff"]
	commit = bold white blue
[color "decorate"]
	branch = green

The attributes from color.diff.commit are inherited for color.decorate.

1. There seems to be no way to reset the attributes such that
"color.decorate.branch = default green blue" wouuld have an effect.

2. It would be nice if there was an option to only paint the 
commit hash, rather than the entire line including the decorate 
parenthesis group.

(My current version is 1.7.7, but there seem to be no changes regarding 
color config in 1.7.8 and 1.7.9 in the release notes, so I presume the 
issue is still current.)

```

## Jeff King, 2012-02-20 21:20

Subject: Re: rfe: git-config: lack of color reset option
Message-ID: <20120220212006.GB6335@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20120220212006.GB6335%40sigill.intra.peff.net
In-Reply-To: <alpine.LNX.2.01.1202202142160.31585@frira.zrqbmnf.qr>

```
On Mon, Feb 20, 2012 at 09:50:11PM +0100, Jan Engelhardt wrote:

> given the following config:
> 
> [color "diff"]
> 	commit = bold white blue
> [color "decorate"]
> 	branch = green
> 
> The attributes from color.diff.commit are inherited for color.decorate.

This is an artifact of the way the ANSI colorizing works. Git says "turn
on bold white and a blue background", then it outputs some content, then
it says "turn on green", and so forth. At the end we issue a "reset" to
turn everything back to normal. We should perhaps issue a reset before
outputting the decoration, as we are moving from one colorized bit to
the other, and we don't know what we are inheriting.

Of course that would break people who _want_ the blue background to
continue into the branch decoration. But they can easily fix it by
putting "green blue" in their config.

> 1. There seems to be no way to reset the attributes such that
> "color.decorate.branch = default green blue" wouuld have an effect.

I would have expected that perhaps setting color.decorate.branch to
"reset green" would work, but it seems that we don't allow arbitrary
sequences. Which would be another possible solution.

In your case, I think you just want turn off bold without resetting the
whole thing. That is its own attribute. It would be nice if we supported
"nobold", "noreverse", etc. But you wouldn't really need them if we
properly reset at the transition between two colorized bits.

> 2. It would be nice if there was an option to only paint the 
> commit hash, rather than the entire line including the decorate 
> parenthesis group.

Yeah, the parentheses are explicitly painted. I'm not sure how to easily
fix that short of adding lots of painfully small config options.

I have a long term dream that our --pretty=format specifiers would grow
featureful enough that all of the other --pretty formats could be
implemented in terms of them. And then you could tweak to your hearts
content, starting with the embedded definition of what "git log" shows
and putting colors wherever you like. I'm not sure how far we are off
from doing that now. You could try writing a format-specifier that looks
like git-log output and see if there is anything lacking.

-Peff

```

## Junio C Hamano, 2012-02-20 22:05

Subject: Re: rfe: git-config: lack of color reset option
Message-ID: <7vwr7hjh32.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vwr7hjh32.fsf%40alter.siamese.dyndns.org
In-Reply-To: <20120220212006.GB6335@sigill.intra.peff.net>

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

> This is an artifact of the way the ANSI colorizing works. Git says "turn
> on bold white and a blue background", then it outputs some content, then
> it says "turn on green", and so forth. At the end we issue a "reset" to
> turn everything back to normal. We should perhaps issue a reset before
> outputting the decoration, as we are moving from one colorized bit to
> the other, and we don't know what we are inheriting.

Yeah, I agree with the diagnosis and the proposed solution. It sounds
both simple and correct thing to do.

```
