git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 5/7] builtin rebase: support --edit-todo and --show-current-patch

From
Pratik Karki <predatoramigo@gmail.com>
Date
Aug 8, 2018, 15:06 UTC
Message-ID
<20180808150622.9614-6-predatoramigo@gmail.com>
In-Reply-To
<20180808150622.9614-1-predatoramigo@gmail.com>

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>
---
 builtin/rebase.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 0d805480a1..e3dd2f511e 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -472,6 +472,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 		ACTION_SKIP,
 		ACTION_ABORT,
 		ACTION_QUIT,
+		ACTION_EDIT_TODO,
+		ACTION_SHOW_CURRENT_PATCH,
 	} action = NO_ACTION;
 	struct option builtin_rebase_options[] = {
 		OPT_STRING(0, "onto", &options.onto_name,
@@ -503,6 +505,11 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 			    ACTION_ABORT),
 		OPT_CMDMODE(0, "quit", &action,
 			    N_("abort but keep HEAD where it is"), ACTION_QUIT),
+		OPT_CMDMODE(0, "edit-todo", &action, N_("edit the todo list "
+			    "during an interactive rebase"), ACTION_EDIT_TODO),
+		OPT_CMDMODE(0, "show-current-patch", &action,
+			    N_("show the patch file being applied or merged"),
+			    ACTION_SHOW_CURRENT_PATCH),
 		OPT_END(),
 	};
 
@@ -570,6 +577,10 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 		usage_with_options(builtin_rebase_usage,
 				   builtin_rebase_options);
 
+	if (action == ACTION_EDIT_TODO && !is_interactive(&options))
+		die(_("The --edit-todo action can only be used during "
+		      "interactive rebase."));
+
 	switch (action) {
 	case ACTION_CONTINUE: {
 		struct object_id head;
@@ -639,8 +650,18 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
 			die(_("could not remove '%s'"), options.state_dir);
 		goto cleanup;
 	}
+	case ACTION_EDIT_TODO:
+		options.action = "edit-todo";
+		options.dont_finish_rebase = 1;
+		goto run_rebase;
+	case ACTION_SHOW_CURRENT_PATCH:
+		options.action = "show-current-patch";
+		options.dont_finish_rebase = 1;
+		goto run_rebase;
+	case NO_ACTION:
+		break;
 	default:
-		die("TODO");
+		BUG("action: %d", action);
 	}
 
 	/* Make sure no rebase is in progress */
-- 
2.18.0
Previous: Pratik KarkiNext: Pratik Karki
Message 6 of 8 in “builtin rebase actions”
  1. Pratik KarkiAug 8, 2018
  2. 1/7 builtin rebase: support --continuePratik Karki, Aug 8, 2018
  3. 2/7 builtin rebase: support --skipPratik Karki, Aug 8, 2018
  4. 3/7 builtin rebase: support --abortPratik Karki, Aug 8, 2018
  5. 4/7 builtin rebase: support --quitPratik Karki, Aug 8, 2018
  6. 5/7 builtin rebase: support --edit-todo and --show-current-patchPratik Karki, Aug 8, 2018
  7. 6/7 builtin rebase: actions require a rebase in progressPratik Karki, Aug 8, 2018
  8. 7/7 builtin rebase: stop if `git am` is in progressPratik Karki, Aug 8, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.