Code

remote-curl: accept empty line as terminator
[git.git] / remote-curl.c
index 17d8a9b377265aeed9765f04d505959e1f7fb9b0..7b3c113b0965d86ba8866741b4b3f238d319bfe0 100644 (file)
@@ -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)
@@ -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);