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

Re: Any way to make git-log to enumerate commits?

From
KKKonstantin Khomoutov <kostix@bswap.ru>
Date
Dec 6, 2018, 11:48 UTC
Message-ID
<20181206114835.oro32chgf4qp2yqd@tigra>
In-Reply-To
<xmqqa7ljbimv.fsf@gitster-ct.c.googlers.com>
On Thu, Dec 06, 2018 at 09:31:36AM +0900, Junio C Hamano wrote:
Show 18 quoted lines
> >> 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.
> 
> I do not see why the "name each rev relative to HEAD" formatting
> option cannot produce HEAD^2~2 etc.
> 
> It would be similar to "git log | git name-rev --stdin" but I do not
> offhand recall if we had a way to tell name-rev to use only HEAD as
> the anchoring point.

My reading was that the OP explicitly wanted to just glance at a single integer number and use it right away in a subsequent rebase command.

I mean, use one's own short memory instead of copying and pasting.

The way I decided to format the reference in my sketch script — using HEAD~<n> — is just a byproduct of the fact I was aware both of the "gitrevisions" manual page and the fact `git name-rev` exists (though I regretfully was not aware it's able to process a stream of `git log`).

Hence while getting fancy names for revisions would be technically correct but less error-prone for retyping from memory ;-)

Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 7 in “Any way to make git-log to enumerate commits?”
  1. Konstantin KharlamovDec 5, 2018
  2. Konstantin KhomoutovDec 5, 2018
  3. Elijah NewrenDec 5, 2018
  4. Andreas SchwabDec 5, 2018
  5. Junio C HamanoDec 6, 2018
  6. Konstantin KhomoutovDec 6, 2018
  7. Junio C HamanoDec 7, 2018

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.