builtin rebase: use no-op editor when interactive is "implied"
authorPratik Karki <predatoramigo@gmail.com>
Wed, 8 Aug 2018 15:36:34 +0000 (21:21 +0545)
committerJunio C Hamano <gitster@pobox.com>
Thu, 11 Oct 2018 05:16:05 +0000 (14:16 +0900)
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/rebase.c
index 600788bf725ff523011e91b4fde1b89c76d94728..36d311b42fb9ebe2d482a1bdff61389b627aa080 100644 (file)
@@ -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";