Skip to content

Commit f9e7ab2

Browse files
nalladscho
authored andcommitted
mingw: explicitly fflush stdout
For performance reasons `stdout` is not unbuffered by default. That leads to problems if after printing to `stdout` a read on `stdin` is performed. For that reason interactive commands like `git clean -i` do not function properly anymore if the `stdout` is not flushed by `fflush(stdout)` before trying to read from `stdin`. In the case of `git clean -i` all reads on `stdin` were preceded by a `fflush(stdout)` call. Signed-off-by: nalla <[email protected]>
1 parent 974b6e8 commit f9e7ab2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

builtin/clean.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,7 @@ static int *list_and_choose(struct menu_opts *opts, struct menu_stuff *stuff)
596596
clean_get_color(CLEAN_COLOR_RESET));
597597
}
598598

599+
fflush(stdout);
599600
if (strbuf_getline(&choice, stdin, '\n') != EOF) {
600601
strbuf_trim(&choice);
601602
} else {
@@ -678,6 +679,7 @@ static int filter_by_patterns_cmd(void)
678679
clean_print_color(CLEAN_COLOR_PROMPT);
679680
printf(_("Input ignore patterns>> "));
680681
clean_print_color(CLEAN_COLOR_RESET);
682+
fflush(stdout);
681683
if (strbuf_getline(&confirm, stdin, '\n') != EOF)
682684
strbuf_trim(&confirm);
683685
else
@@ -776,6 +778,7 @@ static int ask_each_cmd(void)
776778
qname = quote_path_relative(item->string, NULL, &buf);
777779
/* TRANSLATORS: Make sure to keep [y/N] as is */
778780
printf(_("Remove %s [y/N]? "), qname);
781+
fflush(stdout);
779782
if (strbuf_getline(&confirm, stdin, '\n') != EOF) {
780783
strbuf_trim(&confirm);
781784
} else {

0 commit comments

Comments
 (0)