remote-curl: accept empty line as terminator

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>

Sverre Rabbelier committed Jul 16, 2011 at 15:03 UTC 1843f0ce4d31e3c37f7d07dd1d13f6fb034ac2b0
1 file changed +9 -1
remote-curl.c
+9 -1
@@ -855,7 +855,14 @@ int main(int argc, const char **argv)
855 http_init(remote);
856
857 do {
858 - if (strbuf_getline(&buf, stdin, '\n') == EOF)
858 + if (strbuf_getline(&buf, stdin, '\n') == EOF) {
859 + if (ferror(stdin))
860 + fprintf(stderr, "Error reading command stream\n");
861 + else
862 + fprintf(stderr, "Unexpected end of command stream\n");
863 + return 1;
864 + }
865 + if (buf.len == 0)
866 break;
867 if (!prefixcmp(buf.buf, "fetch ")) {
868 if (nongit)
@@ -895,6 +902,7 @@ int main(int argc, const char **argv)
902 printf("\n");
903 fflush(stdout);
904 } else {
905 + fprintf(stderr, "Unknown command '%s'\n", buf.buf);
906 return 1;
907 }
908 strbuf_reset(&buf);