]> git.ipfire.org Git - thirdparty/git.git/commitdiff
interactive: explicitly `fflush` stdout before expecting input
author마누엘 <nalla@hamal.uberspace.de>
Fri, 10 Apr 2020 11:27:51 +0000 (11:27 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 10 Apr 2020 17:27:16 +0000 (10:27 -0700)
At least one interactive command writes a prompt to `stdout` and then
reads user input on `stdin`: `git clean --interactive`. If the prompt is
left in the buffer, the user will not realize the program is waiting for
their input.

So let's just flush `stdout` before reading the user's input.

Signed-off-by: 마누엘 <nalla@hamal.uberspace.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
prompt.c

index 098dcfb7cf94e6571902ea70c16b8d17a21a13ef..5ded21a017f1089c5a5f63c998c3b11631c0a5d6 100644 (file)
--- a/prompt.c
+++ b/prompt.c
@@ -77,8 +77,10 @@ char *git_prompt(const char *prompt, int flags)
 
 int git_read_line_interactively(struct strbuf *line)
 {
-       int ret = strbuf_getline_lf(line, stdin);
+       int ret;
 
+       fflush(stdout);
+       ret = strbuf_getline_lf(line, stdin);
        if (ret != EOF)
                strbuf_trim_trailing_newline(line);