[PATCH 1/2] maint.mk: handle missing git with more grace

2012-10-31 Thread Peter Rosin
* top/maint.mk (no-submodule-changes, public-submodule-commit): Quietly
proceed if git is not present.

Copyright-paperwork-exempt: yes
Signed-off-by: Peter Rosin 
---
 top/maint.mk |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/top/maint.mk b/top/maint.mk
index ea44ece..8afac72 100644
--- a/top/maint.mk
+++ b/top/maint.mk
@@ -1370,7 +1370,8 @@ endef
 
 .PHONY: no-submodule-changes
 no-submodule-changes:
-   $(AM_V_GEN)if test -d $(srcdir)/.git; then  \
+   $(AM_V_GEN)if test -d $(srcdir)/.git\
+   && git --version >& /dev/null; then \
  diff=$$(cd $(srcdir) && git submodule -q foreach  \
  git diff-index --name-only HEAD)  \
|| exit 1;  \
@@ -1388,7 +1389,8 @@ submodule-checks ?= no-submodule-changes 
public-submodule-commit
 # cannot be built from a fresh clone.
 .PHONY: public-submodule-commit
 public-submodule-commit:
-   $(AM_V_GEN)if test -d $(srcdir)/.git; then  \
+   $(AM_V_GEN)if test -d $(srcdir)/.git\
+   && git --version >& /dev/null; then \
  cd $(srcdir) &&   \
  git submodule --quiet foreach test '$$(git rev-parse $$sha1)' \
  = '$$(git merge-base origin $$sha1)'  \
-- 
1.7.9




[PATCH 2/2] git-version-gen: add --fallback option to use if git is not present

2012-10-31 Thread Peter Rosin
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 
---
 build-aux/git-version-gen |9 +++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen
index 0fa9063..d85a126 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-10-31.13; # 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; then
 v=UNKNOWN
+else
+v=$fallback
 fi
 
 v=`echo "$v" |sed "s/^$prefix//"`
-- 
1.7.9