|
18 | 18 | #include "color.h" |
19 | 19 | #include "pathspec.h" |
20 | 20 | #include "help.h" |
| 21 | +#include "prompt.h" |
21 | 22 |
|
22 | 23 | static int force = -1; /* unset */ |
23 | 24 | static int interactive; |
@@ -420,7 +421,6 @@ static int find_unique(const char *choice, struct menu_stuff *menu_stuff) |
420 | 421 | return found; |
421 | 422 | } |
422 | 423 |
|
423 | | - |
424 | 424 | /* |
425 | 425 | * Parse user input, and return choice(s) for menu (menu_stuff). |
426 | 426 | * |
@@ -580,9 +580,7 @@ static int *list_and_choose(struct menu_opts *opts, struct menu_stuff *stuff) |
580 | 580 | clean_get_color(CLEAN_COLOR_RESET)); |
581 | 581 | } |
582 | 582 |
|
583 | | - if (strbuf_getline_lf(&choice, stdin) != EOF) { |
584 | | - strbuf_trim(&choice); |
585 | | - } else { |
| 583 | + if (git_read_line_interactively(&choice) == EOF) { |
586 | 584 | eof = 1; |
587 | 585 | break; |
588 | 586 | } |
@@ -662,9 +660,7 @@ static int filter_by_patterns_cmd(void) |
662 | 660 | clean_print_color(CLEAN_COLOR_PROMPT); |
663 | 661 | printf(_("Input ignore patterns>> ")); |
664 | 662 | clean_print_color(CLEAN_COLOR_RESET); |
665 | | - if (strbuf_getline_lf(&confirm, stdin) != EOF) |
666 | | - strbuf_trim(&confirm); |
667 | | - else |
| 663 | + if (git_read_line_interactively(&confirm) == EOF) |
668 | 664 | putchar('\n'); |
669 | 665 |
|
670 | 666 | /* quit filter_by_pattern mode if press ENTER or Ctrl-D */ |
@@ -760,9 +756,7 @@ static int ask_each_cmd(void) |
760 | 756 | qname = quote_path_relative(item->string, NULL, &buf); |
761 | 757 | /* TRANSLATORS: Make sure to keep [y/N] as is */ |
762 | 758 | printf(_("Remove %s [y/N]? "), qname); |
763 | | - if (strbuf_getline_lf(&confirm, stdin) != EOF) { |
764 | | - strbuf_trim(&confirm); |
765 | | - } else { |
| 759 | + if (git_read_line_interactively(&confirm) == EOF) { |
766 | 760 | putchar('\n'); |
767 | 761 | eof = 1; |
768 | 762 | } |
|
0 commit comments