Message ID | 6be331b22d51e1f6f96cb0035d99db5b8cede676.1705411391.git.zhiyou.jx@alibaba-inc.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | support remote archive via stateless transport | expand |
Jiang Xin <worldhello.net@gmail.com> writes: > From: Jiang Xin <zhiyou.jx@alibaba-inc.com> > > Add new service (git-upload-archive) support in remote-curl, so we can > support remote archive over HTTP/HTTPS protocols. Differences between > git-upload-archive and other serices: s/serices/services > 1. The git-archive command does not expect to see protocol version and > capabilities when connecting to remote-helper, so do not send them > in remote-curl for the git-upload-archive service. > > 2. We need to detect protocol version by calling discover_refs(), s/,/. > Fallback to use the git-upload-pack service (which, like > git-upload-archive, is a read-only operation) to discover protocol > version. > > Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com> > --- > remote-curl.c | 14 +++++++++++--- > 1 file changed, 11 insertions(+), 3 deletions(-) > > diff --git a/remote-curl.c b/remote-curl.c > index ef05752ca5..ce6cb8ac05 100644 > --- a/remote-curl.c > +++ b/remote-curl.c > @@ -1447,8 +1447,14 @@ static int stateless_connect(const char *service_name) > * establish a stateless connection, otherwise we need to tell the > * client to fallback to using other transport helper functions to > * complete their request. > + * > + * The "git-upload-archive" service is a read-only operation. Fallback > + * to use "git-upload-pack" service to discover protocol version. > */ > - discover = discover_refs(service_name, 0); > + if (!strcmp(service_name, "git-upload-archive")) > + discover = discover_refs("git-upload-pack", 0); > + else > + discover = discover_refs(service_name, 0); > if (discover->version != protocol_v2) { > printf("fallback\n"); > fflush(stdout); > @@ -1486,9 +1492,11 @@ static int stateless_connect(const char *service_name) > > /* > * Dump the capability listing that we got from the server earlier > - * during the info/refs request. > + * during the info/refs request. This does not work with the > + * "git-upload-archive" service. > */ > - write_or_die(rpc.in, discover->buf, discover->len); > + if (strcmp(service_name, "git-upload-archive")) > + write_or_die(rpc.in, discover->buf, discover->len); > > /* Until we see EOF keep sending POSTs */ > while (1) { > -- > 2.43.0
diff --git a/remote-curl.c b/remote-curl.c index ef05752ca5..ce6cb8ac05 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -1447,8 +1447,14 @@ static int stateless_connect(const char *service_name) * establish a stateless connection, otherwise we need to tell the * client to fallback to using other transport helper functions to * complete their request. + * + * The "git-upload-archive" service is a read-only operation. Fallback + * to use "git-upload-pack" service to discover protocol version. */ - discover = discover_refs(service_name, 0); + if (!strcmp(service_name, "git-upload-archive")) + discover = discover_refs("git-upload-pack", 0); + else + discover = discover_refs(service_name, 0); if (discover->version != protocol_v2) { printf("fallback\n"); fflush(stdout); @@ -1486,9 +1492,11 @@ static int stateless_connect(const char *service_name) /* * Dump the capability listing that we got from the server earlier - * during the info/refs request. + * during the info/refs request. This does not work with the + * "git-upload-archive" service. */ - write_or_die(rpc.in, discover->buf, discover->len); + if (strcmp(service_name, "git-upload-archive")) + write_or_die(rpc.in, discover->buf, discover->len); /* Until we see EOF keep sending POSTs */ while (1) {