Pike
Pike

Reputation: 166

hash collisions between hg/mercurial and git?

I'm pondering to use the same db model to represent git and hg changesets in a mixed set up. That'd allow me to just store git-vs-hg in the repos.

I'm wondering, are there known overlaps between the hg and git algorithms that'd make conflicts between the two significantly more likely than within hg and git separately?

Upvotes: 2

Views: 132

Answers (1)

andrew cooke
andrew cooke

Reputation: 46862

you will be fine.

they both (currently) use SHA-1. since the hash exposed by the API is just the hex representation of that, there can be no additional risk - this follows directly from the properties of a cryptographic hash.

in other words - it doesn't matter what processing is used before the hash is calculated. once the data go through the hash they become "uniform" in a statistical sense. processing afterwards might affect things, but, as far as i know, there is no post-processing (SHA-1 generates 160 bits or 20 bytes - both git and mercurial hashes are 40 character hex strings, as expected)

Upvotes: 4

Related Questions