summaryrefslogtreecommitdiff
path: root/add-patch.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2020-04-10 11:27:50 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-04-10 17:26:31 (GMT)
commit08d383f23e80e418c844952fcc4e2e635962c292 (patch)
tree224078e2c20f9b24a935a4afa0c42799aaa69963 /add-patch.c
parent9fadedd637b312089337d73c3ed8447e9f0aa775 (diff)
downloadgit-08d383f23e80e418c844952fcc4e2e635962c292.zip
git-08d383f23e80e418c844952fcc4e2e635962c292.tar.gz
git-08d383f23e80e418c844952fcc4e2e635962c292.tar.bz2
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-patch.c')
-rw-r--r--add-patch.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/add-patch.c b/add-patch.c
index d8dafa8..d8bfe37 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -7,6 +7,7 @@
#include "color.h"
#include "diff.h"
#include "compat/terminal.h"
+#include "prompt.h"
enum prompt_mode_type {
PROMPT_MODE_CHANGE = 0, PROMPT_DELETION, PROMPT_HUNK,
@@ -1158,9 +1159,8 @@ static int read_single_character(struct add_p_state *s)
return res;
}
- if (strbuf_getline(&s->answer, stdin) == EOF)
+ if (git_read_line_interactively(&s->answer) == EOF)
return EOF;
- strbuf_trim_trailing_newline(&s->answer);
return 0;
}