How would Git handle a SHA-1 collision on a blob?

This probably never happened in the real-world yet, and may never happen, but let’s consider this: say you have a git repository, make a commit, and get very very unlucky: one of the blobs ends up having the same SHA-1 as another that is already in your repository. Question is, how would Git handle this? Simply fail? Find a way to link the two blobs and check which one is needed according to the context?

More a brain-teaser than an actual problem, but I found the issue interesting.

6 s
6

Leave a Comment