Skip to content

Commit 23b7d59

Browse files
jiangxingitster
authored andcommitted
remote-curl: supports git-upload-archive service
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 services: 1. The git-archive program 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(). 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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4a61faf commit 23b7d59

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

remote-curl.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,8 +1447,14 @@ static int stateless_connect(const char *service_name)
14471447
* establish a stateless connection, otherwise we need to tell the
14481448
* client to fallback to using other transport helper functions to
14491449
* complete their request.
1450+
*
1451+
* The "git-upload-archive" service is a read-only operation. Fallback
1452+
* to use "git-upload-pack" service to discover protocol version.
14501453
*/
1451-
discover = discover_refs(service_name, 0);
1454+
if (!strcmp(service_name, "git-upload-archive"))
1455+
discover = discover_refs("git-upload-pack", 0);
1456+
else
1457+
discover = discover_refs(service_name, 0);
14521458
if (discover->version != protocol_v2) {
14531459
printf("fallback\n");
14541460
fflush(stdout);
@@ -1486,9 +1492,11 @@ static int stateless_connect(const char *service_name)
14861492

14871493
/*
14881494
* Dump the capability listing that we got from the server earlier
1489-
* during the info/refs request.
1495+
* during the info/refs request. This does not work with the
1496+
* "git-upload-archive" service.
14901497
*/
1491-
write_or_die(rpc.in, discover->buf, discover->len);
1498+
if (strcmp(service_name, "git-upload-archive"))
1499+
write_or_die(rpc.in, discover->buf, discover->len);
14921500

14931501
/* Until we see EOF keep sending POSTs */
14941502
while (1) {

0 commit comments

Comments
 (0)