Subject: Re: [PATCH v2 3/3] for-each-ref: introduce %(color:...) for color

From: Junio C Hamano <[email-masked]>
Date: Mon, 18 Nov 2013 08:24:34 -0800

Ramkumar Ramachandra <[email-masked]> writes:

> Junio C Hamano wrote:
>> Perhaps like this (obviously not tested as these three patches did
>> not add any tests ;-)
>
> Sorry about that. I didn't notice t6300-for-each-ref.sh. Will fix in
> the next round.
>
>> I also think that there should be a mechanism to do "color:reset"
>> after each record is issued automatically, and also have the color
>> output honor --color=auto from the command line, i.e.
>>
>>         git for-each-ref --color=auto --format='%(color:blue)%(subject)' | cat
>>
>> should turn the coloring off.
>
> We can add --color=auto later, but I'm wondering about auto-reset
> color after each token. What happens if I do:
>
>   $ git for-each-ref --format='%(subject)%(color:blue)'
>
> No color, right? So, it should be auto-reset color after each token
> _and_ at end of format-string.

If you are saying, by after each token, that

	--format='%(color:blue)%(A)literal string%(B)'

should result in

	<color blue> <value for A> <color reset> "literal string" <value for B>

then I would disagree.  I was suggesting it to instead produce

	<color blue> <value for A> "literal string" <value for B> <color reset>

where the <color reset> always comes when some color is used and we
hit the end of the format string. A bonus point if we can make it so
that we emit the final reset only when the last "%(color:some)" is
not "%(color:reset)", but unconditional "reset if we ever used
color" is fine.

Thanks.