[PATCH 6/6] Make cg-log use optparse, and add features
From: Dan Holmsand <hidden>
Date: 2016-06-15 22:41:59
This is more or less a rewrite of cg-log, that adds a bunch
of new features and gives a substantial speedup.
cg-log now lets git-rev-list and git-diff-tree do as much
of the heavy lifting as possible. When possible, cg-log
pretty much reduces to a sed script, that does some fixup
and adds colorization. Otherwise, cg-log uses
--pretty=[raw|medium|short] output, that's augmented as
necessary.
New features:
- New, human friendlier output format. cg-log now uses
the same format as git-rev-list --pretty. It also
doesn't show tree, committer and parents by default.
These are all shown with "-v or --verbose", however.
- Slightly more readable summary format. sha1s are hidden
unless -v is given. Date format is condenced to HH:MM
for the last day, and Month Day otherwise. (+year is
shown for really old stuff).
summary format can also be combined with other options,
like "-f" and "-d" (diffstat).
- "-u" (or --search=) now searches the entire commit
message. This is more flexible, as you can still do e.g.
"cg-log -u 'author Petr Baudis'". Search is now also
a lot faster, done with a single grep invocation.
- Output can be limited by date or count.
- New format for "-f". This is pretty much the same
output as cg-status gives, and allows for the
rename/copy detection things to work. New and
deleted files are optionally color coded.
The old format is still available as -F.
- Merge commits are hidden by default when displaying
differences between commits, or when displaying disjoint
sets of commits. "-a" makes them show again. So
"cg-log -caF" gives you pretty much the same output
as the old "cg-log -c -f" would.
- Shows diffs between commits with the "-p" options.
The diffs use the same colorization rules as cg-diff,
and can be skipped through with "n" in less if "-c"
is given.
- "--stdin" reads sha1s from stdin instead of from
git-rev-list, for some extra flexibility.
New features in common with cg-diff:
- diffstat support (or rather git-apply --stat). The
"-d" option outputs (optionally colorized) diff stats
before the diff.
- support for more git-diff-[tree/cache] options:
-B, -R, -M, -C are now all passed on.
- The COGITO_AUTO_COLOR environment variable makes output
automatically colorized, if set and if we're on a color
capable terminal.
We also use the new optparse function from cg-Xlib, to allow
for e.g. "cg-log -sfa" and stuff.
Reuse colorization logic from cg-Xlib. All the colors are
added in a single sed invocation.
And use LESS to make "less" search for chunks and diff --git
markers. This allows you to "n" your way through a series
of diffs, and gives a nice visual separation of patches.
Signed-off-by: Dan Holmsand <redacted>
--- Attachments
- 6-cg-log.patch.txt [text/plain] 16296 bytes · preview