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

Re: 0-Based indexes for git log

From
Patrick Steinhardt <ps@pks.im>
Date
Sep 25, 2025, 05:46 UTC
Message-ID
<aNTXRRolcqn5sT6d@pks.im>
In-Reply-To
<95F22D6A-38D9-4F4D-B71E-59320B86B4E8@gmail.com>
On Wed, Sep 24, 2025 at 01:28:31PM -0400, Ben Knoble wrote:
Show 6 quoted lines
> > * merge parent numbers are 2-based (sanity of this statement is
> >   already questionable).  If HEAD is a merge, HEAD~2 is the
> >   "(first) side branch that was merged", HEAD~3 is the "(second)
> >   side brnach that was merged (in an octopus merge), and so on.
> 
> HEAD^2, 3, etc., rather? :)

Probably. I also always regarded this as the nth parent, not the nth merge parent. HEAD^1 returns the first parent even for non-merges, HEAD^2 the second and so on. So I'd claim these are also 1-based.

Patrick
Previous: Ben KnobleNext: Junio C Hamano
Message 11 of 17 in “0-Based indexes for git log”
  1. 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣Sep 23, 2025
  2. Ben KnobleSep 24, 2025
  3. 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣Sep 24, 2025
  4. Ben KnobleSep 24, 2025
  5. Jeff KingSep 24, 2025
  6. 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣Sep 24, 2025
  7. Nico WilliamsSep 24, 2025
  8. Junio C HamanoSep 24, 2025
  9. 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣Sep 24, 2025
  10. Ben KnobleSep 24, 2025
  11. Patrick SteinhardtSep 25, 2025
  12. Junio C HamanoSep 25, 2025
  13. 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣Sep 24, 2025
  14. Nico WilliamsSep 24, 2025
  15. 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣Sep 24, 2025
  16. Emily ShafferSep 24, 2025
  17. 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣Sep 24, 2025

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.