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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 18, 2013, 16:24 UTC
Message-ID
<xmqq4n79d6f1.fsf@gitster.dls.corp.google.com>
In-Reply-To
<CALkWK0k4MudojZt4PkLjnq0uZe322n30WP-=N0ckLw2QcnbzMA@mail.gmail.com>
Ramkumar Ramachandra <artagnon@gmail.com> writes:
Show 22 quoted lines
> 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.
Previous: Ramkumar RamachandraNext: Ramkumar Ramachandra
Message 11 of 12 in “Minor f-e-r enhacements”
  1. 0/3 Minor f-e-r enhacementsRamkumar Ramachandra, Nov 13, 2013
  2. 1/3 for-each-ref: introduce %(HEAD) asterisk markerRamkumar Ramachandra, Nov 13, 2013
  3. 2/3 for-each-ref: introduce %(upstream:track[short])Ramkumar Ramachandra, Nov 13, 2013
  4. Junio C HamanoNov 13, 2013
  5. Junio C HamanoNov 13, 2013
  6. Ramkumar RamachandraNov 14, 2013
  7. 3/3 for-each-ref: introduce %(color:...) for colorRamkumar Ramachandra, Nov 13, 2013
  8. Junio C HamanoNov 13, 2013
  9. Junio C HamanoNov 13, 2013
  10. Ramkumar RamachandraNov 14, 2013
  11. Junio C HamanoNov 18, 2013
  12. Ramkumar RamachandraNov 18, 2013

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.