lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi] Navigate by color in `git-diff --color-moved=plain`


From: Greg Chicares
Subject: [lmi] Navigate by color in `git-diff --color-moved=plain`
Date: Wed, 24 Apr 2019 20:14:17 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

When making successive revisions to lmi's build system, I find it
useful to run a command like the following, which wipes everything
clean and then rebuilds the lmi world from scratch, in a 'set -vx'
script that echoes every step into a log file:

make raze; logfile=log-`date -u +'%Y%m%dT%H%MZ'`; echo "Log file is 
'$logfile.tar.bz2'."; ./install_msw.sh >$logfile 2>&1; tar -cjf 
$logfile.tar.bz2 $logfile; mv ${logfile}* ..

and then compare the latest log to the last known-good log.

Using 'make --jobs=32' lets that script run in only five minutes
or so, but causes the exact order of identical lines to vary from
one log to the next, and older tools like 'diff' aren't ideal for
comparing logs to see whether they changed only in the way they
should...modulo permutation of identical lines. But it becomes
almost easy when I replace 'diff' with:

git diff --no-index --color-moved=plain ../log-20190421T2329Z-good 
../log-20190424T1910Z

I know I can push that particular incremental revision because
all I did was move the build directory, and the only difference
hunk shown in red and green (aside from timestamps) is this:

-rm --force --recursive /opt/lmi/src/lmi/../build/lmi//gcc/ship
+rm --force --recursive /opt/lmi/gcc/build/ship

which is what I wanted to make sure of. But ascertaining that still
more manual work than I'd like.

Analyzing an 1753-line diff is better than studying a 5400-line log.
Coloring the only two lines I care about distinctively is helpful:
I can stare at the screen while pressing
  PgDn PgDn PgDn PgDn PgDn PgDn PgDn PgDn ...
and mentally filter out everything that's white, pink, cyan, or teal.
But what I'd really like is to bind a key to "find next red or green".

With less's '-r' flag, the lines I seek are:

ESC[31m-rm --force --recursive /opt/lmi/src/lmi/../build/lmi//gcc/shipESC[m
ESC[32m+ESC[mESC[32mrm --force --recursive /opt/lmi/gcc/build/shipESC[m

and indeed after '-r' I can search for '/[[]3[12]m'. But of course
'-r' makes everything the same color and shows escape sequences
literally, when ideally I'd like to see the colorized output but
search by (invisible) escape sequence. Does that seem possible?

I might ask for 'less' to fold lines by color, but I'm trying to be
reasonable.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]