Skip to content

Commit 5a61494

Browse files
prertikgitster
authored andcommitted
builtin rebase: support --quit
With this patch, the builtin rebase handles the `--quit` action which can be used to abort a rebase without rolling back any changes performed during the rebase (this is useful when a user forgot that they were in the middle of a rebase and continued working normally). Signed-off-by: Pratik Karki <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5e5d961 commit 5a61494

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

builtin/rebase.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
471471
ACTION_CONTINUE,
472472
ACTION_SKIP,
473473
ACTION_ABORT,
474+
ACTION_QUIT,
474475
} action = NO_ACTION;
475476
struct option builtin_rebase_options[] = {
476477
OPT_STRING(0, "onto", &options.onto_name,
@@ -500,6 +501,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
500501
OPT_CMDMODE(0, "abort", &action,
501502
N_("abort and check out the original branch"),
502503
ACTION_ABORT),
504+
OPT_CMDMODE(0, "quit", &action,
505+
N_("abort but keep HEAD where it is"), ACTION_QUIT),
503506
OPT_END(),
504507
};
505508

@@ -628,6 +631,14 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
628631
ret = finish_rebase(&options);
629632
goto cleanup;
630633
}
634+
case ACTION_QUIT: {
635+
strbuf_reset(&buf);
636+
strbuf_addstr(&buf, options.state_dir);
637+
ret = !!remove_dir_recursively(&buf, 0);
638+
if (ret)
639+
die(_("could not remove '%s'"), options.state_dir);
640+
goto cleanup;
641+
}
631642
default:
632643
die("TODO");
633644
}

0 commit comments

Comments
 (0)