{"thread":{"id":"50342","subject":"[PATCH] implicit interactive rebase: don't run sequence editor","startedAt":"2019-01-28T10:27:55Z","lastAt":"2019-01-28T18:25:20Z","messageCount":2,"participants":["Phillip Wood","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"367821","messageId":"20190128102756.19152-1-phillip.wood@talktalk.net","threadId":"50342","inReplyTo":null,"subject":"[PATCH] implicit interactive rebase: don't run sequence editor","fromName":"Phillip Wood","fromEmail":"phillip.wood@talktalk.net","sentAt":"2019-01-28T10:27:56Z","receivedAt":"2019-01-28T10:27:55Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"From: Phillip Wood <phillip.wood@dunelm.org.uk>\n\nIf GIT_SEQUENCE_EDITOR is set then rebase runs it when executing\nimplicit interactive rebases which are supposed to appear\nnon-interactive to the user. Fix this by setting GIT_SEQUENCE_EDITOR=:\nrather than GIT_EDITOR=:. A couple of tests relied on the old behavior\nso they are updated to work with the new regime.\n\nSigned-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>\n---\n builtin/rebase.c                   |  5 +++--\n git-legacy-rebase.sh               |  4 ++--\n t/t3404-rebase-interactive.sh      |  5 +++++\n t/t3430-rebase-merges.sh           |  2 +-\n t/t7505-prepare-commit-msg-hook.sh | 10 +++++-----\n 5 files changed, 16 insertions(+), 10 deletions(-)\n\ndiff --git a/builtin/rebase.c b/builtin/rebase.c\nindex 00de70365e..7c11b4ac7f 100644\n--- a/builtin/rebase.c\n+++ b/builtin/rebase.c\n@@ -354,7 +354,8 @@ static int run_specific_rebase(struct rebase_options *opts)\n \t\targv_array_pushf(&child.env_array, \"GIT_CHERRY_PICK_HELP=%s\",\n \t\t\t\t resolvemsg);\n \t\tif (!(opts->flags & REBASE_INTERACTIVE_EXPLICIT)) {\n-\t\t\targv_array_push(&child.env_array, \"GIT_EDITOR=:\");\n+\t\t\targv_array_push(&child.env_array,\n+\t\t\t\t\t\"GIT_SEQUENCE_EDITOR=:\");\n \t\t\topts->autosquash = 0;\n \t\t}\n \n@@ -475,7 +476,7 @@ static int run_specific_rebase(struct rebase_options *opts)\n \tif (is_interactive(opts) &&\n \t    !(opts->flags & REBASE_INTERACTIVE_EXPLICIT)) {\n \t\tstrbuf_addstr(&script_snippet,\n-\t\t\t      \"GIT_EDITOR=:; export GIT_EDITOR; \");\n+\t\t\t      \"GIT_SEQUENCE_EDITOR=:; export GIT_SEQUENCE_EDITOR; \");\n \t\topts->autosquash = 0;\n \t}\n \ndiff --git a/git-legacy-rebase.sh b/git-legacy-rebase.sh\nindex b4c7dbfa57..41f7799bb5 100755\n--- a/git-legacy-rebase.sh\n+++ b/git-legacy-rebase.sh\n@@ -168,8 +168,8 @@ run_interactive () {\n \n run_specific_rebase () {\n \tif [ \"$interactive_rebase\" = implied ]; then\n-\t\tGIT_EDITOR=:\n-\t\texport GIT_EDITOR\n+\t\tGIT_SEQUENCE_EDITOR=:\n+\t\texport GIT_SEQUENCE_EDITOR\n \t\tautosquash=\n \tfi\n \ndiff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh\nindex 7a440e08d8..2b961745cc 100755\n--- a/t/t3404-rebase-interactive.sh\n+++ b/t/t3404-rebase-interactive.sh\n@@ -156,6 +156,11 @@ test_expect_success 'rebase -i with exec of inexistent command' '\n \t! grep \"Maybe git-rebase is broken\" actual\n '\n \n+test_expect_success 'implicit interactive rebase does not invoke sequence editor' '\n+\ttest_when_finished \"git rebase --abort ||:\" &&\n+\tGIT_SEQUENCE_EDITOR=\"echo bad >\" git rebase -x\"echo one\" @^\n+'\n+\n test_expect_success 'no changes are a nop' '\n \tgit checkout branch2 &&\n \tset_fake_editor &&\ndiff --git a/t/t3430-rebase-merges.sh b/t/t3430-rebase-merges.sh\nindex cc5646836f..4c69255ee6 100755\n--- a/t/t3430-rebase-merges.sh\n+++ b/t/t3430-rebase-merges.sh\n@@ -125,7 +125,7 @@ test_expect_success '`reset` refuses to overwrite untracked files' '\n \t: >dont-overwrite-untracked.t &&\n \techo \"reset refs/tags/dont-overwrite-untracked\" >script-from-scratch &&\n \ttest_config sequence.editor \\\"\"$PWD\"/replace-editor.sh\\\" &&\n-\ttest_must_fail git rebase -r HEAD &&\n+\ttest_must_fail git rebase -ir HEAD &&\n \tgit rebase --abort\n '\n \ndiff --git a/t/t7505-prepare-commit-msg-hook.sh b/t/t7505-prepare-commit-msg-hook.sh\nindex ebfcad9c4c..ba8bd1b514 100755\n--- a/t/t7505-prepare-commit-msg-hook.sh\n+++ b/t/t7505-prepare-commit-msg-hook.sh\n@@ -215,7 +215,7 @@ test_expect_success 'with hook and editor (merge)' '\n test_rebase () {\n \texpect=$1 &&\n \tmode=$2 &&\n-\ttest_expect_$expect C_LOCALE_OUTPUT \"with hook (rebase $mode)\" '\n+\ttest_expect_$expect C_LOCALE_OUTPUT \"with hook (rebase ${mode:--i})\" '\n \t\ttest_when_finished \"\\\n \t\t\tgit rebase --abort\n \t\t\tgit checkout -f master\n@@ -225,7 +225,7 @@ test_rebase () {\n \t\tGIT_EDITOR=\"\\\"$FAKE_EDITOR\\\"\" &&\n \t\t(\n \t\t\texport GIT_SEQUENCE_EDITOR GIT_EDITOR &&\n-\t\t\ttest_must_fail git rebase $mode b &&\n+\t\t\ttest_must_fail git rebase -i $mode b &&\n \t\t\techo x >a &&\n \t\t\tgit add a &&\n \t\t\ttest_must_fail git rebase --continue &&\n@@ -241,18 +241,18 @@ test_rebase () {\n \t\t\tgit add b &&\n \t\t\tgit rebase --continue\n \t\t) &&\n-\t\tif test $mode = -p # reword amended after pick\n+\t\tif test \"$mode\" = -p # reword amended after pick\n \t\tthen\n \t\t\tn=18\n \t\telse\n \t\t\tn=17\n \t\tfi &&\n \t\tgit log --pretty=%s -g -n$n HEAD@{1} >actual &&\n-\t\ttest_cmp \"$TEST_DIRECTORY/t7505/expected-rebase$mode\" actual\n+\t\ttest_cmp \"$TEST_DIRECTORY/t7505/expected-rebase${mode:--i}\" actual\n \t'\n }\n \n-test_rebase success -i\n+test_rebase success\n test_have_prereq !REBASE_P || test_rebase success -p\n \n test_expect_success 'with hook (cherry-pick)' '\n-- \n2.20.1\n\n"},{"id":"367852","messageId":"xmqq8sz4bpx1.fsf@gitster-ct.c.googlers.com","threadId":"50342","inReplyTo":"20190128102756.19152-1-phillip.wood@talktalk.net","subject":"Re: [PATCH] implicit interactive rebase: don't run sequence editor","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-01-28T18:25:14Z","receivedAt":"2019-01-28T18:25:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Phillip Wood <phillip.wood@talktalk.net> writes:\n\n> From: Phillip Wood <phillip.wood@dunelm.org.uk>\n>\n> If GIT_SEQUENCE_EDITOR is set then rebase runs it when executing\n> implicit interactive rebases which are supposed to appear\n> non-interactive to the user. Fix this by setting GIT_SEQUENCE_EDITOR=:\n> rather than GIT_EDITOR=:. A couple of tests relied on the old behavior\n> so they are updated to work with the new regime.\n>\n> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>\n> ---\n\nGood eyes, and an excellent execution to override the more specific\none ;-)\n\n>  builtin/rebase.c                   |  5 +++--\n>  git-legacy-rebase.sh               |  4 ++--\n>  t/t3404-rebase-interactive.sh      |  5 +++++\n>  t/t3430-rebase-merges.sh           |  2 +-\n>  t/t7505-prepare-commit-msg-hook.sh | 10 +++++-----\n>  5 files changed, 16 insertions(+), 10 deletions(-)\n>\n> diff --git a/builtin/rebase.c b/builtin/rebase.c\n> index 00de70365e..7c11b4ac7f 100644\n> --- a/builtin/rebase.c\n> +++ b/builtin/rebase.c\n> @@ -354,7 +354,8 @@ static int run_specific_rebase(struct rebase_options *opts)\n>  \t\targv_array_pushf(&child.env_array, \"GIT_CHERRY_PICK_HELP=%s\",\n>  \t\t\t\t resolvemsg);\n>  \t\tif (!(opts->flags & REBASE_INTERACTIVE_EXPLICIT)) {\n> -\t\t\targv_array_push(&child.env_array, \"GIT_EDITOR=:\");\n> +\t\t\targv_array_push(&child.env_array,\n> +\t\t\t\t\t\"GIT_SEQUENCE_EDITOR=:\");\n>  \t\t\topts->autosquash = 0;\n>  \t\t}\n>  \n> @@ -475,7 +476,7 @@ static int run_specific_rebase(struct rebase_options *opts)\n>  \tif (is_interactive(opts) &&\n>  \t    !(opts->flags & REBASE_INTERACTIVE_EXPLICIT)) {\n>  \t\tstrbuf_addstr(&script_snippet,\n> -\t\t\t      \"GIT_EDITOR=:; export GIT_EDITOR; \");\n> +\t\t\t      \"GIT_SEQUENCE_EDITOR=:; export GIT_SEQUENCE_EDITOR; \");\n>  \t\topts->autosquash = 0;\n>  \t}\n"}]}