Skip to contentSkip to conversation

Suggestion: drop 'g' in git-describe suffix

DISCUSSION Han-Wen Nienhuys 8 participants 19 messages Aug 11, 2016

lore
Share & tools
lore
#0 lore raw

hi,

the convention to use a 'g' in the output of git-describe, eg.

  [lilydev@haring lilypond]$ git describe --abbrev=39
  lilypond_2_9_7-g47778d2297276484c861fc7536da13feb2d5fe8

is confusing: the g is also a hex digit, and without reading the manual carefully, you'd think this is the commit g4777.

Proposal: why not use

tag#sha1

or some other non-hex character.

Signature · 1 line
 Han-Wen Nienhuys - [email protected] - http://www.xs4all.nl/~hanwen
#1 lore raw
Quoted 9 lines · Han-Wen Nienhuys

hi,

the convention to use a 'g' in the output of git-describe, eg.

  [lilydev@haring lilypond]$ git describe --abbrev=39
  lilypond_2_9_7-g47778d2297276484c861fc7536da13feb2d5fe8
Quoted 8 lines

is confusing: the g is also a hex digit, and without reading the manual carefully, you'd think this is the commit g4777.

Proposal: why not use

tag#sha1

or some other non-hex character.

g is not a hex digit, hex is 0-f ??

In current versions of git, this whole string is also a valid name for the commit ie you can do the following:

	git show lilypond_2_9_7-g47778d2297276484c861fc7536da13feb2d5fe8

-apw

#2 lore raw

Andy Whitcroft escreveu:

Quoted 4 lines
Quoted 1 line

or some other non-hex character.

g is not a hex digit, hex is 0-f ??

Yes of course; silly me. Still I think it would be clearer if it used a non-alphabet char, eg.

tag+sha1

to separate the tag and the committish.

Signature · 1 line
 Han-Wen Nienhuys - [email protected] - http://www.xs4all.nl/~hanwen
#3 lore raw
Quoted 6 lines · Han-Wen Nienhuys

Andy Whitcroft escreveu:

Quoted 4 lines
Quoted 1 line

or some other non-hex character.

g is not a hex digit, hex is 0-f ??

Quoted 6 lines

Yes of course; silly me. Still I think it would be clearer if it used a non-alphabet char, eg.

tag+sha1

to separate the tag and the committish.

Well there is a non-alphabet character in there, a minus (-). The g prefix on the sha1 _fragment_ it to indicate that it is in fact a truncated sha1, not a complete one. If you want the complete clean sha1 this is not the way to get it?

#4 lore raw

Andy Whitcroft escreveu:

Quoted 8 lines
Quoted 7 lines · Han-Wen Nienhuys

Andy Whitcroft escreveu:

Quoted 3 lines
Quoted 1 line

or some other non-hex character.

g is not a hex digit, hex is 0-f ??

Yes of course; silly me. Still I think it would be clearer if it used a non-alphabet char, eg.

Quoted 7 lines
Quoted 3 lines

tag+sha1

to separate the tag and the committish.

Well there is a non-alphabet character in there, a minus (-). The g prefix on the sha1 _fragment_ it to indicate that it is in fact a truncated sha1, not a complete one.

is this policy documented somewhere? None of the tools understand it.

[lilydev@haring git]$ git describe
v1.4.3.3-g1e1f76e
[lilydev@haring git]$ git show g1e1f76e
fatal: ambiguous argument 'g1e1f76e': unknown revision or path not in the working tree. Use '--' to separate paths from revisions

My suggestion is to use

v1.4.3.3+1e1f76e

here.

Quoted 2 lines

If you want the complete clean sha1
this is not the way to get it?

Signature · 1 line
 Han-Wen Nienhuys - [email protected] - http://www.xs4all.nl/~hanwen
#5 lore raw
Quoted 10 lines · Han-Wen Nienhuys

Andy Whitcroft escreveu:

Quoted 9 lines
Quoted 4 lines · Han-Wen Nienhuys

tag+sha1

to separate the tag and the committish.

Well there is a non-alphabet character in there, a minus (-). The g prefix on the sha1 _fragment_ it to indicate that it is in fact a truncated sha1, not a complete one.

I think it is there to indicate it is a git commit sha1.

Quoted 10 lines

is this policy documented somewhere? None of the tools understand it.

[lilydev@haring git]$ git describe
v1.4.3.3-g1e1f76e
[lilydev@haring git]$ git show g1e1f76e
fatal: ambiguous argument 'g1e1f76e': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions

Use the complete output of describe:

$ git show v1.4.3.3-g1e1f76e

