Skip to content

Commit 1843f0c

Browse files
SRabbeliergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e173587 commit 1843f0c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

remote-curl.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,14 @@ int main(int argc, const char **argv)
855855
http_init(remote);
856856

857857
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)
859866
break;
860867
if (!prefixcmp(buf.buf, "fetch ")) {
861868
if (nongit)
@@ -895,6 +902,7 @@ int main(int argc, const char **argv)
895902
printf("\n");
896903
fflush(stdout);
897904
} else {
905+
fprintf(stderr, "Unknown command '%s'\n", buf.buf);
898906
return 1;
899907
}
900908
strbuf_reset(&buf);

0 commit comments

Comments
 (0)