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

Re: How to display "HEAD~*" in "git log"

From
KKKonstantin Khomoutov <kostix@bswap.ru>
Date
Jul 6, 2022, 16:28 UTC
Message-ID
<20220706162856.mkgfdr2lnjdbxgn4@carbon>
In-Reply-To
<YsWebbaOJbaOZ6i7@coredump.intra.peff.net>
On Wed, Jul 06, 2022 at 10:38:37AM -0400, Jeff King wrote:
[...]
Show 7 quoted lines
> > You can script this. Provided you have a POSIX-compatible shell (such as
> > Bash), the encantation would read something like
> > 
> >  $ git log --oneline | { n=0; while read line; do printf '%d\t%s\n' $n "$line"; done; }
> 
> That will just number the commits linearly as they are printed. If your
> history has any branches or merges, eventually it will get out of sync.
Thanks, I did not think of this.
> You can use "name-rev" to annotate commits with names that respect the
> history. It only matches full oids, so try:
> 
>   git log --oneline --no-abbrev | git name-rev --stdin

I pondered about `git name-rev` but failed to figure out how to make it accept just "HEAD" as the point of reference. Passing it "--refs=HEAD" (or "--refs HEAD", FWIW) does not appear to do what I'd expect it to: a couple of top commits are not annotated at all, and then they start to get annotated relative to "origin/HEAD". Note that I've tested this on a detached HEAD which contains an unmerged line of history.

[...]
Previous: Jeff KingNext: Jeff King
Message 7 of 11 in “How to display "HEAD~*" in "git log"”
  1. wuzhouhuiJul 5, 2022
  2. Konstantin KhomoutovJul 5, 2022
  3. Konstantin KhomoutovJul 5, 2022
  4. wuzhouhuiJul 5, 2022
  5. kostix@bswap.ruJul 6, 2022
  6. Jeff KingJul 6, 2022
  7. Konstantin KhomoutovJul 6, 2022
  8. Jeff KingJul 6, 2022
  9. Konstantin KhomoutovJul 6, 2022
  10. Jeff KingJul 7, 2022
  11. Junio C HamanoJul 6, 2022

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.