or the abbrev sha1:

$ git show 1e1f76e
Quoted 3 lines

My suggestion is to use

   v1.4.3.3+1e1f76e

My suggestion is to use:

v1.4.3.3-git1e1f76e

to make clear that it is a git revision version.

One problem I see with this scheme (either 'g', 'git' of '+') is that it does not provide an increasing version number, even for fast-forwarding commits. Then it is not useful as a package version number (deb or rpm). I've already seen deb packages with version+git20061010. One possibility could be to add the number of commits between the tag and the commit as:

v1.4.3.3-git12g1e1f76e

to provide a weak ordering for fast-forwarding commits. What do you thing?

#6 lore raw

Santi Béjar escreveu:

Quoted 10 lines

One problem I see with this scheme (either 'g', 'git' of '+') is that it does not provide an increasing version number, even for fast-forwarding commits. Then it is not useful as a package version number (deb or rpm). I've already seen deb packages with version+git20061010. One possibility could be to add the number of commits between the tag and the commit as:

v1.4.3.3-git12g1e1f76e

to provide a weak ordering for fast-forwarding commits. What do you thing?

Is that number well defined if you merge branches in between?

I'd prefer

v1.4.3.3+git-12-1e1f76e

or similar. Pasting together words without separator is bad for readability.

#7 lore raw
Quoted 12 lines · Han-Wen Nienhuys

Santi Béjar escreveu:

Quoted 10 lines

One problem I see with this scheme (either 'g', 'git' of '+') is that it does not provide an increasing version number, even for fast-forwarding commits. Then it is not useful as a package version number (deb or rpm). I've already seen deb packages with version+git20061010. One possibility could be to add the number of commits between the tag and the commit as:

v1.4.3.3-git12g1e1f76e

to provide a weak ordering for fast-forwarding commits. What do you thing?

Quoted 7 lines

Is that number well defined if you merge branches in between?

I'd prefer

   v1.4.3.3+git-12-1e1f76e

or similar. Pasting together words without separator is bad for readability.

Or even IMVHO better:

    v1.4.3.3+12--1e1f76e

or something like that. v1.4.3.3+12 part meaning that v1.4.3.3 is 12 ancestor in direct shortest direct line, or that v1.4.3.3+12 is 12 generations away from v1.4.3.3.

Of course that is _costly_ to confitm that, and v1.4.3.3+12 might mean more than one revision in presence of branching points, especially that there is no equivalent of "first parent" to distinguish like in case of v1.4.3.3~12

Signature · 3 lines
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
#8 lore raw
In reply to Han-Wen Nienhuys
Quoted 8 lines · Han-Wen Nienhuys

Santi Béjar escreveu:

Quoted 7 lines

One problem I see with this scheme (either 'g', 'git' of '+') is that it does not provide an increasing version number, even for fast-forwarding commits. Then it is not useful as a package version number (deb or rpm). I've already seen deb packages with version+git20061010. One possibility could be to add the number of commits between the tag and the commit as:

Quoted 5 lines
Quoted 3 lines

v1.4.3.3-git12g1e1f76e

to provide a weak ordering for fast-forwarding commits. What do you thing?

Is that number well defined if you merge branches in between?

Yes.

$ git-rev-list 1e1f76e ^v1.4.3.3 | wc -l
Quoted 9 lines

I'd prefer

   v1.4.3.3+git-12-1e1f76e

or similar. Pasting together words without separator is bad for readability.

--
Han-Wen Nienhuys - [email protected] - http://www.xs4all.nl/~hanwen

#9 lore raw
In reply to Santi Béjar
Quoted 48 lines · Santi Béjar
Quoted 10 lines · Han-Wen Nienhuys

Andy Whitcroft escreveu:

Quoted 9 lines
Quoted 4 lines · Han-Wen Nienhuys

tag+sha1

to separate the tag and the committish.

Well there is a non-alphabet character in there, a minus (-). The g prefix on the sha1 _fragment_ it to indicate that it is in fact a truncated sha1, not a complete one.

I think it is there to indicate it is a git commit sha1.

Quoted 10 lines

is this policy documented somewhere? None of the tools understand it.

[lilydev@haring git]$ git describe
v1.4.3.3-g1e1f76e
[lilydev@haring git]$ git show g1e1f76e
fatal: ambiguous argument 'g1e1f76e': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions

Use the complete output of describe:

$ git show v1.4.3.3-g1e1f76e

or the abbrev sha1:

$ git show 1e1f76e
Quoted 3 lines

My suggestion is to use

   v1.4.3.3+1e1f76e

My suggestion is to use:

