changeset 16083:1b52ba2f7e83

git-version-gen: Add --prefix. * build-aux/git-version-gen: Add --prefix to configure the tag match string.
author Simon Josefsson <simon@josefsson.org>
date Sun, 13 Nov 2011 14:43:35 +0100
parents 0da13ca4fc80
children 8c88dd7eb4fb
files ChangeLog build-aux/git-version-gen
diffstat 2 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-11-13  Simon Josefsson  <simon@josefsson.org>
+
+	* build-aux/git-version-gen: Add --prefix to configure the tag
+	match string.
+
 2011-11-13  Simon Josefsson  <simon@josefsson.org>
 
 	* build-aux/git-version-gen: Add --help and --version.
--- 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 @@
 
 Options:
 
+   --prefix           prefix of git tags (default 'v')
+
    --help             display this help and exit
    --version          output version information and exit
 
@@ -94,6 +96,7 @@
   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 @@
 fi
 
 tag_sed_script="${tag_sed_script:-s/x/x/}"
+prefix="${prefix:-v}"
 
 nl='
 '
@@ -146,11 +150,11 @@
 # 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
@@ -183,7 +187,7 @@
     v=UNKNOWN
 fi
 
-v=`echo "$v" |sed 's/^v//'`
+v=`echo "$v" |sed "s/^$prefix//"`
 
 # 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"