Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > comp.lang.java.programmer > #4605

Re: git-describe

From Tom Anderson <twic@urchin.earth.li>
Newsgroups comp.lang.java.programmer
Subject Re: git-describe
Date 2011-05-26 17:59 +0100
Organization Stack Usenet News Service
Message-ID <alpine.DEB.2.00.1105261519520.19918@urchin.earth.li> (permalink)
References <irikq5$q0c$1@lust.ihug.co.nz>

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On Wed, 25 May 2011, Lawrence D'Oliveiro wrote:

> Discovered yet another nifty Git feature while looking through the docs.
>
> Build scripts often try to automatically determine some kind of revision
> number to include with the version info when building a piece of software.
> With Subversion, you can use “svn info” to get a revision number that
> increments with every commit, that you can use for that.
>
> With Git, there is no real equivalent, since it has no sequence numbers for
> anything, every object being identified by its SHA-1 hash, with no sensible
> ordering at all.

Mercurial has a very slight edge here, in that as well as the hash-based 
changeset IDs, it also has a sequential changeset number. The output of 
'hg log' from a trivial demo repository:

changeset:   2:1af3be9856b9
tag:         tip
user:        admin@initech-dev-19
date:        Thu May 26 15:28:30 2011 +0100
summary:     keeping things up to daet

changeset:   1:d2a7ea8727e4
user:        admin@initech-dev-19
date:        Thu May 26 15:26:06 2011 +0100
summary:     update

changeset:   0:a9f4a5b5e4ca
user:        admin@initech-dev-19
date:        Thu May 26 15:25:54 2011 +0100
summary:     first commit

The 'changeset' lines have the revision number, a colon, and the first 
twelve characters of the changeset ID.

The problem with this is that the numbers record the sequence in which 
changesets were added to the current repository - which in the presence of 
commits on multiple machines (ie for any realistic development team) means 
that the numbers won't be the same in different repositories.

For example, if i create a repository and make an initial commit, the 
first changeset gets number 0. If you pull it from me, it will be 0 in 
your repository too. If i do some work and commit it, my new changeset 
will have number 1. If you do some work and commit, your new changeset 
will also have number 1. When you then pull from me, my changeset will 
have number 2.

So, numbers are useful and meaningful, but only in the context of one 
repository.

If you have a single 'golden master' repository from which you cut 
releases, then this may be good enough; you can always relate the number 
to that repository, so a higher number always means a later version.

Failing that, you could use a build number which combines the identity of 
the repository and the changeset number, but that's rather less useful.

Alternatively, you have some sort of master repository, and give it a 
post-changegroup hook that tags every push with a tag constructed from the 
local changeset number.

> But if you have tagged some prior revision, the command “git describe --
> tags” will generate a string of the form
>
>    <tag>-<nr revisions since>-g<part of current revision hash>
>
> For example, looking at the current dvdauthor source tree, the command
> returns this
>
>    0.7.0-18-g6143744
>
> which means it has been 18 commits since the one I released (and tagged) as
> “0.7.0”, and the hash for the last commit begins with 6143744.

In the absence of a master repository, that is substantially more helpful 
than what you can do with Mercurial

A bit of googling reveals that someone ported this to Mercurial as an 
extension, but it seems to have died.

> Exercise for the reader: what happens if you don’t specify “--tags”?

States it as revisions from the initial checkin?

tom

-- 
Batman always wins

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

git-describe Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-05-25 22:14 +1200
  Re: git-describe Tom Anderson <twic@urchin.earth.li> - 2011-05-26 17:59 +0100
    Re: git-describe Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-05-27 11:00 +1200
      Re: git-describe Tom Anderson <twic@urchin.earth.li> - 2011-05-27 23:51 +0100
        Re: git-describe Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-05-28 14:34 +1200
          Re: git-describe Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-05-27 23:21 -0400
            Re: git-describe Lawrence D'Oliveiro <ldo@geek-central.gen.new_zealand> - 2011-05-28 16:29 +1200
              Re: git-describe Tom Anderson <twic@urchin.earth.li> - 2011-05-29 00:33 +0100
          Re: git-describe Tom Anderson <twic@urchin.earth.li> - 2011-05-29 00:25 +0100

csiph-web