[pan2: 67/68] minor fix for git hash handling



commit 716ff68473ef28ba8fde10671c2e3917c818689b
Author: K. Haley <haleykd users sf net>
Date:   Wed Jan 26 17:13:57 2011 -0700

    minor fix for git hash handling
    
    If a tarball was created from the git tree it would lack the git revision.  Have configure create 'pan_git_rev' for use when there is no hash from git archive and not building from the git tree.

 Makefile.am  |    3 ++-
 configure.in |   25 +++++++++++++++----------
 2 files changed, 17 insertions(+), 11 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index d8a33ee..3db545f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -22,7 +22,8 @@ EXTRA_DIST = \
  pan.png \
  $(DESKTOP_IN_FILES) \
  $(DESKTOP_FILES) \
- intltool-extract.in intltool-merge.in intltool-update.in
+ intltool-extract.in intltool-merge.in intltool-update.in \
+ pan_git_rev
 
 Productivitydir = $(datadir)/applications
 Productivity_DATA = $(DESKTOP_FILES)
diff --git a/configure.in b/configure.in
index 2a2c8f7..19cccd4 100644
--- a/configure.in
+++ b/configure.in
@@ -5,25 +5,30 @@ AC_DEFINE(VERSION_REVISION,0,[Revision part of version number])
 AC_DEFINE(VERSION_TITLE,["House of Butterflies"],[Release Name])
 AC_PREREQ(2.54)
 
+dnl expanded by export-archive
+GIT_HASH='$Format:%h$'
+if test '0' \< $GIT_HASH ;then
+	GIT_BRANCH=`echo '$Format:%d$' | awk -F , '{print gensub("[[\(\)]]","","g",$NF)}' 2>/dev/null`
+else
 dnl git-dir is used for building outside the src tree
-GIT_BRANCH=`git --git-dir=$srcdir/.git symbolic-ref HEAD 2> /dev/null | awk -F/ '{print $NF}'`
-GIT_HASH=`git --git-dir=$srcdir/.git log -1 --pretty=format:%h 2> /dev/null`
+	GIT_HASH=`git --git-dir=$srcdir/.git log -1 --pretty=format:%h 2> /dev/null`
+	if test ! -z $GIT_HASH; then
+		GIT_BRANCH=`git --git-dir=$srcdir/.git symbolic-ref HEAD 2> /dev/null | awk -F/ '{print $NF}'`
+	fi
+fi
 if test ! -z $GIT_HASH; then
 	if test -z $GIT_BRANCH; then
 		GIT_REV="GIT $GIT_HASH"
 	else
 		GIT_REV="GIT $GIT_HASH $GIT_BRANCH"
 	fi
+	echo $GIT_REV > pan_git_rev
+elif test -f pan_git_rev; then
+	GIT_REV=`cat pan_git_rev`
 else
-	dnl expanded by export-archive
-	GIT_HASH=$Format:%h$
-	GIT_BRANCH=`echo "$Format:%d$" | awk -F , '{print gensub("[[\(\)]]","","g",$NF)}' 2>/dev/null`
-	if test -z $GIT_BRANCH; then
-		GIT_REV="GIT $GIT_HASH"
-	else
-		GIT_REV="GIT $GIT_HASH $GIT_BRANCH"
-	fi
+	GIT_REV="Unknown"
 fi
+
 AC_DEFINE_UNQUOTED([GIT_REV],["$GIT_REV"],[Git branch and hash])
 
 AM_CONFIG_HEADER(config.h)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]