Why git hash are 40 characters long while bpy.app.build_hash is 12 characters long?

As stated in the title, I just wonder why ? I get that’s enough to identify a commit on phabricator but is there not a risk than a conflict appear and a commit share their first 12 characters ?

The risk is tiny and the consequences of a collision are not very consequential. The risk of collision can be seen in this table in the row for 12 hex digits: https://en.wikipedia.org/wiki/Birthday_problem#Probability_table

There are currently a bit more than 100,000 commits in the blender git repository. So that chance that any two 12-hex-digit prefixes collide is less than 1 in a million.

And what is the consequence if a collision happens? We might be confused as to which commit a build is from. And the consequence of that? Not much. Maybe some confusion in the minds of a developer trying to debug, but they’d likely be able to figure it out by trying both.

Of course, you still might wonder why not simply use 40 – I guess that is your question. I don’t know. In practice, devs like to use shorter than 40 just for ease of typing them in, but that’s a pretty minor advantage.

1 Like

Thanks you very much for answering my question.

After testing, phabricator deal with the problem and give the list of ambiguous commit if there is collision in the first hex-digit, so no worries :slight_smile:

git log --oneline give a 11 char hash. And as mentioned here, it is not a problem, really.

I personally use 12 long chars (manually trimmed) every time I have to refer to a hash in Blender. Why do I do that? Not sure, if memory serves me well, I used to use 10 chars in the past and realized git log was using 11, so I decided to up my game :wink: