Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2020-04-10 14:27:50 +0300
committerJunio C Hamano <gitster@pobox.com>2020-04-10 20:26:31 +0300
commit08d383f23e80e418c844952fcc4e2e635962c292 (patch)
tree224078e2c20f9b24a935a4afa0c42799aaa69963 /add-interactive.c
parent9fadedd637b312089337d73c3ed8447e9f0aa775 (diff)
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 <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'add-interactive.c')
-rw-r--r--add-interactive.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/add-interactive.c b/add-interactive.c
index 4a9bf85cac..29cd2fe020 100644
--- a/add-interactive.c
+++ b/add-interactive.c
@@ -9,6 +9,7 @@
#include "lockfile.h"
#include "dir.h"
#include "run-command.h"
+#include "prompt.h"
static void init_color(struct repository *r, struct add_i_state *s,
const char *slot_name, char *dst,
@@ -289,13 +290,12 @@ static ssize_t list_and_choose(struct add_i_state *s,
fputs(singleton ? "> " : ">> ", stdout);
fflush(stdout);
- if (strbuf_getline(&input, stdin) == EOF) {
+ if (git_read_line_interactively(&input) == EOF) {
putchar('\n');
if (immediate)
res = LIST_AND_CHOOSE_QUIT;
break;
}
- strbuf_trim(&input);
if (!input.len)
break;