Skip to content

Commit b91c2a1

Browse files
nalladscho
nalla
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 a63ead9 commit b91c2a1

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
@@ -576,6 +576,7 @@ static int *list_and_choose(struct menu_opts *opts, struct menu_stuff *stuff)
576576
clean_get_color(CLEAN_COLOR_RESET));
577577
}
578578

579+
fflush(stdout);
579580
if (strbuf_getline_lf(&choice, stdin) != EOF) {
580581
strbuf_trim(&choice);
581582
} else {
@@ -658,6 +659,7 @@ static int filter_by_patterns_cmd(void)
658659
clean_print_color(CLEAN_COLOR_PROMPT);
659660
printf(_("Input ignore patterns>> "));
660661
clean_print_color(CLEAN_COLOR_RESET);
662+
fflush(stdout);
661663
if (strbuf_getline_lf(&confirm, stdin) != EOF)
662664
strbuf_trim(&confirm);
663665
else
@@ -756,6 +758,7 @@ static int ask_each_cmd(void)
756758
qname = quote_path_relative(item->string, NULL, &buf);
757759
/* TRANSLATORS: Make sure to keep [y/N] as is */
758760
printf(_("Remove %s [y/N]? "), qname);
761+
fflush(stdout);
759762
if (strbuf_getline_lf(&confirm, stdin) != EOF) {
760763
strbuf_trim(&confirm);
761764
} else {

0 commit comments

Comments
 (0)