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

Re: [PATCH] abbrev: allow extending beyond 20 chars to disambiguate

From
René Scharfe <l.s.r@web.de>
Date
Aug 12, 2025, 16:21 UTC
Message-ID
<5c7942a3-bccf-44e5-94c2-39fc50f9bab3@web.de>
In-Reply-To
<e463481d-b6a6-4928-86e1-63677f5a88b2@gmail.com>
On 8/12/25 5:26 PM, Jon Forrest wrote:
Show 24 quoted lines
> 
> 
> On 8/11/25 2:17 PM, brian m. carlson wrote:
> 
>>> To see how many leading letters of a given full object name is
>>> sufficiently unambiguous, the algorithm starts from a initial
>>> length, guessed based on the estimated number of objects in the
>>> repository, and see if another object that shares the prefix, and
>>> keeps extending the abbreviation.  The loop stops at GIT_MAX_RAWSZ,
>>> which is counted as the number of bytes, since 5b20ace6 (sha1_name:
>>> unroll len loop in find_unique_abbrev_r(), 2017-10-08); before that
>>> change, it extended up to GIT_MAX_HEXSZ, which is the correct limit
>>> because the loop is adding one output letter per iteration.
> 
> I'm new to all this but the way I did it is much simpler.
> What I did was to check all the files in the appropriate
> object store directory (e.g. .git/objects/XX, where XX are
> the first 2 letters of the object given on the command line.
> If any of the filenames in that directory start with the
> string given on the command line, minus the first 2 letters,
> then that's a match. If more than one filename matches then
> that's ambiguous.
> 
> What's wrong with this approach?

You also need to check all pack files and alternate object databases that you might have.

René
Previous: Jon Forrest
Message 14 of 14 in “abbrev: allow extending beyond 20 chars to disambiguate”
  1. abbrev: allow extending beyond 20 chars to disambiguateJunio C Hamano, Aug 11, 2025
  2. Junio C HamanoAug 11, 2025
  3. abbrev: allow extending beyond 20 chars to disambiguateJunio C Hamano, Aug 11, 2025
  4. brian m. carlsonAug 11, 2025
  5. Derrick StoleeAug 12, 2025
  6. René ScharfeAug 12, 2025
  7. Junio C HamanoAug 12, 2025
  8. René ScharfeAug 12, 2025
  9. abbrev: allow extending beyond 32 chars to disambiguateJunio C Hamano, Aug 14, 2025
  10. brian m. carlsonAug 11, 2025
  11. Junio C HamanoAug 11, 2025
  12. Junio C HamanoAug 11, 2025
  13. Jon ForrestAug 12, 2025
  14. René ScharfeAug 12, 2025

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.