I want to introduce a versioning constant grabbed from the version in Git. I know how to do this -- in a very hackish way in svn --
any ideas on how to do this with
Note: it is interesting to see how Git itself computes its own build number.
That just evolved in Git 2.12 (Q1 2017)
See commit a765974 (04 Dec 2016) by Ramsay Jones (``).
Helped-by: Jeff King (peff).
(Merged by Junio C Hamano -- gitster -- in commit 0a45050, 19 Dec 2016)
GIT-VERSION-GEN
VN=$(git describe --match "v[0-9]*" HEAD 2>/dev/null)
# instead of
VN=$(git describe --match "v[0-9]*" --abbrev=7 HEAD 2>/dev/null)
GIT-VERSION-GEN: do not force abbreviation length used by 'describe'The default version name for a Git binary is computed by running "
git describe" on the commit the binary is made out of, basing on a tag whose name matches "v[0-9]*", e.g.v2.11.0-rc2-2-g7f1dc9.In the very early days, with 9b88fce ("Makefile: use git-describe to mark the git version.", 2005-12-27), we used "
--abbrev=4" to get absolute minimum number of abbreviated commit object name.
This was later changed to match the default minimum of 7 with bf50515 ("Git 1.7.10.1", 2012-05-01).These days, the "default minimum" scales automatically depending on the size of the repository, and there is no point in specifying a particular abbreviation length; all we wanted since Git 1.7.10.1 days was to get "something reasonable we would use by default".
(That was introduced in Git 2.11: see the last part of "How much of a git sha is generally considered necessary to uniquely identify a change in a given codebase?")
Just drop "
--abbrev=" from the invocation of "git describe" and let the command pick what it thinks is appropriate, taking the end user's configuration and the repository contents into account.