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

Re: 0-Based indexes for git log

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 24, 2025, 16:53 UTC
Message-ID
<xmqqh5wrn66m.fsf@gitster.g>
In-Reply-To
<aNQRoMgSRVvNtStG@ubby>
Nico Williams <nico@cryptonector.com> writes:
Show 7 quoted lines
> On Tue, Sep 23, 2025 at 05:15:46PM -0400, 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣 wrote:
>> In git log it uses a 1-based index for the date instead of a 0 based index.
>> So it says "Fri Sep 19 14:23:24 2025 -0400" when it should say "Fri Sep 18
>> 14:23:24 2025 -0400" (or "Friday 2025-8-18 14:23:24 (-4:00.00)"  to get a
>> better format)
>
> Day of month numbers are 1-based.
Correct.
There are a few things in Git that are 0 based, but not so many.
 * parent numbers are 1-based.  HEAD~1 is the "previous commit", aka
   "first parent".  HEAD~0 is the HEAD itself.
 * 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.
 * reflog entries are 1-based.  @{1} is the "previous object pointed
   by the current branch", @{2} is one before that.  @{0} is the
   current branch itself.
 * stash entries are counted 0-based.  "git stash list" shows from
   stash@{0} that is the most recently created stash entry.
Previous: Nico WilliamsNext: 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
Message 8 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.