rebase: warn if state directory cannot be removed
If rebase --quit cannot remove the state directory then it dies. However when rebase finishes normally or the user runs rebase --abort any errors that occur when removing the state directory are ignored. That is fixed by this commit. All of the callers of finish_rebase() except the code that handles --abort are careful to make sure they get a postive return value, do the same for --abort. 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
d3fce47d2df868287de1a15d769e78db2c3283a9
1 file changed
+5
-3
builtin/rebase.c
+5
-3
@@ -760,6 +760,7 @@ static int finish_rebase(struct rebase_options *opts)
760
{
761
struct strbuf dir = STRBUF_INIT;
762
const char *argv_gc_auto[] = { "gc", "--auto", NULL };
763
+ int ret = 0;
764
765
delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);
766
apply_autostash(opts);
@@ -770,10 +771,11 @@ static int finish_rebase(struct rebase_options *opts)
771
*/
772
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
773
strbuf_addstr(&dir, opts->state_dir);
773
- remove_dir_recursively(&dir, 0);
774
+ if (remove_dir_recursively(&dir, 0))
775
+ ret = error(_("could not remove '%s'"), opts->state_dir);
776
strbuf_release(&dir);
777
776
- return 0;
778
+ return ret;
779
}
780
781
static struct commit *peel_committish(const char *name)
@@ -1645,7 +1647,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1647
die(_("could not move back to %s"),
1648
oid_to_hex(&options.orig_head));
1649
remove_branch_state(the_repository);
1648
- ret = finish_rebase(&options);
1650
+ ret = !!finish_rebase(&options);
1651
goto cleanup;
1652
}
1653
case ACTION_QUIT: {