Skip to content

Commit 1f09aed

Browse files
마누엘gitster
authored andcommitted
interactive: explicitly fflush stdout before expecting input
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: 마누엘 <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 08d383f commit 1f09aed

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

prompt.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ char *git_prompt(const char *prompt, int flags)
7777

7878
int git_read_line_interactively(struct strbuf *line)
7979
{
80-
int ret = strbuf_getline_lf(line, stdin);
80+
int ret;
8181

82+
fflush(stdout);
83+
ret = strbuf_getline_lf(line, stdin);
8284
if (ret != EOF)
8385
strbuf_trim_trailing_newline(line);
8486

0 commit comments

Comments
 (0)