How short can Git abbreviate? (2013)
blog.cuviper.com
blog.cuviper.com
$ git rev-list --all --abbrev=0 --abbrev-commit | awk '{ a[length] += 1 } END { for (len in a) print len, a[len] }'
5 84
6 692222
7 527029
8 43802
9 2791
10 181
11 8<https://sqlite.org/src/hash-collisions>
and fossil's own can be seen at:
In general, it's a made up one time value. In this case, it satisfies an additional property.
>6 character prefix: less than a second
>8 character prefix: in the order of one or more minutes
No affiliation with this, but I tested it, and it was fast!
The use case I ran into was an initial + updated "dictionary of values" use case. Imagine: `{ "foo:bar:baz": 1.23, "bleep:bloop:blah": 4.56, ...etc.. }`.
I wanted to send the first batch as a "full dictionary", and then send updated batches as: `{ "aa": 1.23, "bb": 4.56 }` whereby the client should already be able to reverse: `aa` => `foo:bar:baz`, and `bb`: `bleep:bloop:blah` since they could md5 the original key, and then match that to the "compressed" unique key.
For the interview question, asking "what's the minimum unique prefix length", and exactly in the context of "how short can you abbreviate a git commit" was an excellent, low-friction, easily understandable problem.
I was shocked when the initial GPT-3 nailed the naive implementation, and in retrospect, not-surprised when its superficially-correct "optimized" solution was only superficially correct. ;-) Better than 50% of the interviewees I'd asked this question of.