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.