2

Consider this excerpt of git log --oneline --decorate --graph:

*   552485a (HEAD -> master, origin/master) Finish v0.8.4
|\
| * c198066 (tag: v0.8.4) some commit message
* |   343af72 Finish v0.8.3
|\ \
| |/
| * 0267e30 (tag: v0.8.3) some commit message
* |   8f0ff57 some commit message
|\ \
| |/
...

(NB: the tag v0.8.4 is on a commit from branch 'develop')

How comes that when I run git describe I get this:

v0.8.4-16-g552485a

that is, git counts 16 commits since tag v0.8.4. I'd expect it to return v0.8.4-1-g552485a.

More specifically (when using the --debug option):

suche zur Beschreibung von HEAD
beendete Suche bei b53e85f9c8ee785c0ce50f727819b267107554fd
 annotated         16 v0.8.4
 annotated         17 v0.8.3
 annotated         18 v0.8.2
 annotated         22 v0.8
 annotated         49 v0.7
 annotated         60 v0.6
 annotated         85 v0.5
103 Commits durchlaufen
v0.8.4-16-g552485a

Interestingly, if I switch to my develop branch:

0992f78 (HEAD -> develop, origin/develop) Some commit message.
c198066 (tag: v0.8.4) Minor change.
0267e30 (tag: v0.8.3) Minor changes.

git describe returns as expected: v0.8.4-1-g0992f78

Background: I'm using SmartGit and its Git-Flow functionality.

Here's a graphical view of the relevant commits (red: master, blue: develop):

enter image description here

Andre Loker
  • 8,368
  • 1
  • 23
  • 36

1 Answers1

1

The number is calculated not only with the commits since the tags. In case of merging, the commits of the other branch are included too.

The documentation of git-describe

The number of additional commits is the number of commits which would be displayed by "git log v1.0.4..HEAD".

blashser
  • 921
  • 6
  • 13
  • I'm not completely sure why it is done this way, but as it apparently works as design, I'll accept the answer. For my purposes, I need the number of commits on the path between the tag and the HEAD, so I'll resort to `git log --ancestry-path tag..HEAD --oneline` and count the number of lines. This seems to work fine so far. – Andre Loker Aug 07 '15 at 05:58