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

Re: [PATCH 19/20] abbrev: support relative abbrev values

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jun 14, 2018, 19:07 UTC
Message-ID
<87y3fhuqye.fsf@evledraar.gmail.com>
In-Reply-To
<xmqq602l5pvs.fsf@gitster-ct.c.googlers.com>
On Thu, Jun 14 2018, Junio C Hamano wrote:
Show 43 quoted lines
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
>> On Wed, Jun 13 2018, Junio C Hamano wrote:
>>
>>> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>>>
>>>> E.g. here's a breakdown of my dotfiles repo:
>>>>
>>>>     $ git -c core.abbrev=4 log  --pretty=format:%h|perl -nE 'chomp;say length'|sort|uniq -c|sort -nr
>>>>         784 4
>>>>          59 5
>>>>           7 6
>>>>
>>>> I don't have a single commit that needs 7 characters, yet that's our
>>>> default. This is a sane trade-off for the kernel, but for something
>>>> that's just a toy or something you're playing around with something
>>>> shorter can make sense.
>>>>
>>>> SHA-1s aren't just written down, but also e.g. remembered in wetware
>>>> short-term memory.
>>>
>>> That's a fine example of what I called "supporting absurdly small
>>> absolute values like 4"; I still do not see why you want "negative
>>> relative values" from that example.
>>
>> Because hardcoding -2 is very different than setting it to 5, because
>> the -2 will scale to the size of the repository, but 5 is just 7-2 where
>> 7 is our default value.
>>
>> So, in general if you want less future proof hashes by some
>> probabilistic metric (whether you use core.validateAbbrev or not) you'd
>> use -2 or -3, just like you might use +2 or +3 if you'd like to have
>> more future-proof hashes (especially with core.validateAbbrev=true).
>
> That still does not make much sense to me at all.
>
> I do agree that something shorter than the default 7 may be more
> appropriate for our wetware short-term memory, and it would make
> sense to grow the "riskier to collide than the default heuristics
> but more memorable" variant as the project grows, _ONLY_ _IF_ our
> wetware short-term memory scales with the project we happen to be
> working on.  But our wetware does not scale with the project we work
> on; at least mine does not.

Yes, it's a trade-off, but just because something is a trade-off doesn't make it useless.

Aside from the feature I'm proposing, the same thing applies to the short SHA-1 currently. My ~1k commit dotfiles has 7 characters, but linux.git has 12. Does that make printing the short SHA-1 at all useless and we should just fall back to 40 characters if it's say >= 12? No.

12 is still better than 40, but if we could get away with it 10 would be better than 12. Right now the "get away with it" calculation is a hardcoded constant, this makes it configurable.

The reason to make it configurable is because you may want more future proof *or* less future-proof SHA-1s depending on the use-case. Printing a longer SHA-1 has a cost, including but not limited to:

 * Remembering it for a short time
 * Seeing it on one screen and typing it into another computer manually
 * `git log --oneline` output in a terminal where horizontal space is at
   a premium
Previous: Junio C HamanoNext: Ævar Arnfjörð Bjarmason
Message 20 of 37 in “unconditional O(1) SHA-1 abbreviation”
  1. 00/20 unconditional O(1) SHA-1 abbreviationÆvar Arnfjörð Bjarmason, Jun 8, 2018
  2. 01/20 t/README: clarify the description of test_line_countÆvar Arnfjörð Bjarmason, Jun 8, 2018
  3. 02/20 test library: add a test_byte_countÆvar Arnfjörð Bjarmason, Jun 8, 2018
  4. 04/20 abbrev tests: add tests for core.abbrev and --abbrevÆvar Arnfjörð Bjarmason, Jun 8, 2018
  5. Junio C HamanoJun 12, 2018
  6. 07/20 abbrev tests: test "git branch" behaviorÆvar Arnfjörð Bjarmason, Jun 8, 2018
  7. 10/20 abbrev tests: test for "git-diff" behaviorÆvar Arnfjörð Bjarmason, Jun 8, 2018
  8. 14/20 config.c: use braces on multiple conditional armsÆvar Arnfjörð Bjarmason, Jun 8, 2018
  9. 16/20 abbrev: unify the handling of non-numeric valuesÆvar Arnfjörð Bjarmason, Jun 8, 2018
  10. 17/20 abbrev: unify the handling of empty valuesÆvar Arnfjörð Bjarmason, Jun 8, 2018
  11. Martin ÅgrenJun 9, 2018
  12. Martin ÅgrenJun 9, 2018
  13. 19/20 abbrev: support relative abbrev valuesÆvar Arnfjörð Bjarmason, Jun 8, 2018
  14. Martin ÅgrenJun 9, 2018
  15. Junio C HamanoJun 12, 2018
  16. Ævar Arnfjörð BjarmasonJun 13, 2018
  17. Junio C HamanoJun 13, 2018
  18. Ævar Arnfjörð BjarmasonJun 14, 2018
  19. Junio C HamanoJun 14, 2018
  20. Ævar Arnfjörð BjarmasonJun 14, 2018
  21. 20/20 abbrev: add a core.validateAbbrev settingÆvar Arnfjörð Bjarmason, Jun 8, 2018
  22. Martin ÅgrenJun 9, 2018
  23. Junio C HamanoJun 12, 2018
  24. 18/20 abbrev parsing: use braces on multiple conditional armsÆvar Arnfjörð Bjarmason, Jun 8, 2018
  25. 09/20 abbrev tests: test for "git-log" behaviorÆvar Arnfjörð Bjarmason, Jun 8, 2018
  26. Martin ÅgrenJun 9, 2018
  27. Ævar Arnfjörð BjarmasonJun 9, 2018
  28. Martin ÅgrenJun 9, 2018
  29. 15/20 parse-options-cb.c: use braces on multiple conditional armsÆvar Arnfjörð Bjarmason, Jun 8, 2018
  30. 12/20 abbrev tests: test for --abbrev and core.abbrev=[+-]NÆvar Arnfjörð Bjarmason, Jun 8, 2018
  31. 13/20 parse-options-cb.c: convert uses of 40 to GIT_SHA1_HEXSZÆvar Arnfjörð Bjarmason, Jun 8, 2018
  32. 06/20 blame: fix a bug, core.abbrev should work like --abbrevÆvar Arnfjörð Bjarmason, Jun 8, 2018
  33. 08/20 abbrev tests: test for "git-describe" behaviorÆvar Arnfjörð Bjarmason, Jun 8, 2018
  34. 11/20 abbrev tests: test for plumbing behaviorÆvar Arnfjörð Bjarmason, Jun 8, 2018
  35. 03/20 blame doc: explicitly note how --abbrev=40 gives 39 charsÆvar Arnfjörð Bjarmason, Jun 8, 2018
  36. Junio C HamanoJun 12, 2018
  37. 05/20 abbrev tests: test "git-blame" behaviorÆvar Arnfjörð Bjarmason, Jun 8, 2018

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.