summaryrefslogtreecommitdiff
path: root/build-aux/git-version-gen
diff options
context:
space:
mode:
authorPeter Rosin <peda@lysator.liu.se>2012-12-29 00:45:07 +0100
committerEric Blake <eblake@redhat.com>2012-12-31 15:55:16 -0700
commitb679574e3ac7d53c20778854719043c2c4a2dc9e (patch)
tree6837984b7473f9c671dd387e0c8921671e9f2ef9 /build-aux/git-version-gen
parent258a23681fb0e3c6b6031b5dfe049cac0c4a6836 (diff)
downloadgnulib-b679574e3ac7d53c20778854719043c2c4a2dc9e.tar.gz
git-version-gen: add --fallback option to use if git is not present
When building in a git checkout, but from a system lacking git, it is useful to fall back to the version determined when the git checkout was last used from a system sporting git. * build-aux/git-version-gen: Add support for the new option --fallback, which comes into play when there is no $tarball_version_file and git is not working. (scriptversion): Update. Copyright-paperwork-exempt: yes Signed-off-by: Peter Rosin <peda@lysator.liu.se>
Diffstat (limited to 'build-aux/git-version-gen')
-rwxr-xr-xbuild-aux/git-version-gen9
1 files changed, 7 insertions, 2 deletions
diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen
index 0fa90636bd..9152baa189 100755
--- a/build-aux/git-version-gen
+++ b/build-aux/git-version-gen
@@ -1,6 +1,6 @@
#!/bin/sh
# Print a version string.
-scriptversion=2012-03-18.17; # UTC
+scriptversion=2012-12-31.22; # UTC
# Copyright (C) 2007-2012 Free Software Foundation, Inc.
#
@@ -86,6 +86,7 @@ Print a version string.
Options:
--prefix prefix of git tags (default 'v')
+ --fallback fallback version to use if \"git --version\" fails
--help display this help and exit
--version output version information and exit
@@ -93,12 +94,14 @@ Options:
Running without arguments will suffice in most cases."
prefix=v
+fallback=
while test $# -gt 0; do
case $1 in
--help) echo "$usage"; exit 0;;
--version) echo "$version"; exit 0;;
--prefix) shift; prefix="$1";;
+ --fallback) shift; fallback="$1";;
-*)
echo "$0: Unknown option '$1'." >&2
echo "$0: Try '--help' for more information." >&2
@@ -184,8 +187,10 @@ then
# Remove the "g" in git describe's output string, to save a byte.
v=`echo "$v" | sed 's/-/./;s/\(.*\)-g/\1-/'`;
v_from_git=1
-else
+elif test -z "$fallback" || git --version >/dev/null 2>&1; then
v=UNKNOWN
+else
+ v=$fallback
fi
v=`echo "$v" |sed "s/^$prefix//"`