Thread (13 messages) 13 messages, 3 authors, 2019-05-14
DORMANTno replies

[PATCH v2 3/4] sequencer: return errors from sequencer_remove_state()

From: Phillip Wood <hidden>
Date: 2019-05-14 18:04:10
Subsystem: the rest · Maintainer: Linus Torvalds

From: Phillip Wood <redacted>

If there is an error when removing the state directory then we should
report it. This matches what the non-interactive rebase does.

Signed-off-by: Phillip Wood <redacted>
---
 sequencer.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/sequencer.c b/sequencer.c
index 610b7ece14..258e583156 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -274,7 +274,7 @@ static const char *gpg_sign_opt_quoted(struct replay_opts *opts)
 int sequencer_remove_state(struct replay_opts *opts)
 {
 	struct strbuf buf = STRBUF_INIT;
-	int i;
+	int i, ret = 0;
 
 	if (is_rebase_i(opts) &&
 	    strbuf_read_file(&buf, rebase_path_refs_to_delete(), 0) > 0) {
@@ -283,8 +283,10 @@ int sequencer_remove_state(struct replay_opts *opts)
 			char *eol = strchr(p, '\n');
 			if (eol)
 				*eol = '\0';
-			if (delete_ref("(rebase -i) cleanup", p, NULL, 0) < 0)
+			if (delete_ref("(rebase -i) cleanup", p, NULL, 0) < 0) {
 				warning(_("could not delete '%s'"), p);
+				ret = -1;
+			}
 			if (!eol)
 				break;
 			p = eol + 1;
@@ -300,10 +302,11 @@ int sequencer_remove_state(struct replay_opts *opts)
 
 	strbuf_reset(&buf);
 	strbuf_addstr(&buf, get_dir(opts));
-	remove_dir_recursively(&buf, 0);
+	if (remove_dir_recursively(&buf, 0))
+		ret = error(_("could not remove '%s'"), buf.buf);
 	strbuf_release(&buf);
 
-	return 0;
+	return ret;
 }
 
 static const char *action_name(const struct replay_opts *opts)
-- 
2.21.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help