I have done a test in version 2.18 to test how git handle hash collision: 1、I commit pdf file 'shattered-1.pdf' into my local repo. the generated hash for the file is '9aaa145ccd24ef760cf31c74d8f7ca1a2e47b0' in dir 'ba' 2、I change the content of '9aaa145ccd24ef760cf31c74d8f7ca1a2e47b0' to store some other content 3、then i commit another file named 'shattered-3.pdf' which is exactly the same as original 'shattered-1.pdf' to my local repo.
I expect git to reject my commit because the newly generated object have an duplicate hash with and old object but the content is different. But git accept my commit supprisingly.I checkout 'shattered-3.pdf' in another computer and the content is completely different with the one i meant to commit. Git should reject my commit to avoid such strange behaviour. When we create a new object and the hash collides with an old object in our repo, we can compare the object content byte by byte, if they are exactly the same, we can use that old object directly, else we just stop creating the object with an error. Out repo will not be corrupted !! -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
