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

[PATCH 1/4] upload-pack: use repository struct to get config

From
Jeff King <peff@peff.net>
Date
Feb 28, 2024, 22:46 UTC
Message-ID
<20240228224647.GA1158898@coredump.intra.peff.net>
In-Reply-To
<20240228224625.GA1158651@coredump.intra.peff.net>

Our upload_pack_v2() function gets a repository struct, but we ignore it totally. In practice this doesn't cause any problems, as it will never differ from the_repository. But in the spirit of taking a small step towards getting rid of the_repository, let's at least starting using it to grab config. There are probably other spots that could benefit, but it's a start.

Note that we don't need to pass the repo for protected_config(); the whole point there is that we are not looking at repo config, so there is no repo-specific version of the function.

For the v0 version of the protocol, we're not passed a repository struct, so we'll continue to use the_repository there.

Signed-off-by: Jeff King <peff@peff.net>
---
 upload-pack.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/upload-pack.c b/upload-pack.c
index 2537affa90..e156c1e472 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -1385,9 +1385,10 @@ static int upload_pack_protected_config(const char *var, const char *value,
 	return 0;
 }
 
-static void get_upload_pack_config(struct upload_pack_data *data)
+static void get_upload_pack_config(struct repository *r,
+				   struct upload_pack_data *data)
 {
-	git_config(upload_pack_config, data);
+	repo_config(r, upload_pack_config, data);
 	git_protected_config(upload_pack_protected_config, data);
 }
 
@@ -1398,7 +1399,7 @@ void upload_pack(const int advertise_refs, const int stateless_rpc,
 	struct upload_pack_data data;
 
 	upload_pack_data_init(&data);
-	get_upload_pack_config(&data);
+	get_upload_pack_config(the_repository, &data);
 
 	data.stateless_rpc = stateless_rpc;
 	data.timeout = timeout;
@@ -1771,7 +1772,7 @@ enum fetch_state {
 	FETCH_DONE,
 };
 
-int upload_pack_v2(struct repository *r UNUSED, struct packet_reader *request)
+int upload_pack_v2(struct repository *r, struct packet_reader *request)
 {
 	enum fetch_state state = FETCH_PROCESS_ARGS;
 	struct upload_pack_data data;
@@ -1780,7 +1781,7 @@ int upload_pack_v2(struct repository *r UNUSED, struct packet_reader *request)
 
 	upload_pack_data_init(&data);
 	data.use_sideband = LARGE_PACKET_MAX;
-	get_upload_pack_config(&data);
+	get_upload_pack_config(r, &data);
 
 	while (state != FETCH_DONE) {
 		switch (state) {
-- 
2.44.0.rc2.424.gbdbf4d014b
Previous: Jeff KingNext: Patrick Steinhardt
Message 2 of 15 in “some v2 capability advertisement cleanups”
  1. 0/4 some v2 capability advertisement cleanupsJeff King, Feb 28, 2024
  2. 1/4 upload-pack: use repository struct to get configJeff King, Feb 28, 2024
  3. Patrick SteinhardtMar 4, 2024
  4. 2/4 upload-pack: centralize setup of sideband-all configJeff King, Feb 28, 2024
  5. 3/4 upload-pack: use existing config mechanism for advertisementJeff King, Feb 28, 2024
  6. 4/4 upload-pack: only accept packfile-uris if we advertised itJeff King, Feb 28, 2024
  7. Junio C HamanoFeb 28, 2024
  8. Jeff KingFeb 29, 2024
  9. Junio C HamanoFeb 29, 2024
  10. Jeff KingMar 1, 2024
  11. Patrick SteinhardtMar 4, 2024
  12. Junio C HamanoFeb 28, 2024
  13. Jeff KingFeb 29, 2024
  14. Patrick SteinhardtMar 4, 2024
  15. Jeff KingMar 4, 2024

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.