X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=remote-curl.c;h=0aa4bfed309d6c439fac4ff2a0df6a468307e7bf;hb=6c65b5ea439165512d128e18829b67688ddab9cc;hp=69831e931af1fe2a3e668239e8c4bb73a7bfb936;hpb=6d1cdadbeeb03f40250526e29b1f1a91582911d8;p=git.git diff --git a/remote-curl.c b/remote-curl.c index 69831e931..0aa4bfed3 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -573,7 +573,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; @@ -855,7 +862,14 @@ int main(int argc, const char **argv) http_init(remote); do { - if (strbuf_getline(&buf, stdin, '\n') == EOF) + if (strbuf_getline(&buf, stdin, '\n') == EOF) { + if (ferror(stdin)) + fprintf(stderr, "Error reading command stream\n"); + else + fprintf(stderr, "Unexpected end of command stream\n"); + return 1; + } + if (buf.len == 0) break; if (!prefixcmp(buf.buf, "fetch ")) { if (nongit) @@ -895,6 +909,7 @@ int main(int argc, const char **argv) printf("\n"); fflush(stdout); } else { + fprintf(stderr, "Unknown command '%s'\n", buf.buf); return 1; } strbuf_reset(&buf);