All of lore.kernel.org
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: Git Mailing List <git@vger.kernel.org>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Junio C Hamano <gitster@pobox.com>
Cc: Phillip Wood <phillip.wood@dunelm.org.uk>
Subject: [PATCH v2 3/4] sequencer: return errors from sequencer_remove_state()
Date: Tue, 14 May 2019 19:03:48 +0100	[thread overview]
Message-ID: <20190514180349.17245-4-phillip.wood123@gmail.com> (raw)
In-Reply-To: <20190514180349.17245-1-phillip.wood123@gmail.com>

From: Phillip Wood <phillip.wood@dunelm.org.uk>

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>
---
 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


  parent reply	other threads:[~2019-05-14 18:04 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-26 10:32 [PATCH] rebase --abort: cleanup refs/rewritten Phillip Wood
2019-04-29 16:07 ` Johannes Schindelin
2019-04-30  8:54   ` Phillip Wood
2019-04-30 22:49     ` Johannes Schindelin
2019-05-01 15:36       ` Phillip Wood
2019-05-03  9:21         ` Johannes Schindelin
2019-05-03 10:06           ` Phillip Wood
2019-05-07 15:15 ` SZEDER Gábor
2019-05-07 16:07   ` Junio C Hamano
2019-05-07 20:06     ` Phillip Wood
2019-05-14 18:03 ` [PATCH v2 0/4] rebase --abort/--quit: " Phillip Wood
2019-05-14 18:03   ` [PATCH v2 1/4] rebase: fix a memory leak Phillip Wood
2019-05-14 18:03   ` [PATCH v2 2/4] rebase: warn if state directory cannot be removed Phillip Wood
2019-05-14 18:03   ` Phillip Wood [this message]
2019-05-14 18:03   ` [PATCH v2 4/4] rebase --abort/--quit: cleanup refs/rewritten Phillip Wood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190514180349.17245-4-phillip.wood123@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=phillip.wood@dunelm.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.