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

[PATCH 1/3] connect: let write_command_and_capabilities() send a promisor-remote reply

From
Christian Couder <christian.couder@gmail.com>
Date
Nov 12, 2026, 19:59 UTC
Message-ID
<20261112195858.53788-6-christian.couder@gmail.com>
In-Reply-To
<20261112195858.53788-5-christian.couder@gmail.com>

In protocol v2, the `promisor-remote=...` reply is only written by send_capabilities(), which is used to send the `ls-refs` and `bundle-uri` protocol commands.

The request for the `fetch` protocol command is built by write_command_and_capabilities() called by send_fetch_request() in "fetch-pack.c" which cannot send that reply.

In a following commit, we will need send_fetch_request() to send that reply.

Let's prepare for that by adding a new `promisor_remote_reply` argument to write_command_and_capabilities(). When it is not NULL, a `promisor-remote=...` capability with that value is written into the request.

For now, all the callers pass NULL, so there is no change in behavior.
Signed-off-by: Christian Couder <christian.couder@gmail.com>
---
 connect.c           | 6 +++++-
 connect.h           | 6 ++++--
 fetch-object-info.c | 3 ++-
 fetch-pack.c        | 6 ++++--
 4 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/connect.c b/connect.c
index 87d2e8bccd..32243948b4 100644
--- a/connect.c
+++ b/connect.c
@@ -724,7 +724,8 @@ int server_supports(const char *feature)
 }
 
 void write_command_and_capabilities(struct strbuf *req_buf, const char *command,
-				    const struct string_list *server_options)
+				    const struct string_list *server_options,
+				    const char *promisor_remote_reply)
 {
 	const char *hash_name;
 	int advertise_sid = 0;
@@ -754,6 +755,9 @@ void write_command_and_capabilities(struct strbuf *req_buf, const char *command,
 		die(_("the server does not support algorithm '%s'"),
 		    the_hash_algo->name);
 	}
+	if (promisor_remote_reply)
+		packet_buf_write(req_buf, "promisor-remote=%s",
+				 promisor_remote_reply);
 	packet_buf_delim(req_buf);
 }
 
diff --git a/connect.h b/connect.h
index 957e5fe2b9..8914d131c7 100644
--- a/connect.h
+++ b/connect.h
@@ -37,9 +37,11 @@ void check_stateless_delimiter(int stateless_rpc,
 struct string_list;
 /*
  * Write a protocol v2 command request, along with the capability
- * advertisements, into req_buf.
+ * advertisements, into req_buf. When `promisor_remote_reply` is not
+ * NULL, a `promisor-remote` capability is sent with that value.
  */
 void write_command_and_capabilities(struct strbuf *req_buf, const char *command,
-				    const struct string_list *server_options);
+				    const struct string_list *server_options,
+				    const char *promisor_remote_reply);
 
 #endif
diff --git a/fetch-object-info.c b/fetch-object-info.c
index 0a58308f9b..7fe6e4e864 100644
--- a/fetch-object-info.c
+++ b/fetch-object-info.c
@@ -18,7 +18,8 @@ static void send_object_info_request(const int fd_out,
 {
 	struct strbuf req_buf = STRBUF_INIT;
 
-	write_command_and_capabilities(&req_buf, "object-info", server_options);
+	write_command_and_capabilities(&req_buf, "object-info",
+				       server_options, NULL);
 
 	if (ask_size)
 		packet_buf_write(&req_buf, "size");
diff --git a/fetch-pack.c b/fetch-pack.c
index 55d311c0c3..50c97f561e 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -1386,7 +1386,8 @@ static int send_fetch_request(struct fetch_negotiator *negotiator, int fd_out,
 	int done_sent = 0;
 	struct strbuf req_buf = STRBUF_INIT;
 
-	write_command_and_capabilities(&req_buf, "fetch", args->server_options);
+	write_command_and_capabilities(&req_buf, "fetch",
+				       args->server_options, NULL);
 
 	if (args->use_thin_pack)
 		packet_buf_write(&req_buf, "thin-pack");
@@ -2269,7 +2270,8 @@ void negotiate_using_fetch(const struct oid_array *negotiation_restrict_tips,
 					   the_repository, "%d",
 					   negotiation_round);
 		strbuf_reset(&req_buf);
-		write_command_and_capabilities(&req_buf, "fetch", server_options);
+		write_command_and_capabilities(&req_buf, "fetch",
+					       server_options, NULL);
 
 		packet_buf_write(&req_buf, "wait-for-done");
 
-- 
2.56.0
Previous: Christian CouderNext: Junio C Hamano
Message 2 of 8 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. 2/3 fetch-pack: ensure fetch sends a promisor-remote replyChristian Couder, Nov 12, 2026
  8. 3/3 doc: gitprotocol-v2: send the promisor-remote reply with fetchChristian Couder, Nov 12, 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.