Skip to content

Commit

Permalink
remote-curl: Fix warning after HTTP failure
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Shawn O. Pearce authored and Junio C Hamano committed Oct 5, 2011
1 parent ec014ea commit 6cdf022
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion remote-curl.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,14 @@ static int rpc_service(struct rpc_state *rpc, struct discovery *heads)

close(client.in);
client.in = -1;
strbuf_read(&rpc->result, client.out, 0);
if (!err) {
strbuf_read(&rpc->result, client.out, 0);
} else {
char buf[4096];
for (;;)
if (xread(client.out, buf, sizeof(buf)) <= 0)
break;
}

close(client.out);
client.out = -1;
Expand Down

0 comments on commit 6cdf022

Please sign in to comment.