Skip to content

Commit

Permalink
remote-curl: accept empty line as terminator
Browse files Browse the repository at this point in the history
This went unnoticed because the transport helper infrastructore did
not check the return value of the helper, nor did the helper print
anything before exiting.

While at it also make sure that the stream doesn't end unexpectedly.

Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Sverre Rabbelier authored and Junio C Hamano committed Jul 19, 2011
1 parent e173587 commit 1843f0c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion remote-curl.c
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,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)
Expand Down Expand Up @@ -895,6 +902,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);
Expand Down

0 comments on commit 1843f0c

Please sign in to comment.