# bug in 'git describe'?

5 messages from 2018-09-24 to 2018-09-25. Participants: Sebastian Kuzminsky, Junio C Hamano, Duy Nguyen.
Thread: https://gitlist.dev/t/49416

## Sebastian Kuzminsky, 2018-09-24 21:45

Subject: bug in 'git describe'?
Message-ID: <fd340f7b-61c0-2661-bdca-c239e51bc464@highlab.com>
URL: https://gitlist.dev/e/fd340f7b-61c0-2661-bdca-c239e51bc464%40highlab.com

```
I think I've run in to a bug in 'git describe' (reproduced with git 
2.11.0, 2.16.1, and 2.19.0.221.g150f307af).

I've got two tiny git repos whose commit graphs are identical, but where 
'git describe' gives different results.

>     *   merge 1.1 into 2.0  (HEAD -> release-2.0)
>     |\
>     | *   merge boo into 1.1  (tag: release/1.1.1, release-1.1)
>     | |\
>     | | * dummy commit  (boo)
>     | * | dummy commit  (tag: release/1.1.0)
>     * | |   merge feature into 2.0
>     |\ \ \
>     | * | | dummy commit  (feature)
>     |/ / /
>     * | | dummy commit  (tag: release/2.0.1)
>     * | | dummy commit  (tag: release/2.0.0)
>     |/ /
>     * | dummy commit  (release-1.0)
>     |/
>     * dummy commit  (tag: release/1.0.0)

The tag 'release/1.0.0' is the first commit in history.

The histories differ only in the timestamps of the commits (and thus the 
SHAs of the commit objects).

Good repo: release/2.0.1-6-gbc33a04
Bad repo: release/2.0.1-8-g2c0a20c

Details, including full copies of both repos, here:

http://highlab.com/~seb/git-describe-bug/


-- 
Sebastian Kuzminsky

```

## Junio C Hamano, 2018-09-24 22:24

Subject: Re: bug in 'git describe'?
Message-ID: <xmqqefdir0tz.fsf@gitster-ct.c.googlers.com>
URL: https://gitlist.dev/e/xmqqefdir0tz.fsf%40gitster-ct.c.googlers.com
In-Reply-To: <fd340f7b-61c0-2661-bdca-c239e51bc464@highlab.com>

```
Sebastian Kuzminsky <seb@highlab.com> writes:

> I've got two tiny git repos whose commit graphs are identical, but
> where 'git describe' gives different results.
> ...
> The histories differ only in the timestamps of the commits...

describe does take the commit timestamps into account, so it is
expected you would get different results out of an otherwise
identically looking graph.

```

## Sebastian Kuzminsky, 2018-09-25 15:39

Subject: Re: bug in 'git describe'?
Message-ID: <dbd2dcef-c892-3628-119e-f688e74f3599@highlab.com>
URL: https://gitlist.dev/e/dbd2dcef-c892-3628-119e-f688e74f3599%40highlab.com
In-Reply-To: <xmqqefdir0tz.fsf@gitster-ct.c.googlers.com>

```
On 9/24/18 4:24 PM, Junio C Hamano wrote:
> Sebastian Kuzminsky <seb@highlab.com> writes:
> 
>> I've got two tiny git repos whose commit graphs are identical, but 
>> where 'git describe' gives different results. ... The histories
>> differ only in the timestamps of the commits...
> 
> describe does take the commit timestamps into account, so it is 
> expected you would get different results out of an otherwise 
> identically looking graph.

Thanks for that confirmation.

That behavior seems to me to be different from what the (2.11) manpage says:

> it suffixes the tag name with the number of additional commits on top
> of the tagged object


And:

> If multiple tags were found during the walk then the tag which has
> the fewest commits different from the input commit-ish will be
> selected and output. Here fewest commits different is defined as the
> number of commits which would be shown by git log tag..input will be
> the smallest number of commits possible.

All that said, if you consider this "working as expected" then i'm 
content to let the matter drop.


-- 
Sebastian Kuzminsky

```

## Duy Nguyen, 2018-09-25 16:05

Subject: Re: bug in 'git describe'?
Message-ID: <CACsJy8C4+cj=K2NetC05rmwenY0cArQ7NehZZ+Df90fmzBVThA@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8C4%2Bcj%3DK2NetC05rmwenY0cArQ7NehZZ%2BDf90fmzBVThA%40mail.gmail.com
In-Reply-To: <dbd2dcef-c892-3628-119e-f688e74f3599@highlab.com>

```
On Tue, Sep 25, 2018 at 5:41 PM Sebastian Kuzminsky <seb@highlab.com> wrote:
> That behavior seems to me to be different from what the (2.11) manpage says:

Good opportunity to improve the man page anyway even if Junio is
right. I agree that the section about "search strategy" is a bit
misleading because it does not mention anything about time stuff.

>
> > it suffixes the tag name with the number of additional commits on top
> > of the tagged object
>
>
> And:
>
> > If multiple tags were found during the walk then the tag which has
> > the fewest commits different from the input commit-ish will be
> > selected and output. Here fewest commits different is defined as the
> > number of commits which would be shown by git log tag..input will be
> > the smallest number of commits possible.
-- 
Duy

```

## Duy Nguyen, 2018-09-25 16:10

Subject: Re: bug in 'git describe'?
Message-ID: <CACsJy8C+WWkwFjoFT+Y-Ga2ZxSbOn-OkKCyKYFU4qJfXyuJY-w@mail.gmail.com>
URL: https://gitlist.dev/e/CACsJy8C%2BWWkwFjoFT%2BY-Ga2ZxSbOn-OkKCyKYFU4qJfXyuJY-w%40mail.gmail.com
In-Reply-To: <CACsJy8C4+cj=K2NetC05rmwenY0cArQ7NehZZ+Df90fmzBVThA@mail.gmail.com>

```
On Tue, Sep 25, 2018 at 6:05 PM Duy Nguyen <pclouds@gmail.com> wrote:
>
> On Tue, Sep 25, 2018 at 5:41 PM Sebastian Kuzminsky <seb@highlab.com> wrote:
> > That behavior seems to me to be different from what the (2.11) manpage says:
>
> Good opportunity to improve the man page anyway even if Junio is
> right. I agree that the section about "search strategy" is a bit
> misleading because it does not mention anything about time stuff.

If anybody's updating the man page, I think this is the commit that
changed git-describe's search strategy: 80dbae03b0 (Chose better tag
names in git-describe after merges. - 2007-01-10)

--
Duy

```
