git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
APAlex 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*

Previous: Hitoshi MitakeNext: Jeff Epler
Message 7 of 10 in “git-less: a specialized pager for git-log”
  1. 0/2 git-less: a specialized pager for git-logHitoshi Mitake, Mar 22, 2012
  2. 1/2 git-less: a specialized pager for git-logHitoshi Mitake, Mar 22, 2012
  3. 2/2 git-less: git side support for git-lessHitoshi Mitake, Mar 22, 2012
  4. Junio C HamanoMar 22, 2012
  5. Andreas EricssonMar 23, 2012
  6. Hitoshi MitakeMar 23, 2012
  7. Alex PlotnickMar 23, 2012
  8. Jeff EplerMar 30, 2012
  9. Hitoshi MitakeMar 23, 2012
  10. Nguyen Thai Ngoc DuyMar 24, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.