4 ms·
This doesn't make sense in a patch-based VCS, where you can at best verify the integrity of individual deltas, but where there isn't a repository state that you
by rbehrends 11y ago
This doesn't make sense in a patch-based VCS, where you can at best verify the integrity of individual deltas, but where there isn't a repository state that you can hash (cryptographically or otherwise) to begin with.
- dchest 11y agoIf integrity of deltas is not important, why use SHA-1? Why not MD5? ;) There are modern cryptographic hash functions, such as BLAKE2, that are faster than it, and I'm not even talking about non-cryptographic functions, which are many times faster.
- rbehrends 11y agoBecause in the end it doesn't matter much, other than that the probability of accidental collisions is low? Speed doesn't matter, because it's primarily used to look up a file, and I/O will dominate that. SHA-1 is known to work (Git, Mercurial), so what's the point in overengineering this particular implementation detail? The integrity of deltas doesn't matter much because if you have a process for maliciously inserting a falsified patch, you can generally also simply insert a genuine patch (where it's trivial to get even the most complicated cryptographic checksum right) that will be combined with the rest (because the state of the repository is the combination of the patches in it, and whether you replace one or add a different one is largely irrelevant in this context).