# [new tool] git-project-version.sh

8 messages from 2008-04-15 to 2008-04-15. Participants: Nico -telmich- Schottelius, Björn Steinbrink, Santi Béjar, Luciano Rocha, Nico Schottelius, Elijah Newren.
Thread: https://gitlist.dev/t/13122

## Nico -telmich- Schottelius, 2008-04-15 11:36

Subject: [new tool] git-project-version.sh
Message-ID: <20080415113629.GA17459@denkbrett.schottelius.org>
URL: https://gitlist.dev/e/20080415113629.GA17459%40denkbrett.schottelius.org

```
Hello!

As I want to use the latest commit id in all my projects, so I know
which commit the version is based on, I wrote an extremly simple script
that is based on git-show to display only the version named
git-project-version.sh.

You can find it in
   http://unix.schottelius.org/git/git-tools.git/.git/
   http://unix.schottelius.org/cgi-bin/gitweb.cgi?p=git-tools.git/.git;a=summary
and more information is available on
   http://nico.schottelius.org/notizbuch-blog/archive/2008/04/15/git-project-version-sh-written-versions-with-git/

Sincerly

Nico

ps: please cc on reply, I am not subscribed.

-- 
Think about Free and Open Source Software (FOSS).
http://nico.schottelius.org/documentations/foss/the-term-foss/

PGP: BFE4 C736 ABE5 406F 8F42  F7CF B8BE F92A 9885 188C

```

## Björn Steinbrink, 2008-04-15 11:55

Subject: Re: [new tool] git-project-version.sh
Message-ID: <20080415115529.GA3595@atjola.homenet>
URL: https://gitlist.dev/e/20080415115529.GA3595%40atjola.homenet
In-Reply-To: <20080415113629.GA17459@denkbrett.schottelius.org>

```
On 2008.04.15 13:36:29 +0200, Nico -telmich- Schottelius wrote:
> Hello!
> 
> As I want to use the latest commit id in all my projects, so I know
> which commit the version is based on, I wrote an extremly simple script
> that is based on git-show to display only the version named
> git-project-version.sh.
> 
> You can find it in
>    http://unix.schottelius.org/git/git-tools.git/.git/
>    http://unix.schottelius.org/cgi-bin/gitweb.cgi?p=git-tools.git/.git;a=summary
> and more information is available on
>    http://nico.schottelius.org/notizbuch-blog/archive/2008/04/15/git-project-version-sh-written-versions-with-git/

Hm, except for the three trailing dots that you get with
--abbrev-commit, you can get the same results with rev-parse

$ git rev-parse  HEAD
8a18e8fe4e0e64222de6b063a976d0fe24955ddb

$ git rev-parse --short HEAD
8a18e8f

Björn

```

## Santi Béjar, 2008-04-15 12:01

Subject: Re: [new tool] git-project-version.sh
Message-ID: <8aa486160804150501p2f55a3e9g33df94c1d4274e48@mail.gmail.com>
URL: https://gitlist.dev/e/8aa486160804150501p2f55a3e9g33df94c1d4274e48%40mail.gmail.com
In-Reply-To: <20080415113629.GA17459@denkbrett.schottelius.org>

```
On Tue, Apr 15, 2008 at 1:36 PM, Nico -telmich- Schottelius
<nico-git-20080415@schottelius.org> wrote:
> Hello!
>
>  As I want to use the latest commit id in all my projects, so I know
>  which commit the version is based on, I wrote an extremly simple script
>  that is based on git-show to display only the version named
>  git-project-version.sh.

an equivalent simpler version is:

git rev-parse [--short] HEAD

Also "git show" is a porcelain command, that means it is for humans,
not for scripts. The output of "git show" can change while the output
of "git rev-parse" (and the plumbing) is stable.

But maybe what you really want is:

git describe [--always]

Santi

```

## Nico -telmich- Schottelius, 2008-04-15 12:02

Subject: Re: [new tool] git-project-version.sh
Message-ID: <20080415120212.GB17459@denkbrett.schottelius.org>
URL: https://gitlist.dev/e/20080415120212.GB17459%40denkbrett.schottelius.org
In-Reply-To: <20080415115529.GA3595@atjola.homenet>

```
Björn Steinbrink [Tue, Apr 15, 2008 at 01:55:29PM +0200]:
> > [...git-project-version.sh...]
> > 
> 
> Hm, except for the three trailing dots that you get with
> --abbrev-commit, you can get the same results with rev-parse
> 
> $ git rev-parse  HEAD
> 8a18e8fe4e0e64222de6b063a976d0fe24955ddb
> 
> $ git rev-parse --short HEAD
> 8a18e8f

Should have known that before... thank you for the hint!

So just forget my previous post :-)

Nico

-- 
Think about Free and Open Source Software (FOSS).
http://nico.schottelius.org/documentations/foss/the-term-foss/

PGP: BFE4 C736 ABE5 406F 8F42  F7CF B8BE F92A 9885 188C

```

## Luciano Rocha, 2008-04-15 12:05

