Re: [PATCH v0 0/2] git-less: a specialized pager for git-log

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

 



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*

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]