Skip to content

Commit 5e5d961

Browse files
prertikgitster
authored andcommitted
builtin rebase: support --abort
This commit teaches the builtin rebase the "abort" action, which a user can call to roll back a rebase that is in progress. Signed-off-by: Pratik Karki <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 122420c commit 5e5d961

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

builtin/rebase.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
470470
NO_ACTION,
471471
ACTION_CONTINUE,
472472
ACTION_SKIP,
473+
ACTION_ABORT,
473474
} action = NO_ACTION;
474475
struct option builtin_rebase_options[] = {
475476
OPT_STRING(0, "onto", &options.onto_name,
@@ -496,6 +497,9 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
496497
ACTION_CONTINUE),
497498
OPT_CMDMODE(0, "skip", &action,
498499
N_("skip current patch and continue"), ACTION_SKIP),
500+
OPT_CMDMODE(0, "abort", &action,
501+
N_("abort and check out the original branch"),
502+
ACTION_ABORT),
499503
OPT_END(),
500504
};
501505

@@ -608,6 +612,22 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
608612
exit(1);
609613
goto run_rebase;
610614
}
615+
case ACTION_ABORT: {
616+
struct string_list merge_rr = STRING_LIST_INIT_DUP;
617+
options.action = "abort";
618+
619+
rerere_clear(&merge_rr);
620+
string_list_clear(&merge_rr, 1);
621+
622+
if (read_basic_state(&options))
623+
exit(1);
624+
if (reset_head(&options.orig_head, "reset",
625+
options.head_name, 0) < 0)
626+
die(_("could not move back to %s"),
627+
oid_to_hex(&options.orig_head));
628+
ret = finish_rebase(&options);
629+
goto cleanup;
630+
}
611631
default:
612632
die("TODO");
613633
}

0 commit comments

Comments
 (0)