git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Nico Williams <nico@cryptonector.com>
Cc: 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣 <velocifyer@velocifyer.com>, git@vger.kernel.org
Subject: Re: 0-Based indexes for git log
Date: Wed, 24 Sep 2025 09:53:05 -0700	[thread overview]
Message-ID: <xmqqh5wrn66m.fsf@gitster.g> (raw)
In-Reply-To: <aNQRoMgSRVvNtStG@ubby> (Nico Williams's message of "Wed, 24 Sep 2025 10:43:28 -0500")

Nico Williams <nico@cryptonector.com> writes:

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





  reply	other threads:[~2025-09-24 16:53 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-23 21:15 0-Based indexes for git log 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
2025-09-24  2:12 ` Ben Knoble
2025-09-24 13:46   ` 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
2025-09-24 15:26     ` Ben Knoble
2025-09-24  5:22 ` Jeff King
2025-09-24 13:42   ` 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
2025-09-24 15:43 ` Nico Williams
2025-09-24 16:53   ` Junio C Hamano [this message]
2025-09-24 17:11     ` 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
2025-09-24 17:28     ` Ben Knoble
2025-09-25  5:46       ` Patrick Steinhardt
2025-09-25 13:25       ` Junio C Hamano
2025-09-24 17:01   ` 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
2025-09-24 17:04     ` Nico Williams
2025-09-24 17:15 ` 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
2025-09-24 17:22   ` Emily Shaffer
2025-09-24 17:18 ` 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣

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=xmqqh5wrn66m.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=nico@cryptonector.com \
    --cc=velocifyer@velocifyer.com \
    /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;
as well as URLs for NNTP newsgroup(s).