]> Savannah Git Hosting - gnulib.git/commitdiff
git-version-gen: Fix for tags containing '-'
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 6 Aug 2017 06:26:03 +0000 (08:26 +0200)
committerJim Meyering <meyering@fb.com>
Sun, 6 Aug 2017 16:02:25 +0000 (09:02 -0700)
Really old versions of git-describe (before v1.5.0, Feb 2007) don't
have the number of commits in their long format output, i.e. where
modern 'git describe --abbrev=4 --match="v*"' prints
"v0.1-1494-g124b9", they print "v0.1-1494-g124b9".  git-version-gen
recognizes both patterns, and normalizes the old format to the new
one.

Unfortunately, this normalization code gets confused when the tag
contains '-'.  Reproducer:

    $ git-tag -m test v0.2-rc1
    $ build-aux/git-version-gen .tarball-version; echo
    build-aux/git-version-gen: WARNING: git rev-list failed
    UNKNOWN

We take exact tag "v0.2-rc1" for the old format, extract the presumed
tag "v0.2" from it, then run "git rev-list v0.2..HEAD" to count
commits since tha tag.  Fails, because tag "v0.2" does not exist.

* git-version-gen: We could perhaps drop support for versions from more
than a decade ago.  But tightening the pattern match is easy enough,
so do that.  Still breaks when you use version tags ending in something
matching -g????, but you arguably get what you deserve then.

ChangeLog
build-aux/git-version-gen

index 74e9831fb20e38ea312cfce5f49275f546155f07..cae6c7df94e456e64fefd2a91d866def79f72685 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+2017-08-06  Markus Armbruster  <armbru@pond.sub.org>
+
+       git-version-gen: Fix for tags containing '-'
+
+       Really old versions of git-describe (before v1.5.0, Feb 2007)
+       don't have the number of commits in their long format output,
+       i.e. where modern 'git describe --abbrev=4 --match="v*"' prints
+       "v0.1-1494-g124b9", they print "v0.1-1494-g124b9".  git-version-gen
+       recognizes both patterns, and normalizes the old format to the new one.
+
+       Unfortunately, this normalization code gets confused when the tag
+       contains '-'.  Reproducer:
+
+           $ git-tag -m test v0.2-rc1
+           $ build-aux/git-version-gen .tarball-version; echo
+           build-aux/git-version-gen: WARNING: git rev-list failed
+           UNKNOWN
+
+       We take exact tag "v0.2-rc1" for the old format, extract the presumed
+       tag "v0.2" from it, then run "git rev-list v0.2..HEAD" to count
+       commits since tha tag.  Fails, because tag "v0.2" does not exist.
+
+       * git-version-gen: We could perhaps drop support for versions from
+       more than a decade ago.  But tightening the pattern match is easy
+       enough, so do that.  Still breaks when you use version tags ending in
+       something matching -g????, but you arguably get what you deserve then.
+
 2017-08-05  Paul Eggert  <eggert@cs.ucla.edu>
 
        valgrind-tests: use ls, and cache
index 079849d5e523cd8354cbfada84dc7e784f3debfc..6c054b4881a0ba8b2cd44a232fd72197f0b7cba7 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 # Print a version string.
-scriptversion=2017-01-09.19; # UTC
+scriptversion=2017-08-06.05; # UTC
 
 # Copyright (C) 2007-2017 Free Software Foundation, Inc.
 #
@@ -168,8 +168,8 @@ then
     #   Newer: v6.10-77-g0f8faeb
     #   Older: v6.10-g0f8faeb
     case $v in
-        *-*-*) : git describe is okay three part flavor ;;
-        *-*)
+        *-*-g????) : git describe is okay three part flavor ;;
+        *-g????)
             : git describe is older two part flavor
             # Recreate the number of commits and rewrite such that the
             # result is the same as if we were using the newer version