Thread (10 messages) 10 messages, 4 authors, 2018-12-12

Re: Difficulty with parsing colorized diff output

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2018-12-11 16:28:30

On Tue, Dec 11 2018, Jeff King wrote:
On Mon, Dec 10, 2018 at 07:26:46PM -0800, Stefan Beller wrote:
quoted
quoted
Context lines do have both. It's just that the default color for context
lines is empty. ;)
The content itself can contain color codes.

Instead of unconditionally resetting each line, we could parse each
content line to determine if we actually have to reset the colors.
Good point. I don't recall that being the motivation back when this
behavior started, but it's a nice side effect (and the more recent line
you mentioned in emit_line_0 certainly is doing it intentionally).

That doesn't cover _other_ terminal codes, which could also make for
confusing output, but I do think color codes are somewhat special. We
generally send patches through "less -R", which will pass through the
colors but show escaped versions of other codes.
I wonder if optimizing this one way or the other matters for some
terminals. I.e. if we print out some huge diff of thousands of
consecutive "green" added lines is it faster/slower on some of them to
do one "begin green" and "reset" at the end, or is one line at a time
better, or doesn't it matter at all?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help