Subject: Re: [new tool] git-project-version.sh
Message-ID: <20080415120507.GB21572@bit.office.eurotux.com>
URL: https://gitlist.dev/e/20080415120507.GB21572%40bit.office.eurotux.com
In-Reply-To: <20080415113629.GA17459@denkbrett.schottelius.org>

```
On Tue, Apr 15, 2008 at 01:36:29PM +0200, Nico -telmich- Schottelius wrote:
> Hello!
> 
> As I want to use the latest commit id in all my projects, so I know
> which commit the version is based on, I wrote an extremly simple script
> that is based on git-show to display only the version named
> git-project-version.sh.
> 
> You can find it in
>    http://unix.schottelius.org/git/git-tools.git/.git/

I couldn't clone:
Cannot get remote repository information.
Perhaps git-update-server-info needs to be run there?

>    http://unix.schottelius.org/cgi-bin/gitweb.cgi?p=git-tools.git/.git;a=summary
> and more information is available on
>    http://nico.schottelius.org/notizbuch-blog/archive/2008/04/15/git-project-version-sh-written-versions-with-git/

I use "git describe" for this, it's more user-friendly.

-- 
Luciano Rocha <luciano@eurotux.com>
Eurotux Informática, S.A. <http://www.eurotux.com/>

```

## Nico Schottelius, 2008-04-15 12:52

Subject: Re: [new tool] git-project-version.sh
Message-ID: <20080415125209.GC17459@denkbrett.schottelius.org>
URL: https://gitlist.dev/e/20080415125209.GC17459%40denkbrett.schottelius.org
In-Reply-To: <20080415120507.GB21572@bit.office.eurotux.com>

```
Santi Béjar [Tue, Apr 15, 2008 at 02:01:06PM +0200]:
Luciano Rocha [Tue, Apr 15, 2008 at 01:05:07PM +0100]:
> [...git describe...]

Looks also quite nice, also added it to the blog entry,
but it seems to work wrong here:

The last tag I created on the master branch is called 1.20.3pre6,
but git-describe uses pre5:

[14:39] denkbrett:gpm% git-describe 
1.20.3pre5-17-gfccc331
[14:43] denkbrett:gpm% git tag 
1.20.3pre1
1.20.3pre2
1.20.3pre3
1.20.3pre4
1.20.3pre5
1.20.3pre6
1.99.0
1.99.1
1.99.2
1.99.2.1
1.99.2.2
1.99.3
1.99.4
1.99.5
[14:44] denkbrett:gpm% git branch  
  gpm-1-stable
  gpm-2-dev
* master
[14:51] denkbrett:gpm% git --version
git version 1.5.4.4


Nico

-- 
Think about Free and Open Source Software (FOSS).
http://nico.schottelius.org/documentations/foss/the-term-foss/

PGP: BFE4 C736 ABE5 406F 8F42  F7CF B8BE F92A 9885 188C

```

## Elijah Newren, 2008-04-15 12:55

Subject: Re: [new tool] git-project-version.sh
Message-ID: <51419b2c0804150555i50bcfa98pb6811c14e33f9d3c@mail.gmail.com>
URL: https://gitlist.dev/e/51419b2c0804150555i50bcfa98pb6811c14e33f9d3c%40mail.gmail.com
In-Reply-To: <20080415125209.GC17459@denkbrett.schottelius.org>

```
On Tue, Apr 15, 2008 at 6:52 AM, Nico Schottelius
<nico-git-20080415@schottelius.org> wrote:
> Santi Béjar [Tue, Apr 15, 2008 at 02:01:06PM +0200]:
>  Luciano Rocha [Tue, Apr 15, 2008 at 01:05:07PM +0100]:
>  > [...git describe...]
>
>  Looks also quite nice, also added it to the blog entry,
>  but it seems to work wrong here:
>
>  The last tag I created on the master branch is called 1.20.3pre6,
>  but git-describe uses pre5:

Is your 1.20.3pre6 tag annotated?  git-describe only uses annotated
tags by default; pass the --tags option to have it consider all tags.
(This caught me be surprise a few times as well.)

Elijah

```

## Nico Schottelius, 2008-04-15 13:09

Subject: Re: [new tool] git-project-version.sh
Message-ID: <20080415130922.GD17459@denkbrett.schottelius.org>
URL: https://gitlist.dev/e/20080415130922.GD17459%40denkbrett.schottelius.org
In-Reply-To: <51419b2c0804150555i50bcfa98pb6811c14e33f9d3c@mail.gmail.com>

```
Elijah Newren [Tue, Apr 15, 2008 at 06:55:18AM -0600]:
> [...Is your 1.20.3pre6 tag annotated?...]

Got me, it is not!

Also added your hint, thank you!

Nico

-- 
Think about Free and Open Source Software (FOSS).
http://nico.schottelius.org/documentations/foss/the-term-foss/

PGP: BFE4 C736 ABE5 406F 8F42  F7CF B8BE F92A 9885 188C

```
