Skip to content

Commit 51e9ea6

Browse files
prertikgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5a61494 commit 51e9ea6

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

builtin/rebase.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
472472
ACTION_SKIP,
473473
ACTION_ABORT,
474474
ACTION_QUIT,
475+
ACTION_EDIT_TODO,
476+
ACTION_SHOW_CURRENT_PATCH,
475477
} action = NO_ACTION;
476478
struct option builtin_rebase_options[] = {
477479
OPT_STRING(0, "onto", &options.onto_name,
@@ -503,6 +505,11 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
503505
ACTION_ABORT),
504506
OPT_CMDMODE(0, "quit", &action,
505507
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),
506513
OPT_END(),
507514
};
508515

@@ -570,6 +577,10 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
570577
usage_with_options(builtin_rebase_usage,
571578
builtin_rebase_options);
572579

580+
if (action == ACTION_EDIT_TODO && !is_interactive(&options))
581+
die(_("The --edit-todo action can only be used during "
582+
"interactive rebase."));
583+
573584
switch (action) {
574585
case ACTION_CONTINUE: {
575586
struct object_id head;
@@ -639,8 +650,18 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
639650
die(_("could not remove '%s'"), options.state_dir);
640651
goto cleanup;
641652
}
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;
642663
default:
643-
die("TODO");
664+
BUG("action: %d", action);
644665
}
645666

646667
/* Make sure no rebase is in progress */

0 commit comments

Comments
 (0)