]> git.ipfire.org Git - thirdparty/git.git/commit - upload-pack.c
upload-pack: use existing config mechanism for advertisement
authorJeff King <peff@peff.net>
Wed, 28 Feb 2024 22:48:18 +0000 (17:48 -0500)
committerJunio C Hamano <gitster@pobox.com>
Wed, 28 Feb 2024 23:30:41 +0000 (15:30 -0800)
commit9a7b22959ad078df1f50d15e86a169aaebfb8c4c
tree63e5ccfc0caa8123f8fc988d78d8290e20cc4ebc
parent37aa89b068810d4ed7f262adcfecca1e07cf553c
upload-pack: use existing config mechanism for advertisement

When serving a v2 capabilities request, we call upload_pack_advertise()
to tell us the set of features we can advertise to the client. That
involves looking at various config options, all of which need to be kept
in sync with the rules we use in upload_pack_config to set flags like
allow_filter, allow_sideband_all, and so on. If these two pieces of code
get out of sync then we may refuse to respect a capability we
advertised, or vice versa accept one that we should not.

Instead, let's call the same config helper that we'll use for processing
the actual client request, and then just pick the values out of the
resulting struct. This is only a little bit shorter than the current
code, but we don't repeat any policy logic (e.g., we don't have to worry
about the magic sideband-all environment variable here anymore).

And this reveals a gap in the existing code: there is no struct flag for
the packfile-uris capability (we accept it even if it is not advertised,
which we should not). We'll leave the advertisement code for now and
deal with it in the next patch.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
upload-pack.c