Beautify the Git commit hash (have a look at the commit hashes on the right)
github.com
github.com
$ ./beautify_git_hash.py 0001
I wonder if this somehow increases the probability of a hash collision, if only ever so slightly? In any case, it's a neat hack!The script prints a suggested "git commit --amend" command so don't run the suggestion if you've already pushed the head of your branch.
Using this script too often may force you to specify more characters to get past the prefix being identical on too many commits.
Apart from that, of course you should use sensible prefixes like "0001", "0002", etc. and not use the same prefix for all commits.
[1] 2^(144/2) ~= 7e21
[2] 2^(160/2) ~= 1e24
Apart from that, this is a toy project and by no means meant seriously.
If you find a SHA-1 collision, by any method, you will become very, very famous. It will probably be worth having a broken git repository.
Some small corrections:
The script is able to set 5 digits, not 4. The prefixes in the examples are actually 0001a, 0002a, etc. I added the trailing "a" to make the numbers more readable. Otherwise you would get hashes like 00015... which would look awkward. So I'm using the "a" as a kind of separator.
Also, the script refuses to change timestamps by more than 30 minutes. So changing only the committer timestamp would allow you to set only 2-3 hash digits. That's why I'm also changing the author timestamp, which leads to enough possible combinations to set about 5 hash digits. (Unless you're unlucky, because there's always a rest possibility for failure in this kind of algorithms.)
BTW, this program has been inspired by BitCoin's proof of work concept.
Git already has a mechanism for naming commits, anyway. They are called "tags".
edit: jacknagel points out that they actually didn't go with this after all. Insted: https://github.com/git/git/commit/ffc4b8012d9a4f92ef238ff72c...
__C__
/ \
A---B---D
A is commit number one. D is commit number three. If B is two, then what is C? Assuming you can come up with a consistent view when all the information about the branch topology is available, what about when people have disconnected branches? How do you avoid duplicate generation numbers? If you can't avoid duplicate generation numbers, what's the point of having them? "Fixed in commit 2." Great, which commit 2 did you mean?It often won't uniquely identify commits, but revision numbers in SVN are also sometimes used imprecisely ("oh, it was around R1500"), so I think it would have value.
https://github.com/stephenh/git-central/blob/master/server/p...
(It makes a tag-per-commit; I'm not saying that's necessarily a good idea, but if you really want revision numbers...)
I used to be able to highlight and paste the hashes, now the hash string is "hidden" inside a button where text link would do. Sure, as an ugly, kludgy workaround there is the flash-based "copy to clipboard" button, but that only works with ctrl-v pasting, not the middle mouse button. Good luck pasting that into an xterm. So it's either copy-type or click on the link and find the sha in text form on the resulting page.
I found myself using git log a lot more frequently during the past few days.
> Good luck pasting that into an xterm.
Try Ctrl-Shift-V.