Archives
2010 June 2010 May 2010 February 2010 January 2009 October 2009 September 2009 April 2009 February 2009 January 2008 July 2008 May 2008 April 2008 March
Welcome back.
» forget me
Subscribe:
Login:
|
| Sequential Revision Numbers in Git |
| Sun April 19th, 2009 at 8:11 AM PDT |
I've been using Git for a while now on some of my projects, and find it utterly fantastic. It's faster than any SCM I've ever seen, and makes branches a snap. BAM!
But one thing has always annoyed me about it (well, other than being forced to lug the whole repo around when lots of times that isn't necessary):
Revision numbers are a nasty 40-byte hex string.
What good is that? I'm sure it's ultra-useful to the computer, but it tells me absolutely nothing about the given commit. I like Subversion's method, where commits start from 1 and go upward sequentially.
Well, today I figured out how to convert Git's 40-byte hashes into useful revision numbers. I actually figured this out for the benefit of the integrated SCM viewer and issue tracker software I've been working on, but have come to use it a lot outside of there.
Here's a handy shell script to convert Git SHA1 object names into sequential commit numbers:
git rev-list --reverse HEAD | grep -n $rev | cut -d: -f1
where $rev is the Git commit hash. Of course, you must be in your Git working directory for the command to work.
In my extremely informal experiments, the number printed by that command seems to be consistent across multiple distributed copies of the same repository, but merges may affect it. I don't know. But if you have a central repository, the number will never change for a given commit, and that's all that's really important.
Hope this helps someone!
_WRF
Edit: Here's a nice addition to your .bashrc:
function git-rev-number() { if [[ $1 == "" ]]; then echo "usage: git-rev-number " return 1 fi number=`git rev-list --reverse HEAD | grep -n $1 | cut -d: -f1` if [[ $number == "" ]]; then echo "commit not found" return 1 else echo $number fi return 0 }
|
|
» (1 comment)
(make a comment)
|
| New Apartment: Little Italy |
| Thu April 9th, 2009 at 9:18 AM PDT |
Last week I packed up and moved all my stuff from the old apartment in Pilsen to a new one in Little Italy, and the place is finally starting to feel like home. The cable just got connected a few minutes ago, and I'm back online again along with the website.
I had to leave the quiet niceness of Pilsen because I couldn't afford the utilities in the old apartment. In January alone we paid over $500 in heating and electric, and that's just freaking insane. The place was actually too big and open -- there was nothing to keep the warm air in.
The new apartment is in an old six unit building in Little Italy, right by school. It's a cozy 3-bedroom flat in the front of the building. I'm the only one living here right now -- my roommate is currently living in the UIC dorms still, and will be joining me in a few months, and we hope to have a third roommate arranged by then as well.
As soon as I finish unpacking all my stuff, I'll take and post some pictures. It's a nice place, I'm going to like it here.
|
|
» (0 comments)
(make a comment)
|
[Page 1] [All One Page]
|
| Shoutbox |
Anonymous:
lonely shoutbox :(
Mon April 7th, 2008 at 5:09 PM PDT
|
Anonymous:
hello
Mon April 7th, 2008 at 5:12 PM PDT
|
Anonymous:
o hai
Mon April 28th, 2008 at 12:31 PM PDT
|
CHIZUBAGA:
I CAN HAZ CHIZUBAGA!!!!!!!
Wed January 20th, 2010 at 12:58 PM PST
|
Not Jeremy:
o hai remember when i threw hot sauz in yer eye. lulz
Thu January 28th, 2010 at 11:28 AM PST
|
JEREMY:
MOAR NAPKINS DURR HURR
Thu February 11th, 2010 at 9:33 AM PST
|
Shoutbox:
I wuz on a DAtZ.. haffing chizubaga!! Om nom nom nom!!
Wed May 26th, 2010 at 1:04 PM PDT
|
Totally not anyone you know:
Problem?
Thu June 3rd, 2010 at 2:09 PM PDT
|
Random Randomstein:
Shitpickle.
Fri June 11th, 2010 at 6:04 PM PDT
|
|