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

[PATCH v2 6/8] connect: use write_command_and_capabilities() in get_remote_bundle_uri()

From
Christian Couder <christian.couder@gmail.com>
Date
Nov 20, 2026, 16:48 UTC
Message-ID
<20261120164812.707946-16-christian.couder@gmail.com>
In-Reply-To
<20261120164812.707946-10-christian.couder@gmail.com>

Now that previous commits made write_command_and_capabilities() more generic, we can use that function in get_remote_bundle_uri() instead of send_capabilities().

Let's do that then, and let's remove send_capabilities() while at it, as it no longer has any caller.

As before, no "server-option" capability is sent with the `bundle-uri` request.

Note that now "command=bundle-uri" comes first on the wire instead of last, and "promisor-remote" now comes before "object-format", but this should not be an issue as "serve.c" accepts capabilities and "command=..." in any order, and JGit doesn't implement "bundle-uri".

Also note that "command=bundle-uri" no longer ends with "\n", which is harmless because the server chomps newlines.

Signed-off-by: Christian Couder <christian.couder@gmail.com>
---
 connect.c | 49 +++++--------------------------------------------
 1 file changed, 5 insertions(+), 44 deletions(-)
diff --git a/connect.c b/connect.c
index 9d5585f72b..3d0afb2d27 100644
--- a/connect.c
+++ b/connect.c
@@ -516,60 +516,21 @@ void add_promisor_remote_reply(struct strvec *capabilities)
 	}
 }
 
-static void send_capabilities(struct strbuf *req_buf,
-			      struct packet_reader *reader)
-{
-	const char *hash_name;
-	const char *promisor_remote_info;
-	int advertise_sid = 0;
-
-	repo_config_get_bool(the_repository, "transfer.advertisesid", &advertise_sid);
-
-	if (server_supports_v2("agent"))
-		packet_buf_write(req_buf, "agent=%s", git_user_agent_sanitized());
-
-	if (advertise_sid && server_supports_v2("session-id"))
-		packet_buf_write(req_buf, "session-id=%s", trace2_session_id());
-
-	if (server_feature_v2("object-format", &hash_name)) {
-		int hash_algo = hash_algo_by_name(hash_name);
-		if (hash_algo == GIT_HASH_UNKNOWN)
-			die(_("unknown object format '%s' specified by server"), hash_name);
-		reader->hash_algo = &hash_algos[hash_algo];
-		packet_buf_write(req_buf, "object-format=%s", reader->hash_algo->name);
-	} else {
-		reader->hash_algo = &hash_algos[GIT_HASH_SHA1_LEGACY];
-	}
-	if (server_feature_v2("promisor-remote", &promisor_remote_info)) {
-		char *reply;
-		promisor_remote_reply(promisor_remote_info, &reply);
-		if (reply) {
-			packet_buf_write(req_buf, "promisor-remote=%s", reply);
-			free(reply);
-		}
-	}
-}
-
 int get_remote_bundle_uri(int fd_out, struct packet_reader *reader,
 			  struct bundle_list *bundles, int stateless_rpc)
 {
 	struct strbuf req_buf = STRBUF_INIT;
+	struct strvec capabilities = STRVEC_INIT;
 	int line_nr = 1, err = 0;
 
-	/* Assert bundle-uri support */
-	ensure_server_supports_v2("bundle-uri");
-
-	/* (Re-)send capabilities */
-	send_capabilities(&req_buf, reader);
-
-	/* Send command */
-	packet_buf_write(&req_buf, "command=bundle-uri\n");
-	packet_buf_delim(&req_buf);
-
+	add_promisor_remote_reply(&capabilities);
+	write_command_and_capabilities(&req_buf, "bundle-uri",
+				       &capabilities, reader);
 	packet_buf_flush(&req_buf);
 
 	if (write_in_full(fd_out, req_buf.buf, req_buf.len) < 0)
 		die_errno(_("unable to write request to remote"));
+	strvec_clear(&capabilities);
 	strbuf_release(&req_buf);
 
 	/* Process response from server */
-- 
2.56.0
Previous: Christian CouderNext: Christian Couder
Message 16 of 18 in “Fix promisor-remote reply missing from fetch”
  1. 0/3 Fix promisor-remote reply missing from fetchChristian Couder, Nov 12, 2026
  2. 1/3 connect: let write_command_and_capabilities() send a promisor-remote replyChristian Couder, Nov 12, 2026
  3. Junio C HamanoNov 12, 2026
  4. Junio C HamanoNov 12, 2026
  5. Christian CouderNov 13, 2026
  6. Junio C HamanoNov 13, 2026
  7. Christian CouderNov 20, 2026
  8. 2/3 fetch-pack: ensure fetch sends a promisor-remote replyChristian Couder, Nov 12, 2026
  9. 3/3 doc: gitprotocol-v2: send the promisor-remote reply with fetchChristian Couder, Nov 12, 2026
  10. 0/8 Fix promisor-remote reply missing from fetchChristian Couder, Nov 20, 2026
  11. 1/8 connect: pass capability lines to write_command_and_capabilities()Christian Couder, Nov 20, 2026
  12. 2/8 connect: send session-id with ls-refs and bundle-uriChristian Couder, Nov 20, 2026
  13. 3/8 connect: pass a reader to write_command_and_capabilities()Christian Couder, Nov 20, 2026
  14. 4/8 connect: buffer the ls-refs and bundle-uri requestsChristian Couder, Nov 20, 2026
  15. 5/8 connect: use write_command_and_capabilities() in get_remote_refs()Christian Couder, Nov 20, 2026
  16. 6/8 connect: use write_command_and_capabilities() in get_remote_bundle_uri()Christian Couder, Nov 20, 2026
  17. 7/8 fetch-pack: ensure fetch sends a promisor-remote replyChristian Couder, Nov 20, 2026
  18. 8/8 doc: gitprotocol-v2: send the promisor-remote reply with fetchChristian Couder, Nov 20, 2026

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.