[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