# bug: build from tarball uses git-describe

6 messages from 2007-02-13 to 2007-02-14. Participants: Han-Wen Nienhuys, Johannes Schindelin, Junio C Hamano.
Thread: https://gitlist.dev/t/6810

## Han-Wen Nienhuys, 2007-02-13 22:59

Subject: bug: build from tarball uses git-describe
Message-ID: <eqtfso$7mo$1@sea.gmane.org>
URL: https://gitlist.dev/e/eqtfso%247mo%241%40sea.gmane.org

```


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, 2007-02-14 01:00

Subject: Re: bug: build from tarball uses git-describe
Message-ID: <Pine.LNX.4.63.0702140159440.22628@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0702140159440.22628%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <eqtfso$7mo$1@sea.gmane.org>

```
Hi,

On Tue, 13 Feb 2007, Han-Wen Nienhuys wrote:

> 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, 2007-02-14 01:04

Subject: Re: bug: build from tarball uses git-describe
Message-ID: <7vd54dwnvb.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vd54dwnvb.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <Pine.LNX.4.63.0702140159440.22628@wbgn013.biozentrum.uni-wuerzburg.de>

```
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?

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, 2007-02-14 01:10

Subject: Re: bug: build from tarball uses git-describe
Message-ID: <Pine.LNX.4.63.0702140206550.22628@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0702140206550.22628%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <7vd54dwnvb.fsf@assigned-by-dhcp.cox.net>

```
Hi,

On Tue, 13 Feb 2007, Junio C Hamano wrote:

> 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, 2007-02-14 19:26

Subject: Re: bug: build from tarball uses git-describe
Message-ID: <7vlkj0o814.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vlkj0o814.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <Pine.LNX.4.63.0702140206550.22628@wbgn013.biozentrum.uni-wuerzburg.de>

```
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> 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, 2007-02-14 19:30

Subject: Re: bug: build from tarball uses git-describe
Message-ID: <Pine.LNX.4.63.0702142028230.22628@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0702142028230.22628%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <7vlkj0o814.fsf@assigned-by-dhcp.cox.net>

```
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

```