v1.4.3.3-git1e1f76e

to make clear that it is a git revision version.

One problem I see with this scheme (either 'g', 'git' of '+') is that it does not provide an increasing version number, even for fast-forwarding commits. Then it is not useful as a package version number (deb or rpm). I've already seen deb packages with version+git20061010. One possibility could be to add the number of commits between the tag and the commit as:

Quoted 3 lines

v1.4.3.3-git12g1e1f76e

to provide a weak ordering for fast-forwarding commits. What do you thing?

I think you'll restart the 1.2.3.4 versioning is better 'debate' again!

Surly if things are being pushed into a .deb or .rpm we should be using a real release version. We should be tagging that. If the project is not providing release number, there is nothing stopping you from tagging them yourself in your copy of the repository and using your tag. you could use like 'unofficial-N' where N increments in the way you want.

#10 lore raw
Quoted 8 lines · Andy Whitcroft
Quoted 7 lines · Santi Béjar

One problem I see with this scheme (either 'g', 'git' of '+') is that it does not provide an increasing version number, even for fast-forwarding commits. Then it is not useful as a package version number (deb or rpm). I've already seen deb packages with version+git20061010. One possibility could be to add the number of commits between the tag and the commit as:

Quoted 5 lines
Quoted 3 lines

v1.4.3.3-git12g1e1f76e

to provide a weak ordering for fast-forwarding commits. What do you thing?

I think you'll restart the 1.2.3.4 versioning is better 'debate' again!

Sorry, I don't undestand this.

Quoted 5 lines

Surly if things are being pushed into a .deb or .rpm we should be using a real release version. We should be tagging that. If the project is not providing release number, there is nothing stopping you from tagging them yourself in your copy of the repository and using your tag. you could use like 'unofficial-N' where N increments in the way you want.

And where do you store this tag? It is an upstream commit and you just refer to this. With the unofficial-N there is no way to know which upstream commit you are refering without having access to the git repository of the packager .

#11 lore raw
Quoted 9 lines · Santi Béjar
Quoted 8 lines · Andy Whitcroft
Quoted 7 lines · Santi Béjar

One problem I see with this scheme (either 'g', 'git' of '+') is that it does not provide an increasing version number, even for fast-forwarding commits. Then it is not useful as a package version number (deb or rpm). I've already seen deb packages with version+git20061010. One possibility could be to add the number of commits between the tag and the commit as:

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

v1.4.3.3-git12g1e1f76e

to provide a weak ordering for fast-forwarding commits. What do you

thing?

I think you'll restart the 1.2.3.4 versioning is better 'debate' again!

Sorry, I don't undestand this.

There was a long running debate between sha1's and version 'numbers' 1.2.3.4 for each revision.

Quoted 11 lines
Quoted 6 lines

Surly if things are being pushed into a .deb or .rpm we should be using a real release version. We should be tagging that. If the project is not providing release number, there is nothing stopping you from tagging them yourself in your copy of the repository and using your tag. you could use like 'unofficial-N' where N increments in the way you want.

And where do you store this tag? It is an upstream commit and you just refer to this. With the unofficial-N there is no way to know which upstream commit you are refering without having access to the git repository of the packager .

Yes that is completly true, but its normally the packer who is doing the bug fixing of the .deb when its broken. The key problem is you need your numbering to be stable. The only guarenteed stable thing is the sha1, tags can change. IMHO you should be including the full sha1 in the --version output and the package descript, whatever versioning you are using on the .deb itself.

That said I guess it would be pretty easy to come up with something to count the number of commits since the last valid tag, something like that below. Might not be pretty, nor so easy to turn back into a commit of course.

-apw

#!/bin/sh

let n=0

