Skip to content

Commit 9bf22e4

Browse files
마누엘Git for Windows Build Agent
authored andcommitted
mingw: explicitly fflush stdout
For performance reasons `stdout` is buffered 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`. So let's precede all reads on `stdin` in `git clean -i` by flushing `stdout`. Signed-off-by: 마누엘 <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent c73f6a7 commit 9bf22e4

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

581+
fflush(stdout);
581582
if (strbuf_getline_lf(&choice, stdin) != EOF) {
582583
strbuf_trim(&choice);
583584
} else {
@@ -660,6 +661,7 @@ static int filter_by_patterns_cmd(void)
660661
clean_print_color(CLEAN_COLOR_PROMPT);
661662
printf(_("Input ignore patterns>> "));
662663
clean_print_color(CLEAN_COLOR_RESET);
664+
fflush(stdout);
663665
if (strbuf_getline_lf(&confirm, stdin) != EOF)
664666
strbuf_trim(&confirm);
665667
else
@@ -758,6 +760,7 @@ static int ask_each_cmd(void)
758760
qname = quote_path_relative(item->string, NULL, &buf);
759761
/* TRANSLATORS: Make sure to keep [y/N] as is */
760762
printf(_("Remove %s [y/N]? "), qname);
763+
fflush(stdout);
761764
if (strbuf_getline_lf(&confirm, stdin) != EOF) {
762765
strbuf_trim(&confirm);
763766
} else {

0 commit comments

Comments
 (0)