]> git.ipfire.org Git - thirdparty/git.git/commitdiff
implicit interactive rebase: don't run sequence editor
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Mon, 28 Jan 2019 10:27:56 +0000 (10:27 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 28 Jan 2019 18:25:39 +0000 (10:25 -0800)
If GIT_SEQUENCE_EDITOR is set then rebase runs it when executing
implicit interactive rebases which are supposed to appear
non-interactive to the user. Fix this by setting GIT_SEQUENCE_EDITOR=:
rather than GIT_EDITOR=:. A couple of tests relied on the old behavior
so they are updated to work with the new regime.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/rebase.c
git-legacy-rebase.sh
t/t3404-rebase-interactive.sh
t/t3430-rebase-merges.sh
t/t7505-prepare-commit-msg-hook.sh

index b5c99ec10c200a5fccb293c0acadae80642f2808..2cb3f4a6a9473c9f92e1f682c21907cbf95ecd0f 100644 (file)
@@ -354,7 +354,8 @@ static int run_specific_rebase(struct rebase_options *opts)
                argv_array_pushf(&child.env_array, "GIT_CHERRY_PICK_HELP=%s",
                                 resolvemsg);
                if (!(opts->flags & REBASE_INTERACTIVE_EXPLICIT)) {
-                       argv_array_push(&child.env_array, "GIT_EDITOR=:");
+                       argv_array_push(&child.env_array,
+                                       "GIT_SEQUENCE_EDITOR=:");
                        opts->autosquash = 0;
                }
 
@@ -475,7 +476,7 @@ static int run_specific_rebase(struct rebase_options *opts)
        if (is_interactive(opts) &&
            !(opts->flags & REBASE_INTERACTIVE_EXPLICIT)) {
                strbuf_addstr(&script_snippet,
-                             "GIT_EDITOR=:; export GIT_EDITOR; ");
+                             "GIT_SEQUENCE_EDITOR=:; export GIT_SEQUENCE_EDITOR; ");
                opts->autosquash = 0;
        }
 
index b4c7dbfa575d3b5c664677c22b8613284d2e33fb..41f7799bb52c28cfb3b2a7030a150df428d2b5ea 100755 (executable)
@@ -168,8 +168,8 @@ run_interactive () {
 
 run_specific_rebase () {
        if [ "$interactive_rebase" = implied ]; then
-               GIT_EDITOR=:
-               export GIT_EDITOR
+               GIT_SEQUENCE_EDITOR=:
+               export GIT_SEQUENCE_EDITOR
                autosquash=
        fi
 
index 7a440e08d8257487ae2f47b159d11e37a5166df8..2b961745cc0aa302d3ac8ea72c4ad919de2e8bbf 100755 (executable)
@@ -156,6 +156,11 @@ test_expect_success 'rebase -i with exec of inexistent command' '
        ! grep "Maybe git-rebase is broken" actual
 '
 
+test_expect_success 'implicit interactive rebase does not invoke sequence editor' '
+       test_when_finished "git rebase --abort ||:" &&
+       GIT_SEQUENCE_EDITOR="echo bad >" git rebase -x"echo one" @^
+'
+
 test_expect_success 'no changes are a nop' '
        git checkout branch2 &&
        set_fake_editor &&
index cc5646836fce1aaaa01556450a9b017c7a853088..4c69255ee6b14bdd52b6f840e2e528c182cb23ec 100755 (executable)
@@ -125,7 +125,7 @@ test_expect_success '`reset` refuses to overwrite untracked files' '
        : >dont-overwrite-untracked.t &&
        echo "reset refs/tags/dont-overwrite-untracked" >script-from-scratch &&
        test_config sequence.editor \""$PWD"/replace-editor.sh\" &&
-       test_must_fail git rebase -r HEAD &&
+       test_must_fail git rebase -ir HEAD &&
        git rebase --abort
 '
 
index ebfcad9c4c7d3c6766907d76c5e0c794a0720e1c..ba8bd1b51497df1aedf2280210a98b389f12b9e7 100755 (executable)
@@ -215,7 +215,7 @@ test_expect_success 'with hook and editor (merge)' '
 test_rebase () {
        expect=$1 &&
        mode=$2 &&
-       test_expect_$expect C_LOCALE_OUTPUT "with hook (rebase $mode)" '
+       test_expect_$expect C_LOCALE_OUTPUT "with hook (rebase ${mode:--i})" '
                test_when_finished "\
                        git rebase --abort
                        git checkout -f master
@@ -225,7 +225,7 @@ test_rebase () {
                GIT_EDITOR="\"$FAKE_EDITOR\"" &&
                (
                        export GIT_SEQUENCE_EDITOR GIT_EDITOR &&
-                       test_must_fail git rebase $mode b &&
+                       test_must_fail git rebase -i $mode b &&
                        echo x >a &&
                        git add a &&
                        test_must_fail git rebase --continue &&
@@ -241,18 +241,18 @@ test_rebase () {
                        git add b &&
                        git rebase --continue
                ) &&
-               if test $mode = -p # reword amended after pick
+               if test "$mode" = -p # reword amended after pick
                then
                        n=18
                else
                        n=17
                fi &&
                git log --pretty=%s -g -n$n HEAD@{1} >actual &&
-               test_cmp "$TEST_DIRECTORY/t7505/expected-rebase$mode" actual
+               test_cmp "$TEST_DIRECTORY/t7505/expected-rebase${mode:--i}" actual
        '
 }
 
-test_rebase success -i
+test_rebase success
 test_have_prereq !REBASE_P || test_rebase success -p
 
 test_expect_success 'with hook (cherry-pick)' '