# 0-Based indexes for git log

17 messages from 2025-09-23 to 2025-09-25. Participants: 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣, Ben Knoble, Jeff King, Nico Williams, Junio C Hamano, Emily Shaffer, Patrick Steinhardt.
Thread: https://gitlist.dev/t/64195

## 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣, 2025-09-23 21:15

Subject: 0-Based indexes for git log
Message-ID: <fd7758e5-7719-4bed-b1b3-2137c49cc950@velocifyer.com>
URL: https://gitlist.dev/e/fd7758e5-7719-4bed-b1b3-2137c49cc950%40velocifyer.com

```
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)

-- 
George truly, 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
This email does not constitute a legally binding contract

```

## Ben Knoble, 2025-09-24 02:12

Subject: Re: 0-Based indexes for git log
Message-ID: <2FAD09B7-4776-483E-90F1-31B031DAC2CA@gmail.com>
URL: https://gitlist.dev/e/2FAD09B7-4776-483E-90F1-31B031DAC2CA%40gmail.com
In-Reply-To: <fd7758e5-7719-4bed-b1b3-2137c49cc950@velocifyer.com>

```

> Le 23 sept. 2025 à 17:16, 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣 <velocifyer@velocifyer.com> a écrit :
> 
> ﻿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)

Are these date formats locale-specific? In both the US English and France French locales I use commonly, the 19th of September in 2025 _is_ a Friday. Showing 18 would only be confusing.
```

## Jeff King, 2025-09-24 05:22

Subject: Re: 0-Based indexes for git log
Message-ID: <20250924052216.GB1173044@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20250924052216.GB1173044%40coredump.intra.peff.net
In-Reply-To: <fd7758e5-7719-4bed-b1b3-2137c49cc950@velocifyer.com>

```
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"

Are you proposing that the first day of September is the 0th? You might
be able to do that with locale support and using strftime's %c option,
but I'm not sure how powerful locales are (or how one even defines
them).

> (or "Friday 2025-8-18 14:23:24 (-4:00.00)"  to get a
> better format)

If you just care about the format, check out the --date option in
git-log's manpage. Especially the "format:" specifier, which relies on
strftime, like:

  git log --date=format:'%A %Y-%m-%d %H:%M:%S (%z)'

-Peff

```

## 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣, 2025-09-24 13:42

Subject: Re: 0-Based indexes for git log
Message-ID: <55e313f2-8ec3-4f6c-afe9-19d938e3a605@velocifyer.com>
URL: https://gitlist.dev/e/55e313f2-8ec3-4f6c-afe9-19d938e3a605%40velocifyer.com
In-Reply-To: <20250924052216.GB1173044@coredump.intra.peff.net>

```
[sent again because i didn`t reply all
> Are you proposing that the first day of September is the 0th? You might
> be able to do that with locale support and using strftime's %c option,
> but I'm not sure how powerful locales are (or how one even defines
> them).

No, i am sugesting that it is still the 1st but it is september 0

-- 
George truly, 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
This email does not constitute a legally binding contract
Remember to reply all on mailing lists (this is here so i don't forget 
to use reply all)(If you are reading this i forgot to remove it)

```

## 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣, 2025-09-24 13:46

Subject: Re: 0-Based indexes for git log
Message-ID: <27456c8a-25f4-40f2-a791-efd35457d121@velocifyer.com>
URL: https://gitlist.dev/e/27456c8a-25f4-40f2-a791-efd35457d121%40velocifyer.com
In-Reply-To: <2FAD09B7-4776-483E-90F1-31B031DAC2CA@gmail.com>

```
> Are these date formats locale-specific? In both the US English and France French locales I use commonly, the 19th of September in 2025 _is_ a Friday. Showing 18 would only be confusing.

Showing 19 confuses me because i'm used to 0-based indexes where the 
19th is labeld as 18. Showing 18 would not cunfuse most people.

-- 
George truly, 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
This email does not constitute a legally binding contract
Remember to reply all on mailing lists (this is here so i don't forget 
to use reply all)(If you are reading this i forgot to remove it)

```

## Ben Knoble, 2025-09-24 15:26

Subject: Re: 0-Based indexes for git log
Message-ID: <B4B7BB74-9B69-4CDB-B4F2-FFB976A5B0CA@gmail.com>
URL: https://gitlist.dev/e/B4B7BB74-9B69-4CDB-B4F2-FFB976A5B0CA%40gmail.com
In-Reply-To: <27456c8a-25f4-40f2-a791-efd35457d121@velocifyer.com>

```

