project-navigation
Personal tools

Author Topic: "git describe" or svn revision numbering style  (Read 7494 times)

Offline Punkie

  • Rookie
  • ***
  • Posts: 20
    • View Profile
"git describe" or svn revision numbering style
« on: November 19, 2010, 10:51:55 pm »
It is kind of hard to refer to a particular revision in git. Not only are they 40 chars long (although the first 7 are quasi unique)  but they are not a monotone increasing sequence. As a result ppl are not referring to version numbers anymore and it is hard for developers to remember a version or to know where in the timeline it is situated. But behold, numerous ppl value those same properties and they suggest the following

"git describe" as explained here and here.
In short what i understood of it:
Code: [Select]
[punkie@fed ufoai]$ git describe --tags
ufoai_2.1-dev1-27183-g3be0bf3
This revision is 27183 commits seperated from the last tag (ufoai_2.1-dev1) which is identified by the first 7 chars "g3be0bf3". In other words, we can identify this revision as 27183 though we can reset the counter whenever we can. Via a hook this string can be added to the log.

Offline Muton

  • Sergeant
  • *****
  • Posts: 496
    • View Profile
Re: "git describe" or svn revision numbering style
« Reply #1 on: November 20, 2010, 07:57:53 am »
Why not use unixtime
git log -1 --pretty=format:%ct

git log --since="1284280485" --until="1284280485"
will show you the last commit the build is based on

date --universal -ud @1284280862
convert sec to human readable format

.)You have growing values
.)You can recalculate the builddate
.)No extra work need to be done

Offline Punkie

  • Rookie
  • ***
  • Posts: 20
    • View Profile
Re: "git describe" or svn revision numbering style
« Reply #2 on: November 20, 2010, 11:07:02 am »
How would you go from the date to a (single) hash/revision number (not a range) that git understand?

For "git describe" this is supported by git as the output is a valid revision number and thus can be used with other commands
Code: [Select]
#the revision
git checkout ufoai_2.1-dev1-27183-g3be0bf3
# list between 2 revisions before and the last
git rev-list HEAD ufoai_2.1-dev1-27183-g3be0bf3~2

Offline Muton

  • Sergeant
  • *****
  • Posts: 496
    • View Profile
Re: "git describe" or svn revision numbering style
« Reply #3 on: November 20, 2010, 12:03:00 pm »
> How would you go from the date to a (single) hash/revision number (not a range) that git understand?

git log --since="1290243726" --until="1290243726"

will return 2 commits
but only the commit time is different
the push time is the same (git stores the time in unix format)
If someone is pushing n commits at the same time
and you do an update
than you'll receive both commits

Tracing a bug means reverting commits from your local source
and in that case you know the hash


commit 51bc5eaaac472c0854ec34dbbdcf5b92982f471a
Author: Martin Gerhardy <tlh2000@users.sourceforge.net>
Date:   Sat Nov 20 10:01:43 2010 +0100

    * renamed functions in entity Observer class

commit 751f6534b9132255aee28d155312aa8c547e446a
Author: Martin Gerhardy <tlh2000@users.sourceforge.net>
Date:   Sat Nov 20 09:53:15 2010 +0100

    * further merges and improvements for the entity inspector



I would prefer
git describe --tags
ufoai_2.1-dev1-27253-g51bc5ea
commit 27253 is very handy
but
git rev-list HEAD ufoai_2.1-dev1-27253-g3be0bf3~2
prints only a lot of hashes

How to find the hash for commit 27252 ???

Offline Punkie

  • Rookie
  • ***
  • Posts: 20
    • View Profile
Re: "git describe" or svn revision numbering style
« Reply #4 on: November 20, 2010, 01:10:44 pm »
IANAGitExpert (I Am Not A Git Expert) and currently i dont have access to git.

AFAIK You dont need to look up the hash/sha1 because you can use the describe string as if it was a hash.
You can get from a sha1 to a tag decribe like experssion
Code: [Select]
% git name-rev 33db5f4d9027a10e477ccf054b2c1ab94f74c85a
33db5f4d9027a10e477ccf054b2c1ab94f74c85a tags/v0.99^0~940
The other way around? Got to be a way I suppose.
git-show ??
or maybe a shell function is needed, like
git log ufoai_2.1-dev1-27253-g51bc5ea | egrep "^commit "

For functions like rev-list that return sha1 you can make a lookupscript that processes the output
foreach s sha1 (with egrep "^commit "?)
d=`git name-rev $e`
sed -e "s/$e/$d/"
...
« Last Edit: November 20, 2010, 01:28:43 pm by Punkie »