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

gEDA-user: [PATCH] Use git describe --always to check git version.



On Fri, 7 Aug 2009 12:26:25 +0200, Ivan Stankovic <pokemon@xxxxxxxxxxxxxx>
wrote:

> Looking at geda-git.m4, I see 
> 
>     if (cd $srcdir && $GIT describe > /dev/null 2>&1); then
> 
> which needs git tags to work. However, my local clone doesn't have
> any tags and git describe fails with
> 
>     fatal: cannot describe '6dc3b67fb796278954d8440a1ab1950b988146f7'

Hi Ivan,

Please try the attached patch.

Regards,

Peter

-- 
Peter Brett <peter@xxxxxxxxxxxxx>
Remote Sensing Research Group
Surrey Space Centre
From 2cb8c2a82bd54e89e13716833f861538d5a59545 Mon Sep 17 00:00:00 2001
From: Peter TB Brett <peter@xxxxxxxxxxxxx>
Date: Fri, 7 Aug 2009 14:54:06 +0100
Subject: [PATCH] Use git describe --always to check git version.

If a repository was checked out without annotated tags, using git
describe to check for repository presence or for summarising recent
repository history won't work, and version.h won't be generated
correctly.  Passing the --always tag to git describe ensures that
something sane happens.

 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 71996e9..34a331f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -26,7 +26,7 @@ version.h: stamp-git $(top_builddir)/configure $(srcdir)/version.h.in
 
 	@date_ver=$(DATE_VERSION); dotted_ver=$(DOTTED_VERSION); \
 	git_commit=`cd $(srcdir) && $(GIT) rev-parse HEAD`; \
-	git_ver=`cd $(srcdir) && $(GIT) describe HEAD`; \
+	git_ver=`cd $(srcdir) && $(GIT) describe --always HEAD`; \
 	sed -e"s:^.*\(PACKAGE_DATE_VERSION\).*$$:#define \1 \"$$date_ver\":" \
 	    -e"s:^.*\(PACKAGE_DOTTED_VERSION\).*$$:#define \1 \"$$dotted_ver\":" \
 	    -e"s:^.*\(PACKAGE_GIT_VERSION\).*$$:#define \1 \"$$git_ver\":" \
diff --git a/m4/geda-git-version.m4 b/m4/geda-git-version.m4
index b2d301f..a0d707f 100644
--- a/m4/geda-git-version.m4
+++ b/m4/geda-git-version.m4
@@ -35,13 +35,16 @@ changequote([,])
   DATE_VERSION="$1"
 
   # If we're in a git repository, get the detailed version from git
-  # describe. Otherwise, construct something that vaguely matches.
+  # describe.
   if test "X$HAVE_GIT_REPO" = "Xyes"; then
     AC_MSG_CHECKING([version from git repository])
-    GIT_VERSION=`cd $srcdir && $GIT describe`
+    GIT_VERSION=`cd $srcdir && $GIT describe --always`
     AC_MSG_RESULT([$GIT_VERSION])
+  fi
 
-    # Test that the git version and AC_INIT versions agree
+  # If there's an annotated tag available, test that the git version
+  # and AC_INIT versions agree.
+  if git describe > /dev/null; then
 changequote(,)
     git_sed_pattern="^\([^-]*\)-\([^-]*\).*"
 changequote([,])
diff --git a/m4/geda-git.m4 b/m4/geda-git.m4
index 42c6bf4..3d4e1af 100644
--- a/m4/geda-git.m4
+++ b/m4/geda-git.m4
@@ -35,7 +35,7 @@ AC_DEFUN([AX_GIT_REPO],
   HAVE_GIT_REPO=no
   if test "X$GIT" != "Xno"; then
     AC_MSG_CHECKING([if the source directory is a git repository])
-    if (cd $srcdir && $GIT describe > /dev/null 2>&1); then
+    if (cd $srcdir && $GIT describe --always > /dev/null); then
       AC_MSG_RESULT([yes])
       HAVE_GIT_REPO=yes
     else
-- 
1.6.3.3


_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user