Re: [PATCH v0 0/2] git-less: a specialized pager for git-log
- From
- Alex Plotnick <shrike@netaxs.com>
- Date
- Mar 23, 2012, 20:44 UTC
- Message-ID
- <87obrn6o9x.fsf@sol.localdomain>
- In-Reply-To
- <4F6C4B59.8060102@op5.se>
I have on occasion also wished to view log messages (especially with patches) one at a time. And although I agree that a dedicated pager is overkill, perhaps a small script wouldn't be.
The attached script will eventually run afoul of argument length limits, but seems to work well otherwise. If you're using less(1), you can step through the files using :n, :p, and :x.
Cheers,
-- Alex
#!/bin/sh
# Use csplit(1) to split a git log into one commit per file, then run the # pager on the split files.
. $(git --exec-path)/git-sh-setup
SPLIT_DIR="$GIT_DIR/split-$$" CSPLIT="csplit -s -k" if csplit --help 2>/dev/null | sane_grep -- "-z" >/dev/null; then CSPLIT="$CSPLIT -z" fi
_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" _infty=1000000
mkdir "$SPLIT_DIR" && cd "$SPLIT_DIR" || exit 1 trap 'rm -rf "$SPLIT_DIR"' 0 1 2 3 15 git log "$@" | $CSPLIT - "/^commit $_x40/" "{$_infty}" 2>/dev/null git_pager "$SPLIT_DIR"/xx*