Skip to content

Commit 8d18550

Browse files
pyokagangitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 33388a7 commit 8d18550

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

builtin/am.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,21 @@ int cmd_am(int argc, const char **argv, const char *prefix)
11481148
die(_("failed to read the index"));
11491149

11501150
if (am_in_progress(&state)) {
1151+
/*
1152+
* Catch user error to feed us patches when there is a session
1153+
* in progress:
1154+
*
1155+
* 1. mbox path(s) are provided on the command-line.
1156+
* 2. stdin is not a tty: the user is trying to feed us a patch
1157+
* from standard input. This is somewhat unreliable -- stdin
1158+
* could be /dev/null for example and the caller did not
1159+
* intend to feed us a patch but wanted to continue
1160+
* unattended.
1161+
*/
1162+
if (argc || (resume == RESUME_FALSE && !isatty(0)))
1163+
die(_("previous rebase directory %s still exists but mbox given."),
1164+
state.dir);
1165+
11511166
if (resume == RESUME_FALSE)
11521167
resume = RESUME_APPLY;
11531168

0 commit comments

Comments
 (0)