changeset 29143:4380657d0b90

git-version-gen: sync from coreutils. * build-aux/git-version-gen: Add comments. Change the first '-' to '.' in the snapshot version string, e.g., 6.9-377-08144 -> 6.9.377-08144 Remove first parameter. Don't declare a version "-dirty" merely because a time stamp has changed.
author Jim Meyering <meyering@redhat.com>
date Mon, 05 Nov 2007 08:27:07 +0100
parents e88150bfed73
children d368d97d2441
files ChangeLog build-aux/git-version-gen
diffstat 2 files changed, 28 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Nov 05 01:55:32 2007 +0100
+++ b/ChangeLog	Mon Nov 05 08:27:07 2007 +0100
@@ -1,3 +1,13 @@
+2007-11-05  Jim Meyering  <meyering@redhat.com>
+
+	git-version-gen: sync from coreutils.
+	* build-aux/git-version-gen: Add comments.
+	Change the first '-' to '.' in the snapshot version string,
+	e.g., 6.9-377-08144 -> 6.9.377-08144
+	Remove first parameter.
+	Don't declare a version "-dirty" merely because a time
+	stamp has changed.
+
 2007-11-04  Bruno Haible  <bruno@clisp.org>
 
 	* lib/lock.h: Protect all macro definitions containing an 'if'
--- a/build-aux/git-version-gen	Mon Nov 05 01:55:32 2007 +0100
+++ b/build-aux/git-version-gen	Mon Nov 05 08:27:07 2007 +0100
@@ -1,7 +1,6 @@
 #!/bin/sh
 # Print a version string.
-# This script is derived from GIT-VERSION-GEN from GIT: http://git.or.cz/.
-scriptversion=2007-06-30.12
+scriptversion=2007-11-05.08
 
 # Copyright (C) 2007 Free Software Foundation
 #
@@ -20,13 +19,19 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 # 02110-1301, USA.
 
+# This script is derived from GIT-VERSION-GEN from GIT: http://git.or.cz/.
+# It may be run two ways:
+# - from a git repository in which the git-describe command below
+#   produces useful output (thus requiring at least one signed tag)
+# - from a non-git-repo directory containing a .version file, which
+#   presumes this script is invoked like "./git-version-gen .version".
+
 case $# in
-    2) ;;
-    *) echo 1>&2 "Usage: $0 \$VERSION \$srcdir/.version"; exit 1;;
+    1) ;;
+    *) echo 1>&2 "Usage: $0 \$srcdir/.version"; exit 1;;
 esac
 
-default_version=$1
-tarball_version_file=$2
+tarball_version_file=$1
 nl='
 '
 
@@ -54,14 +59,18 @@
 	 *) (exit 1) ;;
        esac
 then
-    # Remove the "g" in git-describe's output string; change each - to a '.'
-    v=`echo "$v" | sed 's/\(.*\)-g/\1-/;s/-/./g'`;
+    # Change the first '-' to a '.', so version-comparing tools work properly.
+    # Remove the "g" in git-describe's output string, to save a byte.
+    v=`echo "$v" | sed 's/-/./;s/\(.*\)-g/\1-/'`;
 else
-    v=$default_version
+    v=UNKNOWN
 fi
 
 v=`echo "$v" |sed 's/^v//'`
 
+# Don't declare a version "dirty" merely because a time stamp has changed.
+git-status > /dev/null 2>&1
+
 dirty=`sh -c 'git diff-index --name-only HEAD' 2>/dev/null` || dirty=
 case "$dirty" in
     '') ;;