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 <predatoram...@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

Reply via email to