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

[PATCH 5/6] builtin rebase: use no-op editor when interactive is "implied"

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

Some options are only handled by the git-rebase--interactive backend, even if run non-interactively. For this awkward situation (run non-interactively, but use the interactive backend), the shell scripted version of `git rebase` introduced the concept of an "implied interactive rebase". All it does is to replace the editor by a dummy one (`:` is the Unix command that takes arbitrary command-line parameters, ignores them and simply exits with success).

Signed-off-by: Pratik Karki <predatoramigo@gmail.com>
---
 builtin/rebase.c | 7 +++++++
 1 file changed, 7 insertions(+)
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 04974dff6e..fb8ab5a177 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -383,6 +383,13 @@ static int run_specific_rebase(struct rebase_options *opts)
 	add_var(&script_snippet, "git_format_patch_opt",
 		opts->git_format_patch_opt.buf);
 
+	if (is_interactive(opts) &&
+	    !(opts->flags & REBASE_INTERACTIVE_EXPLICIT)) {
+		strbuf_addstr(&script_snippet,
+			      "GIT_EDITOR=:; export GIT_EDITOR; ");
+		opts->autosquash = 0;
+	}
+
 	switch (opts->type) {
 	case REBASE_AM:
 		backend = "git-rebase--am";
-- 
2.18.0
Previous: Pratik KarkiNext: Pratik Karki
Message 6 of 7 in “builtin rebase rest”
  1. Pratik KarkiAug 8, 2018
  2. 1/6 builtin rebase: optionally auto-detect the upstreamPratik Karki, Aug 8, 2018
  3. 2/6 builtin rebase: optionally pass custom reflogs to reset_head()Pratik Karki, Aug 8, 2018
  4. 3/6 builtin rebase: fast-forward to onto if it is a proper descendantPratik Karki, Aug 8, 2018
  5. 4/6 builtin rebase: show progress when connected to a terminalPratik Karki, Aug 8, 2018
  6. 5/6 builtin rebase: use no-op editor when interactive is "implied"Pratik Karki, Aug 8, 2018
  7. 6/6 builtin rebase: error out on incompatible option/mode combinationsPratik 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.