> Le 24 sept. 2025 à 09:46, 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣 <velocifyer@velocifyer.com> a écrit :
> 
> ﻿
>> 
>> Are these date formats locale-specific? In both the US English and France French locales I use commonly, the 19th of September in 2025 _is_ a Friday. Showing 18 would only be confusing.
> 
> Showing 19 confuses me because i'm used to 0-based indexes where the 19th is labeld as 18. Showing 18 would not cunfuse most people.

I would need evidence of that. Everyone I interact with agrees to write « 19 » when « 19th » is implied.

As I asked: is this particular to an community? I’m genuinely curious if there are groups or cultures that communicate this way. 

As Peff points out, you can probably make commands display your own personal preference (or a locale should handle this for your community). But I don’t think this is something we can force on other people, because it would be confusing. 
```

## Nico Williams, 2025-09-24 15:43

Subject: Re: 0-Based indexes for git log
Message-ID: <aNQRoMgSRVvNtStG@ubby>
URL: https://gitlist.dev/e/aNQRoMgSRVvNtStG%40ubby
In-Reply-To: <fd7758e5-7719-4bed-b1b3-2137c49cc950@velocifyer.com>

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

```

## Junio C Hamano, 2025-09-24 16:53

Subject: Re: 0-Based indexes for git log
Message-ID: <xmqqh5wrn66m.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqh5wrn66m.fsf%40gitster.g
In-Reply-To: <aNQRoMgSRVvNtStG@ubby>

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





```

## 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣, 2025-09-24 17:01

Subject: Re: 0-Based indexes for git log
Message-ID: <75860b99-b7b5-4398-b32f-47a4873508aa@velocifyer.com>
URL: https://gitlist.dev/e/75860b99-b7b5-4398-b32f-47a4873508aa%40velocifyer.com
In-Reply-To: <aNQRoMgSRVvNtStG@ubby>

```
> Day of month numbers are 1-based.

I consider day of month to use a 0-based index

-- 
George truly, 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
This email does not constitute a legally binding contract

```

## 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣, 2025-09-24 17:11

Subject: Re: 0-Based indexes for git log
Message-ID: <771fc44e-32d4-4758-b497-bcef86433446@velocifyer.com>
URL: https://gitlist.dev/e/771fc44e-32d4-4758-b497-bcef86433446%40velocifyer.com
In-Reply-To: <xmqqh5wrn66m.fsf@gitster.g>

```
>> Day of month numbers are 1-based.
> Correct.
No, day of month numbers are 0-based.
> 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.
HEAD~1 just means HEAD - 1 commit.(AKA "reverse 0-based index")
>   * 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.
No, that is just a reverse 0-based index.
>   * stash entries are counted 0-based.  "git stash list" shows from
>     stash@{0} that is the most recently created stash entry.

That is correct. It's a reverse 0-based index becuase it uses reflog syntax.

-- 
George truly, 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
This email does not constitute a legally binding contract

```

## 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣, 2025-09-24 17:15

Subject: Re: 0-Based indexes for git log
Message-ID: <f1599790-b48c-4c37-8cf7-4756f5064d2e@velocifyer.com>
URL: https://gitlist.dev/e/f1599790-b48c-4c37-8cf7-4756f5064d2e%40velocifyer.com
In-Reply-To: <fd7758e5-7719-4bed-b1b3-2137c49cc950@velocifyer.com>

```
> 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)
>
I suggest git adds a config option for 0-based date and automaticly uses 
0-based date if there is a file at $HOME/use-0-based-index-for-date or 
$USE-0-BASED-INDEX-FOR-DATE == true

-- 
George truly, 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
This email does not constitute a legally binding contract

```

## 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣, 2025-09-24 17:18

Subject: Re: 0-Based indexes for git log
Message-ID: <0fdd4ba0-f2e2-487b-9da0-686645c426e2@velocifyer.com>
URL: https://gitlist.dev/e/0fdd4ba0-f2e2-487b-9da0-686645c426e2%40velocifyer.com
In-Reply-To: <fd7758e5-7719-4bed-b1b3-2137c49cc950@velocifyer.com>

```
[resending because i made a typo]

