Git development
 help / color / mirror / Atom feed
From: Konstantin Khomoutov <kostix@bswap.ru>
To: Jeff King <peff@peff.net>
Cc: Konstantin Khomoutov <kostix@bswap.ru>,
	wuzhouhui <wuzhouhui14@mails.ucas.ac.cn>,
	git@vger.kernel.org
Subject: Re: How to display "HEAD~*" in "git log"
Date: Wed, 6 Jul 2022 19:28:56 +0300	[thread overview]
Message-ID: <20220706162856.mkgfdr2lnjdbxgn4@carbon> (raw)
In-Reply-To: <YsWebbaOJbaOZ6i7@coredump.intra.peff.net>

On Wed, Jul 06, 2022 at 10:38:37AM -0400, Jeff King wrote:

[...]

> > 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.

[...]


  reply	other threads:[~2022-07-06 16:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-05  7:11 How to display "HEAD~*" in "git log" wuzhouhui
2022-07-05  9:25 ` Konstantin Khomoutov
2022-07-05  9:30   ` Konstantin Khomoutov
2022-07-05  9:36     ` wuzhouhui
2022-07-06 12:38       ` kostix
2022-07-06 14:38   ` Jeff King
2022-07-06 16:28     ` Konstantin Khomoutov [this message]
2022-07-06 16:49       ` Jeff King
2022-07-06 18:21         ` Konstantin Khomoutov
2022-07-07 17:06           ` Jeff King
2022-07-06 17:31     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220706162856.mkgfdr2lnjdbxgn4@carbon \
    --to=kostix@bswap.ru \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    --cc=wuzhouhui14@mails.ucas.ac.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox