From: Taylor Blau <me@ttaylorr.com>
To: SURA <surak8806@gmail.com>
Cc: git@vger.kernel.org, Patrick Steinhardt <ps@pks.im>,
Jeff King <peff@peff.net>
Subject: Re: The transfer.hideRefs of the upload-pack process does not work properly
Date: Thu, 27 Feb 2025 19:12:26 -0500 [thread overview]
Message-ID: <Z8D/aiqN5e/aRSn7@nand.local> (raw)
In-Reply-To: <CAD6AYr-ZC32VNfUfMB63H-rQRfTdV=VQfBm67i2mG+6GDCNxkQ@mail.gmail.com>
(There's a parallel discussion going on in [1], so it isn't entirely
clear which thread to respond to. Since it seems a little premature to
comment on the patch itself, I'll respond here.)
On Thu, Feb 27, 2025 at 03:24:07PM +0800, SURA wrote:
> I found that packed refs are excluded by the transfer.hideRefs front
> match, while loose refs use full match (when transfer.hideRefs ends
> with '/', it is prefix match, which is normal)
>
> When the server uses git, after setting transfer.hideRefs, the
> references that the client can see before and after server repo gc are
> different
It's true that the low-level loose references iterator does not know how
to handle excluded patterns, and that is by design. In the packed-refs
case, we can skip over whole sections of the packed-refs file according
to which patterns are excluded.
But in the loose references case, we haven't implemented anything like
that to skip over, e.g. enumerating the contents of
"$GIT_DIR/refs/heads/foo" when "refs/heads/foo/" is excluded. (As an
aside, this is something that we could do, it just hasn't been
implemented yet).
So in practice today the only way to exclude loose references according
to some set of exclusion patterns would be to filter them out as we
iterate over them. But that is the caller's responsibility, as we see in
a handful of comments in refs.h which say "any pattern in
'exclude_patterns' [is] omitted on a best-effort basis".
So upload-pack / etc. will see all loose references, and it filters out
the ones which it's supposed to hide via:
upload_pack() -> for_each_namespaced_ref_1() -> send_ref() ->
write_v0_ref() -> mark_our_ref() -> ref_is_hidden()
, where mark_our_ref() tosses out references that the low-level refs
iterator gave back to it which match one of the excluded patterns.
And there we have ref_is_hidden() doing the following for each hidden
pattern:
if (subject &&
skip_prefix(subject, match, &p) &&
(!*p || *p == '/'))
return !neg;
So if the reference either matches the pattern exactly, or matches up to
a '/', then it is hidden and thus not advertised.
I have to imagine I'm missing something, but perhaps it would be useful
if you could provide a reproduction script that demonstrates what you're
seeing.
> It seems that 59c35fa accidentally damaged upload-pack when optimizing
> git for-each-ref
No. 59c35fac54 (refs/packed-backend.c: implement jump lists to avoid
excluded pattern(s), 2023-07-10) predates any behavior changes in
upload-pack, which were introduced later on in 18b6b1b5c5
(upload-pack.c: avoid enumerating hidden refs where possible,
2023-07-10).
Thanks,
Taylor
[1]: https://lore.kernel.org/git/MA0P287MB06412DF70BCDA0D99641129FE4CD2@MA0P287MB0641.INDP287.PROD.OUTLOOK.COM/T/#t
next prev parent reply other threads:[~2025-02-28 0:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-27 7:24 The transfer.hideRefs of the upload-pack process does not work properly SURA
2025-02-28 0:12 ` Taylor Blau [this message]
2025-02-28 2:32 ` SURA
2025-03-04 7:51 ` Jeff King
2025-03-04 7:51 ` Jeff King
2025-03-04 11:38 ` Patrick Steinhardt
2025-03-04 16:40 ` Taylor Blau
2025-03-06 1:21 ` Taylor Blau
2025-03-05 23:12 ` Taylor Blau
2025-03-05 23:45 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z8D/aiqN5e/aRSn7@nand.local \
--to=me@ttaylorr.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=ps@pks.im \
--cc=surak8806@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).