4 ms·
You know you can shorten the commit hash? For example https://github.com/torvalds/linux/blob/9e02977bfa/kernel/dma/direct.h#L54 https://github.com/torvalds/lin
by bhaak 4y ago
You know you can shorten the commit hash?
For example https://github.com/torvalds/linux/blob/9e02977bfa/kernel/dma/direct.h#L54 https://github.com/torvalds/linux/blob/9e02977bfa/kernel/dma...
I don't find this ugly, it's even very human readable. There's all info in the url that you even can use in the future if GitHub ever goes away.
- madsbuch 4y agoI think this is an elegant point. The URL is clickable and if you clone the repo you are still able to find that exact file from the link alone. Actually, I would use this argument that people should refrain from using url shorteners in papers for this very reason: It is anti-reproducible.
- wang_li 4y agoThe institution or publisher of the paper should maintain their own link shortener if this is something they want to use in the paper.
- dewey 4y agoThat's even worse than using some larger url shortener used by many people. The incentive to keep that one running are way larger than having it as side project of some publisher or university.
- markstos 4y agoA line in an Nginx file is easy to maintain. I’ve been neglecting some Nginx redirects for about 20 years that still work. At some point I did a fairly automated from Apache but otherwise the redirects have been zero maintenance. Notable, they I have broken since I own them!
- faho 4y agoWhat happens when the shortened version becomes ambiguous? For instance that's commit 9e02977bfad006af328add9434c8bffa40e053bb. What happens when someone creates a commit and that happens to have 9e02977bfa-e-something? I'm not even sure what github does here. Does it just refuse to select a commit or give you a list of candidates and you have to check the date (given that your link presumably was unambiguous when you wrote it)?
- anamexis 4y agoWith a 10 digit hash like that, collisions are already extremely unlikely, on the order of 1 in a trillion.
- CodesInChaos 4y agoMost repositories contain more than 2 commits.
- anamexis 4y agoFine, 3 in a trillion.
- CodesInChaos 4y agoYou're right that the chance that two specific 10 digit hashes collide is 1 in a trillion. But the chance of a collision between a specific commit and any other commit goes up linearly, so for the Linux repository it's about 1 million / 1 trillion so 1 in a million. The chance of a collision between a any two commits goes up quadratically (while it's small), and becomes ~50% when you reach the square-root of 1 trillion, i.e. 1 million. So there is a good chance the Linux repository already contains colliding 10 digit hashes, and if they don't exist yet, it'll likely happen during the next couple of years.
- faho 4y agoWhat you are alluding to is the "Birthday problem". https://en.wikipedia.org/wiki/Birthday_problem https://en.wikipedia.org/wiki/Birthday_problem
- CodesInChaos 4y agoI'd rather use a tag, e.g. https://github.com/torvalds/linux/blob/v5.18-rc4/kernel/dma/direct.h https://github.com/torvalds/linux/blob/v5.18-rc4/kernel/dma/...
- nybble41 4y agoA tag can be changed. Barring the extremely unlikely chance of a (non-malicious) hash collision, the commit hash will always identify the specific commit intended by the referrer. As commit hashes ought to be globally unique—the same hash can appear in more than one repo but they will all have the same content and history—GitHub could offer a shorter form of the URL which omits the user and repo names, in exchange for a longer minimum hash length. This would require creating an index of all the commits reachable from public repos, unless they already track that.
- lou1306 4y agoSure, maybe "ugly" is not the best term here. The fact is, the "short" URL you provided is still 74 characters long, while a line in a well-typeset paper is usually 70-80 charecters long. Plus, username and repo in the example are pretty short ("torvalds"+"linux"=13 characters), which is not always the case. So these URLs are definitely hard to put on paper in an aesthetically pleasing way. > There's all info in the url that you even can use in the future if GitHub ever goes away. GitHub could maintain a .git_io file (or whatever) in the repository with the short->long URL mapping, for instance. So, the info would survive GitHub.