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

Re: [PATCH 1/4] ref-cache.c: fix prefix matching in ref iteration

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 9, 2023, 18:15 UTC
Message-ID
<xmqqa5sr1x3p.fsf@gitster.g>
In-Reply-To
<3585d72f-9f06-d190-ad5a-bec6db3f647f@github.com>
Victoria Dye <vdye@github.com> writes:
> I originally operated on the assumption that it was the first case, which is
> why I didn't include a test in this patch. Commands like 'for-each-ref',
> 'show-ref', etc. either use an empty prefix or a directory prefix with a
> trailing slash, which won't trigger this issue.

Ah, yes, I didn't mention it but I suspected as such (i.e. the code is structured in such a way that this broken implementation does not matter to the current callers).

> I encountered the problem
> while working on a builtin that filtered refs by a user-specified prefix -
> the results included refs that should not have been matched, which led me to
> this fix.
OK, perfectly understandable.
Show 11 quoted lines
> Scanning through the codebase again, though, I do see a way to replicate the
> issue:
>
> $ git update-ref refs/bisect/b HEAD
> $ git rev-parse --abbrev-ref --bisect
> refs/bisect/b
>
> Because 'rev-parse --bisect' uses the "refs/bisect/bad" prefix (no trailing
> slash) and does no additional filtering in its 'for_each_fullref_in'
> callback, refs like "refs/bisect/b" and "refs/bisect/ba" are (incorrectly)
> matched. I'll re-roll with the added test.
Good find.  Thanks!
Previous: Victoria DyeNext: Victoria Dye via GitGitGadget
Message 6 of 21 in “Performance improvement & cleanup in loose ref iteration”
  1. 0/4 Performance improvement & cleanup in loose ref iterationVictoria Dye via GitGitGadget, Oct 6, 2023
  2. 1/4 ref-cache.c: fix prefix matching in ref iterationVictoria Dye via GitGitGadget, Oct 6, 2023
  3. Junio C HamanoOct 6, 2023
  4. Patrick SteinhardtOct 9, 2023
  5. Victoria DyeOct 9, 2023
  6. Junio C HamanoOct 9, 2023
  7. 3/4 dir.[ch]: add 'follow_symlink' arg to 'get_dtype'Victoria Dye via GitGitGadget, Oct 6, 2023
  8. 2/4 dir.[ch]: expose 'get_dtype'Victoria Dye via GitGitGadget, Oct 6, 2023
  9. Junio C HamanoOct 6, 2023
  10. 4/4 files-backend.c: avoid stat in 'loose_fill_ref_dir'Victoria Dye via GitGitGadget, Oct 6, 2023
  11. Junio C HamanoOct 6, 2023
  12. Junio C HamanoOct 6, 2023
  13. Patrick SteinhardtOct 9, 2023
  14. Victoria DyeOct 9, 2023
  15. Patrick SteinhardtOct 10, 2023
  16. 0/4 Performance improvement & cleanup in loose ref iterationVictoria Dye via GitGitGadget, Oct 9, 2023
  17. 1/4 ref-cache.c: fix prefix matching in ref iterationVictoria Dye via GitGitGadget, Oct 9, 2023
  18. Patrick SteinhardtOct 10, 2023
  19. 2/4 dir.[ch]: expose 'get_dtype'Victoria Dye via GitGitGadget, Oct 9, 2023
  20. 3/4 dir.[ch]: add 'follow_symlink' arg to 'get_dtype'Victoria Dye via GitGitGadget, Oct 9, 2023
  21. 4/4 files-backend.c: avoid stat in 'loose_fill_ref_dir'Victoria Dye via GitGitGadget, Oct 9, 2023

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.