Skip to content

Commit 122420c

Browse files
prertikgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f957362 commit 122420c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

builtin/rebase.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "diff.h"
2222
#include "wt-status.h"
2323
#include "revision.h"
24+
#include "rerere.h"
2425

2526
static char const * const builtin_rebase_usage[] = {
2627
N_("git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] "
@@ -468,6 +469,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
468469
enum {
469470
NO_ACTION,
470471
ACTION_CONTINUE,
472+
ACTION_SKIP,
471473
} action = NO_ACTION;
472474
struct option builtin_rebase_options[] = {
473475
OPT_STRING(0, "onto", &options.onto_name,
@@ -492,6 +494,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
492494
REBASE_FORCE),
493495
OPT_CMDMODE(0, "continue", &action, N_("continue"),
494496
ACTION_CONTINUE),
497+
OPT_CMDMODE(0, "skip", &action,
498+
N_("skip current patch and continue"), ACTION_SKIP),
495499
OPT_END(),
496500
};
497501

@@ -590,6 +594,20 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
590594
exit(1);
591595
goto run_rebase;
592596
}
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+
}
593611
default:
594612
die("TODO");
595613
}

0 commit comments

Comments
 (0)