builtin rebase: support --edit-todo and --show-current-patch
While these sub-commands are very different in spirit, their implementation is almost identical, so we convert them in one go. And since those are the last sub-commands that needed to be converted, now we can also turn that `default:` case into a bug (because we should now handle all the actions). 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
51e9ea6da76eb129e40a4fafaee6c2cdbcbe0d62
1 file changed
+22
-1
builtin/rebase.c
+22
-1
@@ -472,6 +472,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
472
ACTION_SKIP,
473
ACTION_ABORT,
474
ACTION_QUIT,
475
+ ACTION_EDIT_TODO,
476
+ ACTION_SHOW_CURRENT_PATCH,
477
} action = NO_ACTION;
478
struct option builtin_rebase_options[] = {
479
OPT_STRING(0, "onto", &options.onto_name,
@@ -503,6 +505,11 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
505
ACTION_ABORT),
506
OPT_CMDMODE(0, "quit", &action,
507
N_("abort but keep HEAD where it is"), ACTION_QUIT),
508
+ OPT_CMDMODE(0, "edit-todo", &action, N_("edit the todo list "
509
+ "during an interactive rebase"), ACTION_EDIT_TODO),
510
+ OPT_CMDMODE(0, "show-current-patch", &action,
511
+ N_("show the patch file being applied or merged"),
512
+ ACTION_SHOW_CURRENT_PATCH),
513
OPT_END(),
514
};
515
@@ -570,6 +577,10 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
577
usage_with_options(builtin_rebase_usage,
578
builtin_rebase_options);
579
580
+ if (action == ACTION_EDIT_TODO && !is_interactive(&options))
581
+ die(_("The --edit-todo action can only be used during "
582
+ "interactive rebase."));
583
+
584
switch (action) {
585
case ACTION_CONTINUE: {
586
struct object_id head;
@@ -639,8 +650,18 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
650
die(_("could not remove '%s'"), options.state_dir);
651
goto cleanup;
652
}
653
+ case ACTION_EDIT_TODO:
654
+ options.action = "edit-todo";
655
+ options.dont_finish_rebase = 1;
656
+ goto run_rebase;
657
+ case ACTION_SHOW_CURRENT_PATCH:
658
+ options.action = "show-current-patch";
659
+ options.dont_finish_rebase = 1;
660
+ goto run_rebase;
661
+ case NO_ACTION:
662
+ break;
663
default:
643
- die("TODO");
664
+ BUG("action: %d", action);
665
}
666
667
/* Make sure no rebase is in progress */