summaryrefslogtreecommitdiff
path: root/builtin/am.c
diff options
context:
space:
mode:
authorPaul Tan <pyokagan@gmail.com>2015-08-04 13:51:36 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-08-05 05:02:11 (GMT)
commit8d185503186ea0bc906defb9ecb1e9fb0e06efae (patch)
tree63b046f07be71b7a8a90240effe400d3a344981c /builtin/am.c
parent33388a71d23e6a296eb33879e418e857444f2d74 (diff)
downloadgit-8d185503186ea0bc906defb9ecb1e9fb0e06efae.zip
git-8d185503186ea0bc906defb9ecb1e9fb0e06efae.tar.gz
git-8d185503186ea0bc906defb9ecb1e9fb0e06efae.tar.bz2
builtin-am: reject patches when there's a session in progress
Since d1c5f2a (Add git-am, applymbox replacement., 2005-10-07), git-am would error out if the user gave it mbox(s) on the command-line, but there was a session in progress. Since c95b138 (Fix git-am safety checks, 2006-09-15), git-am would detect if the user attempted to feed it a mbox via stdin, by checking if stdin is not a tty and there is no resume command given. Re-implement the above two safety checks. Signed-off-by: Paul Tan <pyokagan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/am.c')
-rw-r--r--builtin/am.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/builtin/am.c b/builtin/am.c
index 6c24d07..d4b4b86 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -1148,6 +1148,21 @@ int cmd_am(int argc, const char **argv, const char *prefix)
die(_("failed to read the index"));
if (am_in_progress(&state)) {
+ /*
+ * Catch user error to feed us patches when there is a session
+ * in progress:
+ *
+ * 1. mbox path(s) are provided on the command-line.
+ * 2. stdin is not a tty: the user is trying to feed us a patch
+ * from standard input. This is somewhat unreliable -- stdin
+ * could be /dev/null for example and the caller did not
+ * intend to feed us a patch but wanted to continue
+ * unattended.
+ */
+ if (argc || (resume == RESUME_FALSE && !isatty(0)))
+ die(_("previous rebase directory %s still exists but mbox given."),
+ state.dir);
+
if (resume == RESUME_FALSE)
resume = RESUME_APPLY;