Skip to content

Commit eb19107

Browse files
committed
Merge branch 'fflush-in-git-clean'
After writing to `stdout` and before reading from `stdin`, it is a good idea to flush the former. Signed-off-by: Johannes Schindelin <[email protected]>
2 parents 7bc7952 + 1eb78fd commit eb19107

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

582+
fflush(stdout);
582583
if (strbuf_getline_lf(&choice, stdin) != EOF) {
583584
strbuf_trim(&choice);
584585
} else {
@@ -661,6 +662,7 @@ static int filter_by_patterns_cmd(void)
661662
clean_print_color(CLEAN_COLOR_PROMPT);
662663
printf(_("Input ignore patterns>> "));
663664
clean_print_color(CLEAN_COLOR_RESET);
665+
fflush(stdout);
664666
if (strbuf_getline_lf(&confirm, stdin) != EOF)
665667
strbuf_trim(&confirm);
666668
else
@@ -759,6 +761,7 @@ static int ask_each_cmd(void)
759761
qname = quote_path_relative(item->string, NULL, &buf);
760762
/* TRANSLATORS: Make sure to keep [y/N] as is */
761763
printf(_("Remove %s [y/N]? "), qname);
764+
fflush(stdout);
762765
if (strbuf_getline_lf(&confirm, stdin) != EOF) {
763766
strbuf_trim(&confirm);
764767
} else {

0 commit comments

Comments
 (0)