Thread View: linux.kernel.git
6 messages
6 total messages
Started by Christian Couder
Thu, 12 Nov 2026 19:59
[PATCH 1/3] connect: let write_command_and_capabilities() send a promisor-remote reply
Author: Christian Couder
Date: Thu, 12 Nov 2026 19:59
Date: Thu, 12 Nov 2026 19:59
109 lines
14687 bytes
14687 bytes
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
Re: [PATCH 1/3] connect: let write_command_and_capabilities() send a promisor-remote reply
Author: Junio C Hamano
Date: Thu, 12 Nov 2026 22:18
Date: Thu, 12 Nov 2026 22:18
30 lines
13822 bytes
13822 bytes
Christian Couder <christian.couder@gmail.com> writes:
> 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);
> }
This function was designed to have a fairly generic "here we send a
command and then capability exchange based on the settings stored in
the string list" interface for extensibility. It is highly annoying
that we are now adding a specific option here to be sent outside the
framework.
Isn't the misdesign being corrected that the "promisor-remote=..."
string was not sent as part of these server options list of strings?
Can we fix it without contaminating the API like this patch does, or
is it too late?
Re: [PATCH 1/3] connect: let write_command_and_capabilities() send a promisor-remote reply
Author: Junio C Hamano
Date: Thu, 12 Nov 2026 22:34
Date: Thu, 12 Nov 2026 22:34
44 lines
14595 bytes
14595 bytes
Junio C Hamano <gitster@pobox.com> writes:
> Christian Couder <christian.couder@gmail.com> writes:
>
>> 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);
>> }
>
> This function was designed to have a fairly generic "here we send a
> command and then capability exchange based on the settings stored in
> the string list" interface for extensibility. It is highly annoying
> that we are now adding a specific option here to be sent outside the
> framework.
>
> Isn't the misdesign being corrected that the "promisor-remote=..."
> string was not sent as part of these server options list of strings?
> Can we fix it without contaminating the API like this patch does, or
> is it too late?
By this I do not mean that promisor-remote=... has to be sent as one
of the server options (i.e., making the string sent to something
silly like "server-option=promisor-remote=..."). Rather, I am
wondering if the existing server_options string list should be made
into a more generalized form so that the string list can contain
elements whose keys other than "server-option" can also be
contained (like "promisor-remote"). IOW, the caller can decide to
put "promisor-remote=...promisor remote reply..." in the list,
instead of sending it as a totally separate parameter, whose
semantics is hardcoded (i.e. the fourth parameter to this function
will be sent as a value to "promistor-remote=...").
Re: [PATCH 1/3] connect: let write_command_and_capabilities() send a promisor-remote reply
Author: Christian Couder
Date: Fri, 13 Nov 2026 13:10
Date: Fri, 13 Nov 2026 13:10
78 lines
15525 bytes
15525 bytes
On Thu, Nov 12, 2026 at 11:34 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Junio C Hamano <gitster@pobox.com> writes:
>
> > Christian Couder <christian.couder@gmail.com> writes:
> >
> >> 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);
> >> }
> >
> > This function was designed to have a fairly generic "here we send a
> > command and then capability exchange based on the settings stored in
> > the string list" interface for extensibility. It is highly annoying
> > that we are now adding a specific option here to be sent outside the
> > framework.
> >
> > Isn't the misdesign being corrected that the "promisor-remote=..."
> > string was not sent as part of these server options list of strings?
> > Can we fix it without contaminating the API like this patch does, or
> > is it too late?
I think that if we wanted to clean this up, it would need a
significant refactor as there are three separate places in "connect.c"
that write the client's protocol v2 capabilities:
- send_capabilities() used for `bundle-uri`,
- get_remote_refs() (using send_capabilities() and its own loop) used
for `ls-refs`,
- write_command_and_capabilities() used for `fetch` and `object-info`.
They duplicate code for sending "server-option", "agent" and
"object-format", while each sends a different set of capabilities.
The server side already has a table of capabilities (`capabilities[]`
in "serve.c") with generic advertise/receive handling. The client side
could have something similar for building requests.
> By this I do not mean that promisor-remote=... has to be sent as one
> of the server options (i.e., making the string sent to something
> silly like "server-option=promisor-remote=..."). Rather, I am
> wondering if the existing server_options string list should be made
> into a more generalized form so that the string list can contain
> elements whose keys other than "server-option" can also be
> contained (like "promisor-remote"). IOW, the caller can decide to
> put "promisor-remote=...promisor remote reply..." in the list,
> instead of sending it as a totally separate parameter, whose
> semantics is hardcoded (i.e. the fourth parameter to this function
> will be sent as a value to "promistor-remote=...").
I am willing to work on a significant refactoring along what you
suggest, but I think it should be a separate series from this bug fix
series, especially as we might want this fix to also go to maint.
In the meantime, I can send a v2 of this series with something like a
NEEDSWORK comment, for example one in front of
write_command_and_capabilities() saying that it should be refactored
with send_capabilities() and get_remote_refs(), so that callers build
the full list of capabilities, which would remove the
`promisor_remote_reply` parameter
Re: [PATCH 1/3] connect: let write_command_and_capabilities() send a promisor-remote reply
Author: Junio C Hamano
Date: Fri, 13 Nov 2026 19:11
Date: Fri, 13 Nov 2026 19:11
14 lines
13131 bytes
13131 bytes
Christian Couder <christian.couder@gmail.com> writes: > They duplicate code for sending "server-option", "agent" and > "object-format", while each sends a different set of capabilities. That is all the more reason to clean them up before we pile more stuff on top, no? I do not know if that deserves to be called "significant" refactoring, though. It would not take a series with 20 patches each of which weigh more than 30 lines touched, no? Thanks.
Re: [PATCH 1/3] connect: let write_command_and_capabilities() send a promisor-remote reply
Author: Christian Couder
Date: Fri, 20 Nov 2026 16:57
Date: Fri, 20 Nov 2026 16:57
47 lines
13894 bytes
13894 bytes
On Fri, Nov 13, 2026 at 8:11 PM Junio C Hamano <gitster@pobox.com> wrote: > > Christian Couder <christian.couder@gmail.com> writes: > > > They duplicate code for sending "server-option", "agent" and > > "object-format", while each sends a different set of capabilities. > > That is all the more reason to clean them up before we pile more > stuff on top, no? > > I do not know if that deserves to be called "significant" > refactoring, though. It would not take a series with 20 patches > each of which weigh more than 30 lines touched, no? As you can see in the v2 I just sent, it took 6 refactoring patches instead of 1. The diffstat is now: Documentation/gitprotocol-v2.adoc | 7 ++ connect.c | 128 ++++++++++++--------- connect.h | 30 ++++- fetch-object-info.c | 7 +- fetch-pack.c | 23 ++-- t/meson.build | 1 + t/t5705-session-id-in-capabilities.sh | 26 +++++ t/t5710-promisor-remote-capability.sh | 40 +++++++ t/t5711-promisor-remote-capability-http.sh | 126 ++++++++++++++++++++ 9 files changed, 322 insertions(+), 66 deletions(-) create mode 100755 t/t5711-promisor-remote-capability-http.sh instead of: Documentation/gitprotocol-v2.adoc | 6 + connect.c | 6 +- connect.h | 6 +- fetch-object-info.c | 3 +- fetch-pack.c | 17 ++- t/meson.build | 1 + t/t5710-promisor-remote-capability.sh | 40 +++++++ t/t5711-promisor-remote-capability-http.sh | 126 +++++++++++++++++++++ 8 files changed, 196 insertions(+), 9 deletions(-) create mode 100755 t/t5711-promisor-remote-capability-http.sh Thanks.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads