[PATCH/RFC 2/2] remote-curl: send the refs to fetch-pack on stdin

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>From 723a561946824ee367f57f0d9b9d336a6bc28d13 Mon Sep 17 00:00:00 2001
From: Ivan Todoroski <grnch@xxxxxxx>
Date: Sat, 24 Mar 2012 15:53:36 +0100
Subject: [PATCH/RFC 2/2] remote-curl: send the refs to fetch-pack on stdin

---
 remote-curl.c |   18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/remote-curl.c b/remote-curl.c
index d159fe7f34..9fdfca9f32 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -531,12 +531,13 @@ static int post_rpc(struct rpc_state *rpc)
 	return err;
 }
 
-static int rpc_service(struct rpc_state *rpc, struct discovery *heads)
+static int rpc_service(struct rpc_state *rpc, struct discovery *heads,
+		int nr_fetch, struct ref **to_fetch)
 {
 	const char *svc = rpc->service_name;
 	struct strbuf buf = STRBUF_INIT;
 	struct child_process client;
-	int err = 0;
+	int err = 0, i;
 
 	memset(&client, 0, sizeof(client));
 	client.in = -1;
@@ -545,6 +546,13 @@ static int rpc_service(struct rpc_state *rpc, struct discovery *heads)
 	client.argv = rpc->argv;
 	if (start_command(&client))
 		exit(1);
+
+	/* push the refs to fetch-pack via stdin, if requested */
+	if (to_fetch) {
+		for (i = 0; i < nr_fetch; i++)
+			packet_write(client.in, "%s\n", to_fetch[i]->name);
+		packet_flush(client.in);
+	}
 	if (heads)
 		write_or_die(client.in, heads->buf, heads->len);
 
@@ -633,6 +641,7 @@ static int fetch_git(struct discovery *heads,
 	argv = xmalloc((15 + nr_heads) * sizeof(char*));
 	argv[argc++] = "fetch-pack";
 	argv[argc++] = "--stateless-rpc";
+	argv[argc++] = "--stdin";
 	argv[argc++] = "--lock-pack";
 	if (options.followtags)
 		argv[argc++] = "--include-tag";
@@ -655,7 +664,6 @@ static int fetch_git(struct discovery *heads,
 		struct ref *ref = to_fetch[i];
 		if (!ref->name || !*ref->name)
 			die("cannot fetch by sha1 over smart http");
-		argv[argc++] = ref->name;
 	}
 	argv[argc++] = NULL;
 
@@ -664,7 +672,7 @@ static int fetch_git(struct discovery *heads,
 	rpc.argv = argv;
 	rpc.gzip_request = 1;
 
-	err = rpc_service(&rpc, heads);
+	err = rpc_service(&rpc, heads, nr_heads, to_fetch);
 	if (rpc.result.len)
 		safe_write(1, rpc.result.buf, rpc.result.len);
 	strbuf_release(&rpc.result);
@@ -783,7 +791,7 @@ static int push_git(struct discovery *heads, int nr_spec, char **specs)
 	rpc.service_name = "git-receive-pack",
 	rpc.argv = argv;
 
-	err = rpc_service(&rpc, heads);
+	err = rpc_service(&rpc, heads, 0, NULL);
 	if (rpc.result.len)
 		safe_write(1, rpc.result.buf, rpc.result.len);
 	strbuf_release(&rpc.result);
-- 
1.7.9.4.16.gd24fa.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]