git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: --abbrev-commit gives longer hash than necessary

From
Bryan Turner <bturner@atlassian.com>
Date
Jun 30, 2016, 20:14 UTC
Message-ID
<CAGyf7-E0VbkCC29y=OuNHL5_KA=qoXEsrChxvXcGmfZ_CjTzqQ@mail.gmail.com>
In-Reply-To
<20160630193845.TbelqPPHx%steffen@sdaoden.eu>
Steffen,

Git commands generally have a 7 character minimum by default when abbreviating hashes, even if fewer characters are still (currently) unique. Per the documentation:

   core.abbrev
       Set the length object names are abbreviated to. If unspecified,
       many commands abbreviate to 7 hexdigits, which may not be enough
       for abbreviated object names to stay unique for sufficiently long
       time.

You may be able to set core.abbrev to a smaller value to get even shorter hashes, but the shorter you go the more likely you are to find once-unique hashes no longer are, as your repository grows over time. The default isn't just about what's likely to be unique now; it's about what's likely to stay unique for a period of time.

Hope this helps! Bryan Turner

On Thu, Jun 30, 2016 at 12:38 PM, Steffen Nurpmeso <steffen@sdaoden.eu> wrote:
Show 38 quoted lines
> Hello, for your possible interest.
>
> For some time (currently with 2.9.0) know see that a single commit
> gives a longer hash than necessary, even though there is no
> ambiguity:
>
>   ?0[steffen@wales ]$ git longca|
>   awk 'BEGIN{l7=0;l8=0}\
>     /^[[:alnum:]]{7} /{++l7;next}\
>     /^[[:alnum:]]{8} /{++l8;print}\
>   END{print "L7 " l7 " L8 " l8}'
>   786d0c9c [mimepipe.2] send.c:sendpart(): force iconv(3)+ for TEXT part handlers..
>   L7 3364 L8 1
>
> So it is only this single commit.. but why?
>
>   ?0[steffen@wales ]$ git long1 786d0c9
>   786d0c9c [mimepipe.2] send.c:sendpart(): force iconv(3)+ for TEXT part handlers..
>   ?0[steffen@wales ]$ git long1 786d0c
>   786d0c9c [mimepipe.2] send.c:sendpart(): force iconv(3)+ for TEXT part handlers..
>   ?0[steffen@wales ]$ git long1 786d0
>   786d0c9c [mimepipe.2] send.c:sendpart(): force iconv(3)+ for TEXT part handlers..
>   ?0[steffen@wales ]$ git long1 786d
>   786d0c9c [mimepipe.2] send.c:sendpart(): force iconv(3)+ for TEXT part handlers..
>
> Not really ambiguous:
>
>   ?0[steffen@wales ]$ git long|cut -f1 -d' '|grep ^786
>   786d0c9c
>   786f219
>
> Ciao!
>
> --steffen
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous: Steffen NurpmesoNext: Steffen Nurpmeso
Message 2 of 5 in “--abbrev-commit gives longer hash than necessary”
  1. Steffen NurpmesoJun 30, 2016
  2. Bryan TurnerJun 30, 2016
  3. Steffen NurpmesoJul 1, 2016
  4. Jeff KingJul 1, 2016
  5. Steffen NurpmesoJul 1, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.