implicit interactive rebase: don't run sequence editor
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>
Phillip Wood committed
Jan 28, 2019 at 10:27 UTC
891d4a0313edc03f7e2ecb96edec5d30dc182294
5 files changed
+16
-10
builtin/rebase.c
+3
-2
@@ -354,7 +354,8 @@ static int run_specific_rebase(struct rebase_options *opts)
354
argv_array_pushf(&child.env_array, "GIT_CHERRY_PICK_HELP=%s",
355
resolvemsg);
356
if (!(opts->flags & REBASE_INTERACTIVE_EXPLICIT)) {
357
- argv_array_push(&child.env_array, "GIT_EDITOR=:");
357
+ argv_array_push(&child.env_array,
358
+ "GIT_SEQUENCE_EDITOR=:");
359
opts->autosquash = 0;
360
}
361
@@ -475,7 +476,7 @@ static int run_specific_rebase(struct rebase_options *opts)
476
if (is_interactive(opts) &&
477
!(opts->flags & REBASE_INTERACTIVE_EXPLICIT)) {
478
strbuf_addstr(&script_snippet,
478
- "GIT_EDITOR=:; export GIT_EDITOR; ");
479
+ "GIT_SEQUENCE_EDITOR=:; export GIT_SEQUENCE_EDITOR; ");
480
opts->autosquash = 0;
481
}
482
git-legacy-rebase.sh
+2
-2
@@ -168,8 +168,8 @@ run_interactive () {
168
169
run_specific_rebase () {
170
if [ "$interactive_rebase" = implied ]; then
171
- GIT_EDITOR=:
172
- export GIT_EDITOR
171
+ GIT_SEQUENCE_EDITOR=:
172
+ export GIT_SEQUENCE_EDITOR
173
autosquash=
174
fi
175
t/t3404-rebase-interactive.sh
+5
@@ -156,6 +156,11 @@ test_expect_success 'rebase -i with exec of inexistent command' '
156
! grep "Maybe git-rebase is broken" actual
157
'
158
159
+test_expect_success 'implicit interactive rebase does not invoke sequence editor' '
160
+ test_when_finished "git rebase --abort ||:" &&
161
+ GIT_SEQUENCE_EDITOR="echo bad >" git rebase -x"echo one" @^
162
+'
163
+
164
test_expect_success 'no changes are a nop' '
165
git checkout branch2 &&
166
set_fake_editor &&
t/t3430-rebase-merges.sh
+1
-1
@@ -125,7 +125,7 @@ test_expect_success '`reset` refuses to overwrite untracked files' '
125
: >dont-overwrite-untracked.t &&
126
echo "reset refs/tags/dont-overwrite-untracked" >script-from-scratch &&
127
test_config sequence.editor \""$PWD"/replace-editor.sh\" &&
128
- test_must_fail git rebase -r HEAD &&
128
+ test_must_fail git rebase -ir HEAD &&
129
git rebase --abort
130
'
131
t/t7505-prepare-commit-msg-hook.sh
+5
-5
@@ -215,7 +215,7 @@ test_expect_success 'with hook and editor (merge)' '
215
test_rebase () {
216
expect=$1 &&
217
mode=$2 &&
218
- test_expect_$expect C_LOCALE_OUTPUT "with hook (rebase $mode)" '
218
+ test_expect_$expect C_LOCALE_OUTPUT "with hook (rebase ${mode:--i})" '
219
test_when_finished "\
220
git rebase --abort
221
git checkout -f master
@@ -225,7 +225,7 @@ test_rebase () {
225
GIT_EDITOR="\"$FAKE_EDITOR\"" &&
226
(
227
export GIT_SEQUENCE_EDITOR GIT_EDITOR &&
228
- test_must_fail git rebase $mode b &&
228
+ test_must_fail git rebase -i $mode b &&
229
echo x >a &&
230
git add a &&
231
test_must_fail git rebase --continue &&
@@ -241,18 +241,18 @@ test_rebase () {
241
git add b &&
242
git rebase --continue
243
) &&
244
- if test $mode = -p # reword amended after pick
244
+ if test "$mode" = -p # reword amended after pick
245
then
246
n=18
247
else
248
n=17
249
fi &&
250
git log --pretty=%s -g -n$n HEAD@{1} >actual &&
251
- test_cmp "$TEST_DIRECTORY/t7505/expected-rebase$mode" actual
251
+ test_cmp "$TEST_DIRECTORY/t7505/expected-rebase${mode:--i}" actual
252
'
253
}
254
255
-test_rebase success -i
255
+test_rebase success
256
test_have_prereq !REBASE_P || test_rebase success -p
257
258
test_expect_success 'with hook (cherry-pick)' '