From 08d383f23e80e418c844952fcc4e2e635962c292 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 10 Apr 2020 11:27:50 +0000 Subject: interactive: refactor code asking the user for interactive input There are quite a few code locations (e.g. `git clean --interactive`) where Git asks the user for an answer. In preparation for fixing a bug shared by all of them, and also to DRY up the code, let's refactor it. Please note that most of these callers trimmed white-space both at the beginning and at the end of the answer, instead of trimming only the end (as the caller in `add-patch.c` does). Therefore, technically speaking, we change behavior in this patch. At the same time, it can be argued that this is actually a bug fix. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- shell.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'shell.c') diff --git a/shell.c b/shell.c index 54cca7439d..cef7ffdc9e 100644 --- a/shell.c +++ b/shell.c @@ -4,6 +4,7 @@ #include "strbuf.h" #include "run-command.h" #include "alias.h" +#include "prompt.h" #define COMMAND_DIR "git-shell-commands" #define HELP_COMMAND COMMAND_DIR "/help" @@ -76,12 +77,11 @@ static void run_shell(void) int count; fprintf(stderr, "git> "); - if (strbuf_getline_lf(&line, stdin) == EOF) { + if (git_read_line_interactively(&line) == EOF) { fprintf(stderr, "\n"); strbuf_release(&line); break; } - strbuf_trim(&line); rawargs = strbuf_detach(&line, NULL); split_args = xstrdup(rawargs); count = split_cmdline(split_args, &argv); -- cgit v1.2.3