bug-gnulib
[Top][All Lists]
Advanced

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

Re: git-version-gen


From: Simon Josefsson
Subject: Re: git-version-gen
Date: Sun, 13 Nov 2011 14:26:33 +0100
User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/23.2 (gnu/linux)

How about this patch to make the match string configurable?

/Simon

diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen
index 3234bdd..1d484d9 100755
--- a/build-aux/git-version-gen
+++ b/build-aux/git-version-gen
@@ -1,6 +1,6 @@
 #!/bin/sh
 # Print a version string.
-scriptversion=2011-11-13.10; # UTC
+scriptversion=2011-11-13.13; # UTC
 
 # Copyright (C) 2007-2011 Free Software Foundation, Inc.
 #
@@ -85,6 +85,8 @@ Print a version string.
 
 Options:
 
+   --prefix           prefix of git tags (default 'v*')
+
    --help             display this help and exit
    --version          output version information and exit
 
@@ -94,6 +96,7 @@ while test $# -gt 0; do
   case $1 in
     --help) echo "$usage"; exit 0;;
     --version) echo "$version"; exit 0;;
+    --prefix) shift; prefix="$1";;
     -*)
       echo "$0: Unknown option \`$1'." >&2
       echo "$0: Try \`--help' for more information." >&2
@@ -117,6 +120,7 @@ if test -z "$tarball_version_file"; then
 fi
 
 tag_sed_script="${tag_sed_script:-s/x/x/}"
+prefix="${prefix:-v*}"
 
 nl='
 '
@@ -146,14 +150,15 @@ then
 # directory, and "git describe" output looks sensible, use that to
 # derive a version string.
 elif test "`git log -1 --pretty=format:x . 2>&1`" = x \
-    && v=`git describe --abbrev=4 --match='v*' HEAD 2>/dev/null \
+    && v=`git describe --abbrev=4 --match="$prefix*" HEAD 2>/dev/null \
           || git describe --abbrev=4 HEAD 2>/dev/null` \
     && v=`printf '%s\n' "$v" | sed "$tag_sed_script"` \
     && case $v in
-         v[0-9]*) ;;
+         $prefix*) ;;
          *) (exit 1) ;;
        esac
 then
+    v=`echo "$v" |sed "s/^$prefix//"`
     # Is this a new git that lists number of commits since the last
     # tag or the previous older version that did not?
     #   Newer: v6.10-77-g0f8faeb
@@ -183,8 +188,6 @@ else
     v=UNKNOWN
 fi
 
-v=`echo "$v" |sed 's/^v//'`
-
 # Test whether to append the "-dirty" suffix only if the version
 # string we're using came from git.  I.e., skip the test if it's "UNKNOWN"
 # or if it came from .tarball-version.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]