Thread (45 messages) flat view 45 messages, 3 authors, 2016-06-15
STALE3732d

Revision v3 of 5 in this series.

Revisions (5)
  1. v3 current
  2. v4 [diff vs current]
  3. v5 [diff vs current]
  4. v6 [diff vs current]
  5. v7 [diff vs current]

[PATCH/WIP v3 23/31] am: handle stray state directory

From: Paul Tan <hidden>
Date: 2016-06-15 23:05:22
Subsystem: the rest · Maintainer: Linus Torvalds

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 <redacted>
---
 builtin/am.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
diff --git a/builtin/am.c b/builtin/am.c
index 0d7e37c..bbef91f 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -1395,6 +1395,21 @@ int cmd_am(int argc, const char **argv, const char *prefix)
 		struct string_list paths = STRING_LIST_INIT_DUP;
 		int i;
 
+		/*
+		 * Possible stray dotest directory in the independent-run case.
+		 */
+		if (file_exists(state.dir.buf) && !state.rebasing) {
+			if (opt_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.buf);
+		}
+
 		if (opt_resume)
 			die(_("Resolve operation not in progress, we are not resuming."));
 
-- 
2.1.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help