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

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

From
Christian Couder <christian.couder@gmail.com>
Date
Nov 13, 2026, 13:10 UTC
Message-ID
<CAP8UFD18rTvM0mu9oSPMd3V+J9GBgc07RM91Pfh4RJqZg0s9aw@mail.gmail.com>
In-Reply-To
<xmqq4idlhe69.fsf@gitster.g>
On Thu, Nov 12, 2026 at 11:34 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 32 quoted lines
>
> 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.

Show 11 quoted lines
> 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

Previous: Junio C HamanoNext: Junio C Hamano
Message 5 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.