git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Konstantin Khomoutov <kostix@bswap.ru>
To: Konstantin Kharlamov <hi-angel@yandex.ru>
Cc: git@vger.kernel.org
Subject: Re: Any way to make git-log to enumerate commits?
Date: Wed, 5 Dec 2018 17:54:20 +0300	[thread overview]
Message-ID: <20181205145419.vbbaghzzrnceez45@tigra> (raw)
In-Reply-To: <5e5c6d1c-6b3e-c94a-17be-a2af518c1607@yandex.ru>

On Wed, Dec 05, 2018 at 05:22:14PM +0300, Konstantin Kharlamov wrote:

> It would be great if git-log has a formatting option to insert an
> index of the current commit since HEAD.
> 
> It would allow after quitting the git-log to immediately fire up "git
> rebase -i HEAD~index" instead of "git rebase -i
> go-copy-paste-this-long-number-id".

This may have little sense in a general case as the history maintained
by Git is a graph, not a single line. Hence your prospective approach
would only work for cases like `git log` called with the
"--first-parent" command-line option.

Still, for a simple approach you may code it right away yourself.
Say, let's create an alias:

  $ git config alias.foo '!git log "$@" --pretty=oneline --source | {
      n=0;
      while read sha ref rest; do
        printf "%s\t%s~%s\t%s\n" "$sha" "$ref" $n "$rest"
		n=$((n+1))
	  done
    }'

Now calling `git foo --abbrev=commit` would output something like

9be8e297d        HEAD~7       Frobincated fizzle

where "7" is what you're looking for.

A more roubst solution may need to use the `git rev-list` command.


  reply	other threads:[~2018-12-05 14:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-05 14:22 Any way to make git-log to enumerate commits? Konstantin Kharlamov
2018-12-05 14:54 ` Konstantin Khomoutov [this message]
2018-12-05 15:31   ` Elijah Newren
2018-12-05 15:43     ` Andreas Schwab
2018-12-06  0:31   ` Junio C Hamano
2018-12-06 11:48     ` Konstantin Khomoutov
2018-12-07  0:12       ` 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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=20181205145419.vbbaghzzrnceez45@tigra \
    --to=kostix@bswap.ru \
    --cc=git@vger.kernel.org \
    --cc=hi-angel@yandex.ru \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).