remote-curl: Fix warning after HTTP failure
If the HTTP connection is broken in the middle of a fetch or clone body, the client presented a useless error message due to part of the upload-pack->remote-curl pkt-line protocol leaking out of the helper as the helper's "fetch result": error: RPC failed; result=18, HTTP code = 200 fatal: The remote end hung up unexpectedly fatal: early EOF fatal: unpack-objects failed warning: https unexpectedly said: '0000' Instead when the HTTP RPC fails discard all remaining data from upload-pack and report nothing to the transport helper. Errors were already sent to stderr. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Shawn O. Pearce committed
Oct 4, 2011 at 16:20 UTC
6cdf0223fe4a9ccae543fece8b5e78a626ccdf89
1 file changed
+8
-1
remote-curl.c
+8
-1
@@ -575,7 +575,14 @@ static int rpc_service(struct rpc_state *rpc, struct discovery *heads)
575
576
close(client.in);
577
client.in = -1;
578
- strbuf_read(&rpc->result, client.out, 0);
578
+ if (!err) {
579
+ strbuf_read(&rpc->result, client.out, 0);
580
+ } else {
581
+ char buf[4096];
582
+ for (;;)
583
+ if (xread(client.out, buf, sizeof(buf)) <= 0)
584
+ break;
585
+ }
586
587
close(client.out);
588
client.out = -1;