git log --pretty=one "$@" | \
        awk '{print $1}' | \
        git name-rev --tags --stdin | \
{
        while read sha1 name
        do
                if [ "$name" != "" ]; then
                        echo "$sha1 $name $n"
                        exit 0
                fi
                let "n=n+1"
        done
        echo "- unknown 0"
        exit 1
#12 lore raw
In reply to Santi Béjar
Quoted 25 lines · Santi Béjar
Quoted 10 lines · Han-Wen Nienhuys

Andy Whitcroft escreveu:

Quoted 9 lines
Quoted 4 lines · Han-Wen Nienhuys

tag+sha1

to separate the tag and the committish.

Well there is a non-alphabet character in there, a minus (-). The g prefix on the sha1 _fragment_ it to indicate that it is in fact a truncated sha1, not a complete one.

I think it is there to indicate it is a git commit sha1.

Quoted 10 lines

is this policy documented somewhere? None of the tools understand it.

[lilydev@haring git]$ git describe
v1.4.3.3-g1e1f76e
[lilydev@haring git]$ git show g1e1f76e
fatal: ambiguous argument 'g1e1f76e': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions

Quoted 2 lines

Use the complete output of describe:

$ git show v1.4.3.3-g1e1f76e

this one doesn't work for me in my repository.

$ git-describe
release_1_22_v0.7-g85eb121
$ git show release_1_22_v0.7-g85eb121
fatal: ambiguous argument 'release_1_22_v0.7-g85eb121': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions
Quoted 2 lines

or the abbrev sha1:

$ git show 1e1f76e

this one works with my repository

$ git show 85eb121

i use git version 1.4.2.rc2.g2686c

(that was next branch of git one or two days ago or so..)

it would be great to let the full output of git describe work as well.

Sincerly

#13 lore raw

Hi,

Quoted 4 lines · Nicolas Vilz 'niv
Quoted 2 lines

Use the complete output of describe:

$ git show v1.4.3.3-g1e1f76e

this one doesn't work for me in my repository.

You need at least v1.4.3-rc1^0~69 (v1.4.2.1-g7dd45e1) for this. You indicated in your email that your version is older.

Ciao,
Dscho

#14 lore raw
Quoted 9 lines · Johannes Schindelin

Hi,

Quoted 3 lines · Nicolas Vilz 'niv
Quoted 2 lines

Use the complete output of describe:

$ git show v1.4.3.3-g1e1f76e

this one doesn't work for me in my repository.

You need at least v1.4.3-rc1^0~69 (v1.4.2.1-g7dd45e1) for this. You indicated in your email that your version is older.

strange, from time to time i have to delete the whole git repository, not to get stuck on old revisions. Now with a fresh repository i get a current revision and with this version, it works.

Thx for help

#15 lore raw
In reply to Han-Wen Nienhuys
Quoted 26 lines · Han-Wen Nienhuys

Andy Whitcroft escreveu:

Quoted 8 lines
Quoted 7 lines · Han-Wen Nienhuys

Andy Whitcroft escreveu:

Quoted 3 lines
Quoted 1 line

or some other non-hex character.

g is not a hex digit, hex is 0-f ??

Yes of course; silly me. Still I think it would be clearer if it used a non-alphabet char, eg.

Quoted 7 lines
Quoted 3 lines

tag+sha1

to separate the tag and the committish.

Well there is a non-alphabet character in there, a minus (-). The g prefix on the sha1 _fragment_ it to indicate that it is in fact a truncated sha1, not a complete one.

is this policy documented somewhere? None of the tools understand it.

[lilydev@haring git]$ git describe
v1.4.3.3-g1e1f76e
[lilydev@haring git]$ git show g1e1f76e
fatal: ambiguous argument 'g1e1f76e': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions

Quoted 5 lines

My suggestion is to use

v1.4.3.3+1e1f76e

here.

The 'whole' thing is valid as an object reference:

apw@pinky$ git describe
v1.4.3.3-g8cf249b
apw@pinky$ git show v1.4.3.3-g8cf249b
commit 8cf249b755c257ea19100b888ac612e601cdf96b
Merge: 15c3ffb... fa438a2...
[...]
#17 lore raw
In reply to Andy Whitcroft

Dear diary, on Thu, Nov 02, 2006 at 11:37:31AM CET, I got a letter where Andy Whitcroft <[email protected]> said that...

Quoted 2 lines

The g prefix on the sha1 _fragment_ it to indicate that it is in fact a truncated sha1, not a complete one.

I think it's rather to indicate that it is a sha1 at all.

Signature · 4 lines
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
#18 lore raw
Quoted 7 lines · Petr Baudis

Dear diary, on Thu, Nov 02, 2006 at 11:37:31AM CET, I got a letter where Andy Whitcroft <[email protected]> said that...

Quoted 2 lines

The g prefix on the sha1 _fragment_ it to indicate that it is in fact a truncated sha1, not a complete one.

I think it's rather to indicate that it is a sha1 at all.

Frankly, I've never understood the 'g' prefix at all. I don't use git-describe much, but some people have sent me things with this 'g' on the front and every time I've received that I was annoyed to find the commit identifier they sent didn't work until I manually removed it.

It's definitely never provided any useful semantic information to me.

-Carl

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQBFSfZf6JDdNq8qSWgRAjZlAJ0cE0HLFP+iI5YeuXLEIYw5WQM4bgCgkd6F P9i80UHDons3D/asROElPVY=
=fMCo
-----END PGP SIGNATURE-----