title: In my repo, how long must the longest hash prefix be to prevent any overlap?
body: <p>The <code>--abbrev-commit</code> flag can be used in conjunction with <code>git log</code> and <code>git rev-list</code> in order to show partial prefixes instead of the full 40-character SHA-1 hashes of commit objects. According to the <a href="https://git-scm.com/book/en/v2/Git-Tools-Revision-Selection#Short-SHA-1" rel="noreferrer">Pro Git book</a>,</p>
  
  <blockquote>
    <p>it defaults to using seven characters but makes them longer if necessary to keep the SHA-1 unambiguous [...]</p>
  </blockquote>
  
  <p>Additionally, short SHAs are at least 4-character long. Still according to the Pro Git book,</p>
  
  <blockquote>
    <p>Generally, eight to ten characters are more than enough to be unique within a project.</p>
    
    <p>As an example, the Linux kernel, which is a pretty large project with over 450k commits and 3.6 million objects, has no two objects whose SHA-1s overlap more than the first 11 characters.</p>
  </blockquote>
  
  <p>Since the length of the longest prefix required to prevent any overlap among all prefix hashes of commit objects (11, in the case of the Linux kernel) is a crude indicator of a repo's size, I'd like to programmatically determine the corresponding quantity in my own local repository. How can I do that?</p>