On 1/13/23 17:27, Konstantin Ryabitsev wrote:
The answer is, unhelpfully, "because that's how git works." Every commit is a standalone object that references the previous commit, plus includes hashes of all trees, and those include hashes of all blobs. SHA-1 was picked because of its speed and the fact that it guarantees an extremely low potential for collisions (even better with SHA256). As a side-effect, it's easy to calculate the integrity of the entire tree, including its history, by verifying its hashes (this is what git fsck does).
Same thing can be said for CRC-XXX. Just some magic CPU instructions and we're good. You don't even need a library.
--HPS