sequencer: return errors from sequencer_remove_state()

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 <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Phillip Wood committed May 14, 2019 at 19:03 UTC 37e9ee5cb90db0831d5d58bed82149ba67917d73
1 file changed +7 -4
sequencer.c
+7 -4
@@ -274,7 +274,7 @@ static const char *gpg_sign_opt_quoted(struct replay_opts *opts)
274 int sequencer_remove_state(struct replay_opts *opts)
275 {
276 struct strbuf buf = STRBUF_INIT;
277 - int i;
277 + int i, ret = 0;
278
279 if (is_rebase_i(opts) &&
280 strbuf_read_file(&buf, rebase_path_refs_to_delete(), 0) > 0) {
@@ -283,8 +283,10 @@ int sequencer_remove_state(struct replay_opts *opts)
283 char *eol = strchr(p, '\n');
284 if (eol)
285 *eol = '\0';
286 - if (delete_ref("(rebase -i) cleanup", p, NULL, 0) < 0)
286 + if (delete_ref("(rebase -i) cleanup", p, NULL, 0) < 0) {
287 warning(_("could not delete '%s'"), p);
288 + ret = -1;
289 + }
290 if (!eol)
291 break;
292 p = eol + 1;
@@ -300,10 +302,11 @@ int sequencer_remove_state(struct replay_opts *opts)
302
303 strbuf_reset(&buf);
304 strbuf_addstr(&buf, get_dir(opts));
303 - remove_dir_recursively(&buf, 0);
305 + if (remove_dir_recursively(&buf, 0))
306 + ret = error(_("could not remove '%s'"), buf.buf);
307 strbuf_release(&buf);
308
306 - return 0;
309 + return ret;
310 }
311
312 static const char *action_name(const struct replay_opts *opts)