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

Re: The transfer.hideRefs of the upload-pack process does not work properly

From
Jeff King <peff@peff.net>
Date
Mar 4, 2025, 07:51 UTC
Message-ID
<20250304075113.GD1283943@coredump.intra.peff.net>
In-Reply-To
<CAD6AYr84KuBb5N-LVBQo-6Gq2Ms3JKQCk0gyO8i=N8gp3whe_Q@mail.gmail.com>
On Fri, Feb 28, 2025 at 10:32:01AM +0800, SURA wrote:
> My previous description was not clear enough. The early hiding
> according to exclude_patterns in packed_ref_iterator_begin seems to be
> designed for git for-each-ref's exclude. It is different from the
> ref_hidden matching rule used by upload-pack.

From your reproduction, it looks like the issue is that for loose refs, asking for_each_ref() to exclude "refs/heads/foo" will not yield "refs/heads/foo/bar", but will yield "refs/heads/foo-bar".

And that was true for packed-refs, too, before 59c35fac54 (refs/packed-backend.c: implement jump lists to avoid excluded pattern(s), 2023-07-10). After that, packed-refs exclude both.

So probably the solution is for the jump list in 59c35fac54 to be pickier about finding its start/end points. It should insist on a trailing "/" (I think end-of-string would also be valid, but it may be easier to ignore that, and it is OK to err on the side of inclusion, since the caller is supposed to do their own filtering).

Probably the logic needs to go into cmp_record_to_refname(), but I lack sufficient brain power at this time of night to even attempt a fix.

The smallest reproduction for me is:
  git init
  git commit --allow-empty -m foo
  git pack-refs --all
  git -c transfer.hiderefs=refs/he upload-pack .

which shows "refs/heads/main" (or "master") before 59c35fac54, but not after.

-Peff
Previous: SURANext: Jeff King
Message 4 of 10 in “The transfer.hideRefs of the upload-pack process does not work properly”
  1. SURAFeb 27, 2025
  2. Taylor BlauFeb 28, 2025
  3. SURAFeb 28, 2025
  4. Jeff KingMar 4, 2025
  5. Jeff KingMar 4, 2025
  6. Patrick SteinhardtMar 4, 2025
  7. Taylor BlauMar 4, 2025
  8. Taylor BlauMar 6, 2025
  9. Taylor BlauMar 5, 2025
  10. Junio C HamanoMar 5, 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.