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

Re: [PATCH] pretty: fix lost and leaked colors at line breaks

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 16, 2026, 16:25 UTC
Message-ID
<xmqq4idgn3py.fsf@gitster.g>
In-Reply-To
<2f9f835e3f99d7de5bbf51be2e8ef4dc0485a46e.1794778250.git.andy.koppe@gmail.com>
Andy Koppe <andy.koppe@gmail.com> writes:
Show 9 quoted lines
> Colors in custom log formats remain in effect until reset, including
> across line breaks. Lines therefore don't necessarily set their own
> colors, nor reset them at their end, which leads to two problems.
>
> Firstly, lines that continue colors from preceding lines lose them when
> shown without that context. Notably, --graph and color-aware pagers such
> as less reset colors at line breaks, so for example "%C(bold)%w(72)%s"
> only makes the first line of a wrapped subject bold, and "%C(cyan)%b"
> only colors the first line of the message body.

And custom format writers have no way to control what happens at the (artificial) line boundary that wrapping at 72 columns %w(72) introduces, %b may include many lines but there is nothing for them to say "at the end of each and every line, do this". And that is why you decided that runtime detection is the only way to do this to help custom formats?

OK. My initial reaction to the "let's do the same as the default format output" was "isn't that the responsibility of those who write their own custom format?", but there clearly is a gap in the custom format feature that makes it impossible for them to do so.

> The same can happen to
> lines picked out by grepping colored output.
I am not sure if that is a problem.
> Secondly, colors that are still active at the end of a line can leak
> into what follows.
That somehow feels contradictory with the previous point, though.
Previous: Andy KoppeNext: Andy Koppe
Message 2 of 5 in “pretty: fix lost and leaked colors at line breaks”
  1. pretty: fix lost and leaked colors at line breaksAndy Koppe, Nov 15, 2026
  2. Junio C HamanoNov 16, 2026
  3. Andy KoppeNov 17, 2026
  4. pretty: fix lost and leaked colors at line breaksAndy Koppe, Nov 17, 2026
  5. pretty: fix lost and leaked colors at line breaksAndy Koppe, Nov 17, 2026

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.