builtin rebase: support --skip

This commit adds the option `--skip` which is used to restart rebase after skipping the current patch. Signed-off-by: Pratik Karki <predatoramigo@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Pratik Karki committed Aug 8, 2018 at 20:51 UTC 122420c295310de9ec64da5feab738a6591a65ce
1 file changed +18
builtin/rebase.c
+18
@@ -21,6 +21,7 @@
21 #include "diff.h"
22 #include "wt-status.h"
23 #include "revision.h"
24 +#include "rerere.h"
25
26 static char const * const builtin_rebase_usage[] = {
27 N_("git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] "
@@ -468,6 +469,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
469 enum {
470 NO_ACTION,
471 ACTION_CONTINUE,
472 + ACTION_SKIP,
473 } action = NO_ACTION;
474 struct option builtin_rebase_options[] = {
475 OPT_STRING(0, "onto", &options.onto_name,
@@ -492,6 +494,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
494 REBASE_FORCE),
495 OPT_CMDMODE(0, "continue", &action, N_("continue"),
496 ACTION_CONTINUE),
497 + OPT_CMDMODE(0, "skip", &action,
498 + N_("skip current patch and continue"), ACTION_SKIP),
499 OPT_END(),
500 };
501
@@ -590,6 +594,20 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
594 exit(1);
595 goto run_rebase;
596 }
597 + case ACTION_SKIP: {
598 + struct string_list merge_rr = STRING_LIST_INIT_DUP;
599 +
600 + options.action = "skip";
601 +
602 + rerere_clear(&merge_rr);
603 + string_list_clear(&merge_rr, 1);
604 +
605 + if (reset_head(NULL, "reset", NULL, 0) < 0)
606 + die(_("could not discard worktree changes"));
607 + if (read_basic_state(&options))
608 + exit(1);
609 + goto run_rebase;
610 + }
611 default:
612 die("TODO");
613 }