2

Suppose there is a bug in git causing developers commit incorrect changes to the repository so that sources checked out do not match what they have locally under same hash. I understand that hash protects structure of git objects, not checked out sources.

Does git have any safeguard mechanisms that make this less likely than one might think?

sevo
  • 4,559
  • 1
  • 15
  • 31
  • Wouldn't `git diff` or `git status` show it if a file in the working tree didn't match the blob in the git object database? – Thomas Aug 02 '15 at 11:24

1 Answers1

2

That would only happen if there is a SHA1 collision, meaning if the content SHA1 is the same as the one stored in the Git repo.

You can check that by computing yourself the SHA1 of a file you just checked out.
See also "How does git compute file hashes?".

The probability of a collision (two different content for the same SHA1) is very low: see "Why does Git use a cryptographic hash function?".

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250