[RFC] Is using git describe resilient enough for setting the build version of git?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]