From: Christian Couder <christian.couder@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
Patrick Steinhardt <ps@pks.im>, Matt Cote <mcote@nvidia.com>,
Christian Couder <christian.couder@gmail.com>
Subject: [PATCH v2 0/8] Fix promisor-remote reply missing from fetch
Date: Fri, 20 Nov 2026 17:48:13 +0100 [thread overview]
Message-ID: <20261120164812.707946-10-christian.couder@gmail.com> (raw)
In-Reply-To: <20261112195858.53788-5-christian.couder@gmail.com>
This started as a small series to fix a brown paper bag bug in the
"promisor-remote" protocol v2 capability found by Matt Cote during the
NVIDIA hackathon following the Gerrit User Summit 2026.
But with this version 2, it has become more of a refactoring of the
code that clients use to write protocol v2 capabilities. That's
because there are three different places doing that in "connect.c":
- 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`.
So a large part of this version 2 series refactors this, and now only
write_command_and_capabilities() does it.
The bug, which is addressed in the last two patches of the series, is
that the client doesn't send a "promisor-remote=..." reply with the
`fetch` protocol commands. It does send such a reply with the
`ls-refs` and `bundle-uri` protocol commands. So this works by luck
with a Git server over file:// or ssh://, as the same `upload-pack`
process handles all the requests and remembers the reply from
`ls-refs`.
But it doesn't work with servers that handle each request on its own,
like Git over HTTP. (This is also how it was found with a JGit/Gerrit
setup during the hackathon.) It also doesn't work when only object IDs
are fetched, as no `ls-refs` is sent then.
In these cases, the server doesn't know that the client accepted a
promisor remote, so it doesn't allow the objects available on the
accepted promisor remotes to be missing from the pack, and fails with
"could not fetch <oid> from promisor remote".
This has been the case since the capability was introduced in v2.49,
so it would be nice to have the fix in maint too. The series still
applies cleanly on top of maint (v2.56.1) and the tests pass there. As
the wire changes in the first part of the series are small (see
below), I hope the whole series can be considered for maint.
Other related issues were found during the NVIDIA hackathon, but this
one is the most annoying. The others will be addressed in separate
series.
Overview of the patches
=======================
- Patches 1/8 to 6/8 make write_command_and_capabilities() the only
function that writes protocol v2 capabilities. That function
becomes more generic, while helper functions are added for callers
to prepare capabilities before passing them to that function.
There are a few wire changes in those mostly refactoring patches,
to unify the behavior when sending different requests:
- patch 2/8 sends "session-id" with `ls-refs` and `bundle-uri`
requests (only when `transfer.advertiseSID` is set),
- patch 4/8 changes how failing to write `ls-refs` and
`bundle-uri` requests is reported, as we now die with "unable to
write request to remote", like for `fetch` and `object-info`
requests, instead of with "packet write with format failed" (or
silently from SIGPIPE on EPIPE),
- patches 5/8 and 6/8 change the order of the capability lines,
and "command=bundle-uri" now comes first,
- patches 5/8 and 6/8 also stop sending a trailing "\n" after
"command=ls-refs" and "command=bundle-uri".
- Patch 7/8 ("fetch-pack: ensure fetch sends a promisor-remote
reply") is the actual fix, with new tests in t5710, and in a new
t5711 test script for HTTP.
- Patch 8/8 ("doc: gitprotocol-v2: send the promisor-remote reply
with fetch") documents that the client should send the reply with
`fetch` requests asking for a pack.
Changes compared to v1
======================
Thanks to Junio for reviewing v1. As he suggested, callers now build
the list of capabilities they want to send and pass it to
write_command_and_capabilities(), instead of passing a specific
promisor-remote reply argument.
- Patches 1/8 to 6/8 are new. They replace patch 1/3 in v1 (which
only added a new `const char *promisor_remote_reply` argument to
write_command_and_capabilities() so that this function could send
a promisor-remote reply).
- Patch 7/8 now uses a new add_promisor_remote_reply() helper
function introduced by previous patches to prepare the
"promisor-remote" capability reply, and then always writes it with
the improved write_command_and_capabilities() when sending a
`fetch` request. The added tests are the same as in v1.
- Patch 8/8 now documents that the reply should be sent with each
`fetch` request asking for a pack (so not with negotiation-only
requests), and mentions `bundle-uri` along with `ls-refs`.
CI tests
========
Some failed, others didn't even start, see:
https://github.com/chriscool/git/actions/runs/44747276981
But all these issues look unrelated to this series.
Range-diff compared to v1
=========================
1: 523fec7fc3 < -: ---------- connect: let write_command_and_capabilities() send a promisor-remote reply
-: ---------- > 1: 0b8a469426 connect: pass capability lines to write_command_and_capabilities()
-: ---------- > 2: b5814012e7 connect: send session-id with ls-refs and bundle-uri
-: ---------- > 3: 9ae83a24d4 connect: pass a reader to write_command_and_capabilities()
-: ---------- > 4: b9393478d9 connect: buffer the ls-refs and bundle-uri requests
-: ---------- > 5: c7bb7aea1e connect: use write_command_and_capabilities() in get_remote_refs()
-: ---------- > 6: 6f8b694584 connect: use write_command_and_capabilities() in get_remote_bundle_uri()
2: 8e2294ec62 ! 7: d3ab977624 fetch-pack: ensure fetch sends a promisor-remote reply
@@ Commit message
fetch-pack: ensure fetch sends a promisor-remote reply
In protocol v2, when the client accepts promisor remotes, the
- `promisor-remote=...` reply is only written by send_capabilities(),
- which is used to send the `ls-refs` and `bundle-uri` protocol commands.
+ `promisor-remote=...` reply is only sent with the `ls-refs` and
+ `bundle-uri` protocol commands, by get_remote_refs() and
+ get_remote_bundle_uri() in "connect.c".
The request for the `fetch` protocol command is built by
- write_command_and_capabilities() called by send_fetch_request() in
- "fetch-pack.c" which doesn't send that reply. do_fetch_pack_v2() calls
- promisor_remote_reply(), but only to mark the accepted remotes, as
- e15a6b2f8b (promisor-remote: change promisor_remote_reply()'s
- signature, 2026-02-16) assumed that fetch-pack would not need to send
- a reply.
+ send_fetch_request() in "fetch-pack.c" which doesn't send that reply.
+ do_fetch_pack_v2() calls promisor_remote_reply(), but only to mark the
+ accepted remotes, as e15a6b2f8b (promisor-remote: change
+ promisor_remote_reply()'s signature, 2026-02-16) assumed that
+ fetch-pack would not need to send a reply.
With file:// and ssh:// URLs on a Git server, one upload-pack process
handles both `ls-refs` and `fetch`. The acceptance recorded during
`ls-refs` by promisor_remote_receive() in "serve.c" is still there at
`fetch` time, so the clone succeeds. But it fails when each request is
handled on its own, for example with HTTP where different upload-pack
- processes are used, or with other server implementations like JGit.
+ processes are used.
It also fails when only object IDs are fetched, as no `ls-refs`
command is then sent. In these cases, the server doesn't know that the
@@ Commit message
objects to be missing from the pack it sends, and it fails with "could
not fetch <oid> from promisor remote".
- Let's fix that by always properly sending the `promisor-remote=...`
- reply when sending a `fetch` request from do_fetch_pack_v2().
+ Let's fix that by building the list of capabilities for the `fetch`
+ requests once in do_fetch_pack_v2(), using add_server_options() and
+ add_promisor_remote_reply(), and by passing that list to
+ send_fetch_request(). This way the `promisor-remote=...` reply is
+ always properly sent with the `fetch` requests, and the accepted
+ remotes are still marked at the same point as before.
The `fetch` requests sent by negotiate_using_fetch() don't ask for a
pack, so they don't need that reply.
@@ fetch-pack.c: static int send_fetch_request(struct fetch_negotiator *negotiator,
int sideband_all, int seen_ack,
- struct oidset *negotiation_include_oids)
+ struct oidset *negotiation_include_oids,
-+ const char *promisor_remote_reply)
++ const struct strvec *capabilities)
{
int haves_added;
int done_sent = 0;
struct strbuf req_buf = STRBUF_INIT;
+- struct strvec capabilities = STRVEC_INIT;
+- add_server_options(&capabilities, args->server_options);
write_command_and_capabilities(&req_buf, "fetch",
-- args->server_options, NULL);
-+ args->server_options,
-+ promisor_remote_reply);
+- &capabilities, NULL);
++ capabilities, NULL);
if (args->use_thin_pack)
packet_buf_write(&req_buf, "thin-pack");
+@@ fetch-pack.c: static int send_fetch_request(struct fetch_negotiator *negotiator, int fd_out,
+ 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);
+ return done_sent;
+ }
@@ fetch-pack.c: static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
+ struct string_list packfile_uris = STRING_LIST_INIT_DUP;
int i;
struct strvec index_pack_args = STRVEC_INIT;
- const char *promisor_remote_config;
-+ char *accepted = NULL;
+- const char *promisor_remote_config;
++ struct strvec capabilities = STRVEC_INIT;
fsck_options_init(&fsck_options, the_repository, FSCK_OPTIONS_MISSING_GITMODULES);
- if (server_feature_v2("promisor-remote", &promisor_remote_config))
+- if (server_feature_v2("promisor-remote", &promisor_remote_config))
- promisor_remote_reply(promisor_remote_config, NULL);
-+ promisor_remote_reply(promisor_remote_config, &accepted);
++ add_server_options(&capabilities, args->server_options);
++ add_promisor_remote_reply(&capabilities);
if (args->filter_options.choice == LOFC_AUTO) {
struct strbuf errbuf = STRBUF_INIT;
@@ fetch-pack.c: static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
seen_ack,
- &negotiation_include_oids)) {
+ &negotiation_include_oids,
-+ accepted)) {
++ &capabilities)) {
trace2_region_leave_printf("negotiation_v2", "round",
the_repository, "%d",
negotiation_round);
@@ fetch-pack.c: static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
- if (negotiator)
- negotiator->release(negotiator);
-+ free(accepted);
- fsck_options_clear(&fsck_options);
- oidset_clear(&common);
- oidset_clear(&negotiation_include_oids);
+ string_list_clear(&packfile_uris, 0);
+ strvec_clear(&index_pack_args);
++ strvec_clear(&capabilities);
+
+ if (fsck_finish(&fsck_options))
+ die("fsck failed");
## t/meson.build ##
@@ t/meson.build: integration_tests = [
3: 4103b0f449 ! 8: 40f7866ade doc: gitprotocol-v2: send the promisor-remote reply with fetch
@@ Commit message
Until a previous commit, a client sent its `promisor-remote=...` reply
only with the `ls-refs` and `bundle-uri` protocol commands.
- Let's clearly document that the client should send that reply with the
- `fetch` command request too.
+ Let's clearly document that the client should send that reply with each
+ `fetch` command request asking for a pack too, as protocol v2 is
+ stateless.
+
+ The `fetch` requests sent only for negotiation, like with `git fetch
+ --negotiate-only`, don't ask for a pack, so they don't need that reply.
Reported-by: Matt Cote <mcote@nvidia.com>
Signed-off-by: Christian Couder <christian.couder@gmail.com>
@@ Documentation/gitprotocol-v2.adoc: In this case, or if the client doesn't want t
"promisor-remote" capability at all in its reply.
+As protocol v2 is stateless (see the "Capabilities" section above),
-+the client should send this reply with the `fetch` command request,
-+even if it has already sent it with an earlier command request, like
-+`ls-refs`. Note that when only some object IDs are fetched, the client
-+might not send any `ls-refs` command request at all.
++the client should send this reply with each `fetch` command request
++asking for a pack, even if it has already sent it with an earlier
++command request, like `ls-refs` or `bundle-uri`. Note that when only
++some object IDs are fetched, the client might not send any `ls-refs`
++command request at all.
+
On the server side, the "promisor.advertise" and "promisor.sendFields"
configuration options can be used to control what it advertises. On
Christian Couder (8):
connect: pass capability lines to write_command_and_capabilities()
connect: send session-id with ls-refs and bundle-uri
connect: pass a reader to write_command_and_capabilities()
connect: buffer the ls-refs and bundle-uri requests
connect: use write_command_and_capabilities() in get_remote_refs()
connect: use write_command_and_capabilities() in
get_remote_bundle_uri()
fetch-pack: ensure fetch sends a promisor-remote reply
doc: gitprotocol-v2: send the promisor-remote reply with fetch
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
base-commit: e1ec09b23c8e0deb21a0b95ac5996422277395d4
--
2.56.0
next prev parent reply other threads:[~2026-11-20 16:48 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 19:58 [PATCH 0/3] Fix promisor-remote reply missing from fetch Christian Couder
2026-11-12 19:59 ` [PATCH 1/3] connect: let write_command_and_capabilities() send a promisor-remote reply Christian Couder
2026-11-12 22:18 ` Junio C Hamano
2026-11-12 22:34 ` Junio C Hamano
2026-11-13 13:10 ` Christian Couder
2026-11-13 19:11 ` Junio C Hamano
2026-11-20 16:57 ` Christian Couder
2026-11-12 19:59 ` [PATCH 2/3] fetch-pack: ensure fetch sends " Christian Couder
2026-11-12 19:59 ` [PATCH 3/3] doc: gitprotocol-v2: send the promisor-remote reply with fetch Christian Couder
2026-11-20 16:48 ` Christian Couder [this message]
2026-11-20 16:48 ` [PATCH v2 1/8] connect: pass capability lines to write_command_and_capabilities() Christian Couder
2026-11-20 16:48 ` [PATCH v2 2/8] connect: send session-id with ls-refs and bundle-uri Christian Couder
2026-11-20 16:48 ` [PATCH v2 3/8] connect: pass a reader to write_command_and_capabilities() Christian Couder
2026-11-20 16:48 ` [PATCH v2 4/8] connect: buffer the ls-refs and bundle-uri requests Christian Couder
2026-11-20 16:48 ` [PATCH v2 5/8] connect: use write_command_and_capabilities() in get_remote_refs() Christian Couder
2026-11-20 16:48 ` [PATCH v2 6/8] connect: use write_command_and_capabilities() in get_remote_bundle_uri() Christian Couder
2026-11-20 16:48 ` [PATCH v2 7/8] fetch-pack: ensure fetch sends a promisor-remote reply Christian Couder
2026-11-20 16:48 ` [PATCH v2 8/8] doc: gitprotocol-v2: send the promisor-remote reply with fetch Christian Couder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261120164812.707946-10-christian.couder@gmail.com \
--to=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mcote@nvidia.com \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox