summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2019-05-20 12:11:13 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-05-28 17:26:36 (GMT)
commit6e7baf246a2d12480d4dbc04c47efb66408c1927 (patch)
tree845ae0fcb12be2b10f7661fc6c5f1023de4b0209 /builtin
parent97387c8bdd92596d79a84ce8a479c6b3c16d0cb7 (diff)
downloadgit-6e7baf246a2d12480d4dbc04c47efb66408c1927.zip
git-6e7baf246a2d12480d4dbc04c47efb66408c1927.tar.gz
git-6e7baf246a2d12480d4dbc04c47efb66408c1927.tar.bz2
am: drop tty requirement for --interactive
We have required that the stdin of "am --interactive" be a tty since a1451104ac (git-am: interactive should fail gracefully., 2005-10-12). However, this isn't strictly necessary, and makes the tool harder to test (and is unlike all of our other --interactive commands). The goal of that commit was to make sure that somebody does not do: git am --interactive <mbox and cause us to read commands from the mbox. But we can simply check up front for this case and complain before entering the interactive loop. Technically this disallows: git am --interactive </dev/null where our lack of patches means we would never prompt for anything, and so the old code would not notice our lack of tty (and now we'd die early). But since such a command is totally pointless, it's no loss. 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, 3 insertions, 3 deletions
diff --git a/builtin/am.c b/builtin/am.c
index 9d8437c..9cbbd8e 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -1640,9 +1640,6 @@ static int do_interactive(struct am_state *state)
{
assert(state->msg);
- if (!isatty(0))
- die(_("cannot be interactive without stdin connected to a terminal."));
-
for (;;) {
char reply[64];
@@ -2327,6 +2324,9 @@ int cmd_am(int argc, const char **argv, const char *prefix)
argv_array_push(&paths, mkpath("%s/%s", prefix, argv[i]));
}
+ if (state.interactive && !paths.argc)
+ die(_("interactive mode requires patches on the command line"));
+
am_setup(&state, patch_format, paths.argv, keep_cr);
argv_array_clear(&paths);