threads / bug / 6810

bug: build from tarball uses git-describe

Subject: bug: build from tarball uses git-describe

## tl;dr

6 messages between Feb 13, 2007 and Feb 14, 2007.

replies: 5people: 3as markdown or json

Han-Wen Nienhuys· Feb 13, 2007, 22:59 UTC · lore

while building GIT from tarball inside a GUB checkout (GUB is a build environment , now using GIT for version control):

sed -e '1s|#!.*/sh|#!/bin/sh|' \
            -e 's|@@PERL@@|/usr/bin/perl|g' \
            -e 's/@@GIT_VERSION@@/release_2.11.17.1_of_lilypond_release/2.11.16.1.g3abe43a66cf3655e5ec5486c3001ac2ac479433.3.gdb02-dirty/g' \
            -e 's/@@NO_CURL@@//g' \
apparently, the makefile blindly uses the output of 
  git describe 
without checking whether there is a .git directory.
-- 
 Han-Wen Nienhuys - hanwen@xs4all.nl - http://www.xs4all.nl/~hanwen
Johannes Schindelin· Feb 14, 2007, 01:00 UTC · re: Han-Wen Nienhuys · lore

Re: bug: build from tarball uses git-describe

Hi,
On Tue, 13 Feb 2007, Han-Wen Nienhuys wrote:
Show 5 quoted lines
> apparently, the makefile blindly uses the output of 
> 
>   git describe 
> 
> without checking whether there is a .git directory.
Does this (totally untested) patch help?
--
 GIT-VERSION-GEN |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index 7a10b60..e6f89cb 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -8,7 +8,7 @@ LF='
 
 # First try git-describe, then see if there is a version file
 # (included in release tarballs), then default
-if VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
+if test -d .git && VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
    case "$VN" in
    *$LF*) (exit 1) ;;
    v[0-9]*) : happy ;;
Junio C Hamano· Feb 14, 2007, 01:04 UTC · re: Johannes Schindelin · lore

Re: bug: build from tarball uses git-describe

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 20 quoted lines
> Does this (totally untested) patch help?
>
> --
>
>  GIT-VERSION-GEN |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
> index 7a10b60..e6f89cb 100755
> --- a/GIT-VERSION-GEN
> +++ b/GIT-VERSION-GEN
> @@ -8,7 +8,7 @@ LF='
>  
>  # First try git-describe, then see if there is a version file
>  # (included in release tarballs), then default
> -if VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
> +if test -d .git && VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
>     case "$VN" in
>     *$LF*) (exit 1) ;;
>     v[0-9]*) : happy ;;

Have you checked what the elif part does in the if statement you are patching?

After all fresh tarball is how we build rpm packages and we do not have .git in that build environment, so I am quite puzzled.

Johannes Schindelin· Feb 14, 2007, 01:10 UTC · re: Junio C Hamano · lore

Re: bug: build from tarball uses git-describe

Hi,
On Tue, 13 Feb 2007, Junio C Hamano wrote:
Show 25 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > Does this (totally untested) patch help?
> >
> > --
> >
> >  GIT-VERSION-GEN |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
> > index 7a10b60..e6f89cb 100755
> > --- a/GIT-VERSION-GEN
> > +++ b/GIT-VERSION-GEN
> > @@ -8,7 +8,7 @@ LF='
> >  
> >  # First try git-describe, then see if there is a version file
> >  # (included in release tarballs), then default
> > -if VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
> > +if test -d .git && VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
> >     case "$VN" in
> >     *$LF*) (exit 1) ;;
> >     v[0-9]*) : happy ;;
> 
> Have you checked what the elif part does in the if statement you
> are patching?

It checks if the file "version" exists, and takes the contents of that as version, otherwise $DEF_VER.

> After all fresh tarball is how we build rpm packages and we do
> not have .git in that build environment, so I am quite puzzled.

Yes, the idea was: if there is no .git, do not even bother checking the output of git-describe (it might find a .git directory in a parent directory, after all).

Ciao, Dscho

Junio C Hamano· Feb 14, 2007, 19:26 UTC · re: Johannes Schindelin · lore

Re: bug: build from tarball uses git-describe

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 9 quoted lines
> It checks if the file "version" exists, and takes the contents of that as 
> version, otherwise $DEF_VER.
>
>> After all fresh tarball is how we build rpm packages and we do
>> not have .git in that build environment, so I am quite puzzled.
>
> Yes, the idea was: if there is no .git, do not even bother checking the 
> output of git-describe (it might find a .git directory in a parent 
> directory, after all).

Ok, then let's do this. Our tarballs do have version file, and if the upperlevel Makefile wants to set a different version it can drop 'version' file before descending into us.

diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
index febacd2..6abde8d 100755
--- a/GIT-VERSION-GEN
+++ b/GIT-VERSION-GEN
@@ -6,18 +6,19 @@ DEF_VER=v1.5.0.GIT
 LF='
 '
 
-# First try git-describe, then see if there is a version file
-# (included in release tarballs), then default
-if VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
-   case "$VN" in
-   *$LF*) (exit 1) ;;
-   v[0-9]*) : happy ;;
-   esac
-then
-	VN=$(echo "$VN" | sed -e 's/-/./g');
-elif test -f version
+# First see if there is a version file (included in release tarballs),
+# then try git-describe, then default.
+if test -f version
 then
 	VN=$(cat version) || VN="$DEF_VER"
+elif test -d .git &&
+	VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
+	case "$VN" in
+	*$LF*) (exit 1) ;;
+	v[0-9]*) : happy ;;
+	esac
+then
+	VN=$(echo "$VN" | sed -e 's/-/./g');
 else
 	VN="$DEF_VER"
 fi
Johannes Schindelin· Feb 14, 2007, 19:30 UTC · re: Junio C Hamano · lore

Re: bug: build from tarball uses git-describe

Hi,
On Wed, 14 Feb 2007, Junio C Hamano wrote:
> Ok, then let's do this.  Our tarballs do have version file, and if the 
> upperlevel Makefile wants to set a different version it can drop 
> 'version' file before descending into us.

Okay. But I started hacking git by getting it, compiling it, doing "git init", a "git fetch origin", "git read-tree HEAD" and "git update-index --refresh". In that case, .git is there, but also the file "version".

But that's too obscure a case as to care about, so I am okay with your patch.

Ciao, Dscho

← back to recent threads