Re: [PATCH] find_unique_abbrev(): honor caller-supplied "len" better

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 10, 2011 at 4:40 PM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
>
> How many characters do we need to name master uniquely today?
>
>    $ ./git -c core.abbrevguard=0 rev-parse --short=1 master
>    83c3c
>
> Ok, so there are more than one object with 83c3 and 83c3c is the absolute
> minimum.

Actually, that's just lucky.

Do this:

  git rev-list --abbrev=4 --abbrev-commit --all --objects | grep '^.........*$'

and you'll see several commits in the git tree that need eight
characters to be unique. The fact that your current 'master' isn't one
of them, and in fact happens to be one that only needs five, is just
pure luck.

So even in the (much smaller) git repo, 7 is not a sufficient unique
minimum even today. Never mind any future guarding.

And your argument fails for exactly that reason: yes, for an
_individual_ SHA1, you may think that "five characters is sufficient",
and when you then use that random number (5) as a basis for forming
your "max 8 character" logic, it fails miserably for other cases.

Now, if the "abbrevguard" was based not one one random data-point, but
on the _whole_ current state of the repository, things would be
different.  Then it would actually become a "let's pick a good default
abbreviation length for this repo". But that's now that it does. The
abbrevguard depends on the one particular SHA1 you're looking at, so
you can actually be asking for a longer abbreviation, but still get a
_shorter_ end result than when you asked for a shorter abbreviation.

IOW, try your example thing not just with "master", but with two
extreme commits. For example, try

  git -c core.abbrevguard=2 rev-parse --short=5 83c3c622
  git -c core.abbrevguard=2 rev-parse --short=4 979f7929

and tell me what you get. I _think_ you should get 7 digits for the
first case, and 8 digits for the second one. Even though you "asked"
for a longer name in the first case, and you had the same abbrevguard.

See what I'm saying? I think that's just insane. And it comes exactly
from the fact that abbreviation ends up being a "local" thing.

                          Linus
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]