aboutsummaryrefslogtreecommitdiffstats
path: root/upload-pack.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2024-02-28 17:48:18 -0500
committerJunio C Hamano <gitster@pobox.com>2024-02-28 15:30:41 -0800
commit9a7b22959ad078df1f50d15e86a169aaebfb8c4c (patch)
tree63e5ccfc0caa8123f8fc988d78d8290e20cc4ebc /upload-pack.c
parent37aa89b068810d4ed7f262adcfecca1e07cf553c (diff)
downloadgit-9a7b22959ad078df1f50d15e86a169aaebfb8c4c.tar.gz
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>
Diffstat (limited to 'upload-pack.c')
-rw-r--r--upload-pack.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/upload-pack.c b/upload-pack.c
index 6bda20754d..491ef51daa 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -1841,31 +1841,23 @@ int upload_pack_v2(struct repository *r, struct packet_reader *request)
int upload_pack_advertise(struct repository *r,
struct strbuf *value)
{
+ struct upload_pack_data data;
+
+ upload_pack_data_init(&data);
+ get_upload_pack_config(r, &data);
+
if (value) {
- int allow_filter_value;
- int allow_ref_in_want;
- int allow_sideband_all_value;
char *str = NULL;
strbuf_addstr(value, "shallow wait-for-done");
- if (!repo_config_get_bool(r,
- "uploadpack.allowfilter",
- &allow_filter_value) &&
- allow_filter_value)
+ if (data.allow_filter)
strbuf_addstr(value, " filter");
- if (!repo_config_get_bool(r,
- "uploadpack.allowrefinwant",
- &allow_ref_in_want) &&
- allow_ref_in_want)
+ if (data.allow_ref_in_want)
strbuf_addstr(value, " ref-in-want");
- if (git_env_bool("GIT_TEST_SIDEBAND_ALL", 0) ||
- (!repo_config_get_bool(r,
- "uploadpack.allowsidebandall",
- &allow_sideband_all_value) &&
- allow_sideband_all_value))
+ if (data.allow_sideband_all)
strbuf_addstr(value, " sideband-all");
if (!repo_config_get_string(r,
@@ -1877,5 +1869,7 @@ int upload_pack_advertise(struct repository *r,
}
}
+ upload_pack_data_clear(&data);
+
return 1;
}