summaryrefslogtreecommitdiff
path: root/builtin/am.c
diff options
context:
space:
mode:
authorPaul Tan <pyokagan@gmail.com>2015-08-04 13:51:44 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-08-05 05:02:11 (GMT)
commit6d42ac2941cac80b44e318d867bae7979c1af6fe (patch)
treeded5cce7dfe85003b618df8e41c933ccd17d757b /builtin/am.c
parentdf2760a576a8d26e26a6a11aa497e347c7402fd3 (diff)
downloadgit-6d42ac2941cac80b44e318d867bae7979c1af6fe.zip
git-6d42ac2941cac80b44e318d867bae7979c1af6fe.tar.gz
git-6d42ac2941cac80b44e318d867bae7979c1af6fe.tar.bz2
builtin-am: handle stray state directory
Should git-am terminate unexpectedly between the point where the state directory is created, but the "next" and "last" files are not written yet, a stray state directory will be left behind. As such, since b141f3c (am: handle stray $dotest directory, 2013-06-15), git-am.sh explicitly recognizes such a stray directory, and allows the user to remove it with am --abort. Re-implement this feature in builtin/am.c. 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.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/builtin/am.c b/builtin/am.c
index a02c84e..47dd4c7 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -1530,6 +1530,23 @@ int cmd_am(int argc, const char **argv, const char *prefix)
struct argv_array paths = ARGV_ARRAY_INIT;
int i;
+ /*
+ * Handle stray state directory in the independent-run case. In
+ * the --rebasing case, it is up to the caller to take care of
+ * stray directories.
+ */
+ if (file_exists(state.dir) && !state.rebasing) {
+ if (resume == RESUME_ABORT) {
+ am_destroy(&state);
+ am_state_release(&state);
+ return 0;
+ }
+
+ die(_("Stray %s directory found.\n"
+ "Use \"git am --abort\" to remove it."),
+ state.dir);
+ }
+
if (resume)
die(_("Resolve operation not in progress, we are not resuming."));