changeset 14094:14bd4f47ae3f

git-version-gen: handle failed "git rev-list" * build-aux/git-version-gen: Rather than leaking a "fatal" error from git and proceeding as if it had succeeded but printed no SHA1 checksums, suppress the diagnostic and handle the failure. Reported by Bruce Korb in http://marc.info/?l=git&m=129399145930450&w=2
author Jim Meyering <meyering@redhat.com>
date Mon, 03 Jan 2011 19:35:19 +0100
parents bae3b310c970
children a6c3d8a0de24
files ChangeLog build-aux/git-version-gen
diffstat 2 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2011-01-03  Jim Meyering  <meyering@redhat.com>
 
+	git-version-gen: handle failed "git rev-list"
+	* build-aux/git-version-gen: Rather than leaking a "fatal" error
+	from git and proceeding as if it had succeeded but printed no SHA1
+	checksums, suppress the diagnostic and handle the failure.
+	Reported by Bruce Korb in http://marc.info/?l=git&m=129399145930450&w=2
+
 	git-version-gen: include command name in one more diagnostic
 	* build-aux/git-version-gen: When the required .tarball-version file
 	was missing or unreadable, you might see the diagnostic from "cat",
--- a/build-aux/git-version-gen
+++ b/build-aux/git-version-gen
@@ -1,6 +1,6 @@
 #!/bin/sh
 # Print a version string.
-scriptversion=2011-01-03.10; # UTC
+scriptversion=2011-01-03.18; # UTC
 
 # Copyright (C) 2007-2011 Free Software Foundation, Inc.
 #
@@ -122,8 +122,12 @@
 	    # result is the same as if we were using the newer version
 	    # of git describe.
 	    vtag=`echo "$v" | sed 's/-.*//'`
-	    numcommits=`git rev-list "$vtag"..HEAD | wc -l`
+	    commit_list=`git rev-list "$vtag"..HEAD 2>/dev/null` \
+		|| { commit_list=failed;
+		     echo "$0: WARNING: git rev-list failed" 1>&2; }
+	    numcommits=`echo "$commit_list" | wc -l`
 	    v=`echo "$v" | sed "s/\(.*\)-\(.*\)/\1-$numcommits-\2/"`;
+	    test "$commit_list" = failed && v=UNKNOWN
 	    ;;
     esac