4 ms·
It's a bit baffling that git.git suggests using 7-characters commit abbreviations, when they already have collisions for them: $ git log --oneline | cut -c 1
by jwilk 9y ago
It's a bit baffling that git.git suggests using 7-characters commit abbreviations, when they already have collisions for them:
$ git log --oneline | cut -c 1-7 | sort | uniq -c | grep -v ' 1 '
2 1536dd9
2 191f241
2 2e6e3e8
2 3b130ad
2 d53a350
- Cthulhu_ 9y ago7 characters should be enough for most repos, and iirc git can deal with collisions already (so git co 1536dd9 in your example would bring a prompt). How many commits is the repo you're running this on btw?
- pleasecalllater 9y agoSure. And randomly generated UUIDs should not conflict... unless they do, and blow up a huge app in production. Yes, I have experienced that once.
- msingle 9y agothe odds of truly randomly generated UUID's conflicting are .... really really low (see https://en.wikipedia.org/wiki/Universally_unique_identifier#Collisions https://en.wikipedia.org/wiki/Universally_unique_identifier#...). If you had a collision, then the odds are truly opposed to anyone else ever having that problem in the foreseeable future, so thanks for taking the hit for the rest of us!
- deiwin 9y agoWhere did you find the 7 character suggestion? 7 used to be the default suggestion, but the problem of collisions has been acknowledged and dealt with by the git project. Linus himself authored the change that made the abbreviated revision length vary based on the size of the repository: https://github.com/git/git/commit/e6c587c733b4634030b353f4024794b08bc86892 https://github.com/git/git/commit/e6c587c733b4634030b353f402.... Also, the command for creating references to other commits which comes from the git project and is linked to in the article also uses automatic abbreviation length.