Skip to content

Commit a49305f

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 16685c2 commit a49305f

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(&choice, stdin, '\n') != 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(&confirm, stdin, '\n') != EOF)
662664
strbuf_trim(&confirm);
663665
else
@@ -755,6 +757,7 @@ static int ask_each_cmd(void)
755757
if (!eof) {
756758
qname = quote_path_relative(item->string, NULL, &buf);
757759
printf(_("remove %s? "), qname);
760+
fflush(stdout);
758761
if (strbuf_getline(&confirm, stdin, '\n') != EOF) {
759762
strbuf_trim(&confirm);
760763
} else {

0 commit comments

Comments
 (0)