summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2019-05-20 12:09:26 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-05-28 17:26:36 (GMT)
commit97387c8bdd92596d79a84ce8a479c6b3c16d0cb7 (patch)
tree7a026f280c94a43ff9a66986ca49841b0c6937cb /builtin
parent1db65f324ecf246f7f5f8e0158daab0420dd18bc (diff)
downloadgit-97387c8bdd92596d79a84ce8a479c6b3c16d0cb7.zip
git-97387c8bdd92596d79a84ce8a479c6b3c16d0cb7.tar.gz
git-97387c8bdd92596d79a84ce8a479c6b3c16d0cb7.tar.bz2
am: read interactive input from stdin
In the conversion of git-am from shell script to C, we switched to using git_prompt(). Unlike the original shell command "read reply", this doesn't read from stdin at all, but rather from /dev/tty. In most cases this distinction wouldn't matter. We require (as the shell script did) that stdin is a tty, so they would generally be the same thing. But one important exception is our test suite: even with test_terminal, we cannot test "am --interactive" because it insists on reading from /dev/tty, not the pseudo-tty we've set up in the test script. Fixing this clears the way to adding tests in a future patch. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/am.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/builtin/am.c b/builtin/am.c
index 56b1738..9d8437c 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -1644,7 +1644,7 @@ static int do_interactive(struct am_state *state)
die(_("cannot be interactive without stdin connected to a terminal."));
for (;;) {
- const char *reply;
+ char reply[64];
puts(_("Commit Body is:"));
puts("--------------------------");
@@ -1656,7 +1656,9 @@ static int do_interactive(struct am_state *state)
* in your translation. The program will only accept English
* input at this point.
*/
- reply = git_prompt(_("Apply? [y]es/[n]o/[e]dit/[v]iew patch/[a]ccept all: "), PROMPT_ECHO);
+ printf(_("Apply? [y]es/[n]o/[e]dit/[v]iew patch/[a]ccept all: "));
+ if (!fgets(reply, sizeof(reply), stdin))
+ die("unable to read from stdin; aborting");
if (*reply == 'y' || *reply == 'Y') {
return 0;