Hi all!

We're observing a strange behavior of git describe. We have a local fork of an 
open-source github.com/openbmc/openbmc repository. The local fork has some 
extra commits and we merge from upstream on a regular basis. Until today it all 
worked fine, the last merge was from upstream commit b1b8f77 and `git describe` 
was showing the correct info based on `v2.3` tag added with commit ad35219:

```
$ git log --oneline --decorate=short --graph
*   f0f01334f (HEAD) Merge remote-tracking branch 'upstream/master'
|\ 
| * b1b8f7705 phosphor-logging: srcrev bump f8d38bbebe..30047bf964
| * 0a848f84d entity-manager: srcrev bump 8ca708689f..d534f7433d
| * 7e16090cd google-ipmi-sys: srcrev bump 3ebf2dd524..ff40f273a7
| * 9b7dcc807 google-ipmi-i2c: srcrev bump 38e8c6e170..ad05703ce0
...
| * ad35219cd (tag: v2.3) Update bmcweb to latest
...
$
$ git describe --debug
searching to describe HEAD
finished search at eb8644742b22a77f40e6cfe9f3d325e92a602def
 annotated       1601 v2.3
 annotated       1965 v2.2
 annotated       2416 v2.1
 annotated       2637 v2.0
 annotated       2899 v1.99.10
traversed 2974 commits
v2.3-1601-gf0f0133
$
```

Since that point there have been some commits both to the upstream and to our 
local fork. Now as we've merged again from upstream, we're seeing something 
strange. The latest (timestamp-wise) commit before the merge was to the 
upstream and it was tagged `v2.4` (annotated):

```
$ git log --oneline --decorate=short --graph upstream/master
* c71bcdc01 (tag: v2.4, upstream/master, upstream/HEAD, upstream) 
phosphor-webui: srcrev bump 1cc7021c9e..bc5cc7f75c
* 3db7820e6 skiboot: Bump to 6.0.13
* 5a963b231 linux-aspeed: Move to 4.18.16
* 36a49e2d7 Add Entity Manager to Facebook Tiogapass
```

Our local fork after merging looks like this:

```
$ git merge upstream/master
Merge made by the 'recursive' strategy.
 meta-aspeed/recipes-kernel/linux/linux-aspeed_git.bb                           
 |  4 ++--
 meta-facebook/meta-tiogapass/conf/machine/tiogapass.conf                       
 |  1 +
 
meta-facebook/meta-tiogapass/recipes-fbtp/packagegroups/packagegroup-fb-apps.bb 
| 18 ++++++++++++++++++
 meta-google/recipes-google/ipmi/google-ipmi-sys_git.bb                         
 |  2 +-
 meta-openpower/recipes-bsp/skiboot/skiboot.inc                                 
 |  6 +++---
 meta-phosphor/recipes-phosphor/state/phosphor-state-manager_git.bb             
 |  2 +-
 meta-phosphor/recipes-phosphor/webui/phosphor-webui_git.bb                     
 |  2 +-
 7 files changed, 27 insertions(+), 8 deletions(-)
 create mode 100644 
meta-facebook/meta-tiogapass/recipes-fbtp/packagegroups/packagegroup-fb-apps.bb
$
$ git log --oneline --decorate=short --graph
*   4aaa7d156 (HEAD -> master) Merge remote-tracking branch 'upstream/master'
|\ 
| * c71bcdc01 (tag: v2.4, upstream/master, upstream/HEAD, upstream) 
phosphor-webui: srcrev bump 1cc7021c9e..bc5cc7f75c
| * 3db7820e6 skiboot: Bump to 6.0.13
| * 5a963b231 linux-aspeed: Move to 4.18.16
| * 36a49e2d7 Add Entity Manager to Facebook Tiogapas
...
$
```

The strange part is this:

```
$ git describe --debug
searching to describe HEAD
finished search at eb8644742b22a77f40e6cfe9f3d325e92a602def
 annotated       1612 v2.3
 annotated       1976 v2.2
 annotated       2427 v2.1
 annotated       2525 v2.4
 annotated       2648 v2.0
 annotated       2910 v1.99.10
traversed 2985 commits
v2.3-1612-g4aaa7d1
```

As you can see, the `v2.4` tag, that according to the graph log is the 
immediate parent of the current HEAD, is not the best candidate somehow, and 
`v2.3` is instead reported. It also somehow thinks that there are 2525 commits 
between `v2.4` tag and the HEAD.

Is this a bug in git or are we doing anything wrong?

Thanks.

Alexander.

P.S. This has been verified both with stock git version 2.7.4 and with version 
2.20.0.rc0.349.g148beda from `next` top-of-branch.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to