Skip to content

Commit 8ed143e

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 0e280aa commit 8ed143e

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
@@ -581,6 +581,7 @@ static int *list_and_choose(struct menu_opts *opts, struct menu_stuff *stuff)
581581
clean_get_color(CLEAN_COLOR_RESET));
582582
}
583583

584+
fflush(stdout);
584585
if (strbuf_getline_lf(&choice, stdin) != EOF) {
585586
strbuf_trim(&choice);
586587
} else {
@@ -663,6 +664,7 @@ static int filter_by_patterns_cmd(void)
663664
clean_print_color(CLEAN_COLOR_PROMPT);
664665
printf(_("Input ignore patterns>> "));
665666
clean_print_color(CLEAN_COLOR_RESET);
667+
fflush(stdout);
666668
if (strbuf_getline_lf(&confirm, stdin) != EOF)
667669
strbuf_trim(&confirm);
668670
else
@@ -761,6 +763,7 @@ static int ask_each_cmd(void)
761763
qname = quote_path_relative(item->string, NULL, &buf);
762764
/* TRANSLATORS: Make sure to keep [y/N] as is */
763765
printf(_("Remove %s [y/N]? "), qname);
766+
fflush(stdout);
764767
if (strbuf_getline_lf(&confirm, stdin) != EOF) {
765768
strbuf_trim(&confirm);
766769
} else {

0 commit comments

Comments
 (0)