Skip to content

Commit 6cdf022

Browse files
spearcegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ec014ea commit 6cdf022

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

remote-curl.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,14 @@ static int rpc_service(struct rpc_state *rpc, struct discovery *heads)
575575

576576
close(client.in);
577577
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+
}
579586

580587
close(client.out);
581588
client.out = -1;

0 commit comments

Comments
 (0)