git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steve Diver <squelch@think.zenbe.com>
To: Git List <git@vger.kernel.org>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: [RFC] Is using git describe resilient enough for setting the build version of git?
Date: Sun, 21 Feb 2010 00:48:45 +0000	[thread overview]
Message-ID: <4B8082ED.7020505@think.zenbe.com> (raw)

Hi,

I recently ran into a problem with the displayed version number for a 
build of MSysgit. After much head scratching on my part, and divine 
intervention from Dscho given his intimate knowledge of the codebase, 
was it resolved.

My problem was that although I had checked out the tip of devel branch, 
every time I ran make, my build version was incorrect, although the hash 
suffix corresponded to the tip of the devel branch.

$ make
GIT_VERSION = 1.6.4.msysgit.0.2049.g91809
...

I was expecting to see 1.7.0 as the version which had been merged a few 
days ago, and simply inspecting the files did not reveal where the 
discrepancy originated.

I had been concentrating on GIT-VERSION-GEN to see how the version was 
generated, and then comparing between two machines - one with a 
successful build showing correct version and the other not, but both 
showing 1.7.0 as DEF_VER and apparently identical repositories - 
Johannes then replied to my query with a request to fetch some tags 
which had been overlooked. Viewing the two repositories graphically side 
by side immediately revealed that the build with the incorrect version 
label did not have recent tags, and it was not the files I should have 
been diffing, but comparing the output of "git describe". Problem solved 
after fetching the new tags.

This has been a most beneficial learning exercise for me, and I am most 
grateful, and heartened I was on the right track, but I think I also see 
a potential problem.

GIT-VERSION-GEN sets a default value DEF_VER according to the version at 
the time.

The two most recent being 1.6.6.2 at revision 82221 and 1.7.0 at e923e

However, in the absence of a version, the script uses "git describe" to 
retrieve the latest tag, and goes on to use this to create the version 
file along with the hash suffix at the current HEAD. In my case, the 
latest tag was 1.6.4 but I was building from the latest source at 
revision 91809.

Reading the manual entry for "git describe"[1] there is a note saying 
that the hash suffix does not guarantee disambiguity, and given that a 
tag may be incorrect or missing, there is a chance - albeit with 
diminishing odds - that the 5 digit hash/tag combination might lead to 
some obscure problems at some point along the line.

The chance of this happening really is low, but there is a chance all 
the same. We cannot foresee all errors, but identifying, and further 
reducing the odds of some must be good. Without doing the math, a guess 
would be that the probability of a repeat 5 digit abbreviated hash 
suffix increases the longer a tagged version is in place, so never will 
be 100% safe. Relying on the build version alone is not a good test 
under most circumstances, but in my case I could see that the hash was 
correct and the displayed version was unexpected. The other way around 
or one of those rare occasions of a repeat would have gone completely 
unnoticed.

I may be wrong, but the only scenario where I see DEF_VER being used by 
GIT-VERSION-GEN, would be when there are no tags for git describe to 
retrieve. ie "git pull --no-tags"

If my understanding is correct, DEF_VER is unique and set at the same 
time as the tagged version, so wouldn't it be desirable to cross check, 
or include this value instead of relying solely on the tag when present 
during the generation of GIT-VERSION-FILE at build time?


Steve

1. http://www.kernel.org/pub/software/scm/git/docs/git-describe.html

             reply	other threads:[~2010-02-21  0:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-21  0:48 Steve Diver [this message]
2010-02-21  6:07 ` [RFC] Is using git describe resilient enough for setting the build version of git? Avery Pennarun
2010-02-21  8:42   ` Steve Diver

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=4B8082ED.7020505@think.zenbe.com \
    --to=squelch@think.zenbe.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    /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).