> 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)
>
I suggest git adds a config option for 0-based date and automatically 
uses 0-based date if there is a file at 
$HOME/.config/use-0-based-index-for-date or $USE-0-BASED-INDEX-FOR-DATE 
== true

-- 
George truly, 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
This email does not constitute a legally binding contract

```

## Emily Shaffer, 2025-09-24 17:22

Subject: Re: 0-Based indexes for git log
Message-ID: <CAJoAoZkhqF83gsT963X81zZZi0wvYV9umEoXaArVpan6nDCoDg@mail.gmail.com>
URL: https://gitlist.dev/e/CAJoAoZkhqF83gsT963X81zZZi0wvYV9umEoXaArVpan6nDCoDg%40mail.gmail.com
In-Reply-To: <f1599790-b48c-4c37-8cf7-4756f5064d2e@velocifyer.com>

```
On Wed, Sep 24, 2025 at 10:15 AM 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
<velocifyer@velocifyer.com> 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)
> >
> I suggest git adds a config option for 0-based date and automaticly uses
> 0-based date if there is a file at $HOME/use-0-based-index-for-date or
> $USE-0-BASED-INDEX-FOR-DATE == true

Git uses strftime from libc for date formatting. strftime[1] doesn't
offer a way to format the date as you prefer - what you're asking for
appears to be a personal preference, not a standard in any community
of the world. I think that your best bet would be to attempt to
contribute an option to strftime to render the day of the month from
0-30, but I would be surprised if such a contribution were to be
welcomed - as, again, this looks like a preference held by very few.
Based on my quick refresher through date.[ch] in the Git codebase, it
would be infeasible to add such a flag and custom formatting.

However, Git is open source software, and you're fully welcome to
patch your copy of Git to accept such a config (or this ~/some-file,
which is not a way Git typically sets configuration) and build it
yourself locally.

1: https://www.man7.org/linux/man-pages/man3/strftime.3.html
>
> --
> George truly, 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣
> This email does not constitute a legally binding contract

```

## Ben Knoble, 2025-09-24 17:28

Subject: Re: 0-Based indexes for git log
Message-ID: <95F22D6A-38D9-4F4D-B71E-59320B86B4E8@gmail.com>
URL: https://gitlist.dev/e/95F22D6A-38D9-4F4D-B71E-59320B86B4E8%40gmail.com
In-Reply-To: <xmqqh5wrn66m.fsf@gitster.g>

```

> Le 24 sept. 2025 à 12:53, Junio C Hamano <gitster@pobox.com> a écrit :
> 
> ﻿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.

HEAD^2, 3, etc., rather? :)
```

## Nico Williams, 2025-09-24 17:04

Subject: Re: 0-Based indexes for git log
Message-ID: <aNQkrF1k4ZCj4h9Q@ubby>
URL: https://gitlist.dev/e/aNQkrF1k4ZCj4h9Q%40ubby
In-Reply-To: <75860b99-b7b5-4398-b32f-47a4873508aa@velocifyer.com>

```
On Wed, Sep 24, 2025 at 01:01:30PM -0400, 𝕍𝕖𝕝𝕠𝕔𝕚𝕗𝕪𝕖𝕣 wrote:
> > Day of month numbers are 1-based.
> 
> I consider day of month to use a 0-based index

The rest of the world does not.  You want to be able to interoperate
with the rest of the world.  So day of month numbers are 1-based.  I
also wish everything were 0-based, but it's not.  That's just life.

```

## Patrick Steinhardt, 2025-09-25 05:46

Subject: Re: 0-Based indexes for git log
Message-ID: <aNTXRRolcqn5sT6d@pks.im>
URL: https://gitlist.dev/e/aNTXRRolcqn5sT6d%40pks.im
In-Reply-To: <95F22D6A-38D9-4F4D-B71E-59320B86B4E8@gmail.com>

```
On Wed, Sep 24, 2025 at 01:28:31PM -0400, Ben Knoble wrote:
> > * 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

```

## Junio C Hamano, 2025-09-25 13:25

Subject: Re: 0-Based indexes for git log
Message-ID: <xmqqcy7eis02.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqcy7eis02.fsf%40gitster.g
In-Reply-To: <95F22D6A-38D9-4F4D-B71E-59320B86B4E8@gmail.com>

```
Ben Knoble <ben.knoble@gmail.com> writes:

>> * 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? :)

Thanks for correcting me.  Yes.  And HEAD^1 is the first parent that
is the same as HEAD~1.

```
