Skip to content

Commit d3fce47

Browse files
phillipwoodgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7372eae commit d3fce47

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

builtin/rebase.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@ static int finish_rebase(struct rebase_options *opts)
760760
{
761761
struct strbuf dir = STRBUF_INIT;
762762
const char *argv_gc_auto[] = { "gc", "--auto", NULL };
763+
int ret = 0;
763764

764765
delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);
765766
apply_autostash(opts);
@@ -770,10 +771,11 @@ static int finish_rebase(struct rebase_options *opts)
770771
*/
771772
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
772773
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);
774776
strbuf_release(&dir);
775777

776-
return 0;
778+
return ret;
777779
}
778780

779781
static struct commit *peel_committish(const char *name)
@@ -1645,7 +1647,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
16451647
die(_("could not move back to %s"),
16461648
oid_to_hex(&options.orig_head));
16471649
remove_branch_state(the_repository);
1648-
ret = finish_rebase(&options);
1650+
ret = !!finish_rebase(&options);
16491651
goto cleanup;
16501652
}
16511653
case ACTION_QUIT: {

0 commit comments

Comments
 (0)