Merge branch 'bc/signed-objects-with-both-hashes'
[git] / t / t3404-rebase-interactive.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2007 Johannes E. Schindelin
4 #
5
6 test_description='git rebase interactive
7
8 This test runs git rebase "interactively", by faking an edit, and verifies
9 that the result still makes sense.
10
11 Initial setup:
12
13      one - two - three - four (conflict-branch)
14    /
15  A - B - C - D - E            (primary)
16  | \
17  |   F - G - H                (branch1)
18  |     \
19  |\      I                    (branch2)
20  | \
21  |   J - K - L - M            (no-conflict-branch)
22   \
23     N - O - P                 (no-ff-branch)
24
25  where A, B, D and G all touch file1, and one, two, three, four all
26  touch file "conflict".
27 '
28 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
29 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
30
31 . ./test-lib.sh
32
33 . "$TEST_DIRECTORY"/lib-rebase.sh
34
35 test_expect_success 'setup' '
36         git switch -C primary &&
37         test_commit A file1 &&
38         test_commit B file1 &&
39         test_commit C file2 &&
40         test_commit D file1 &&
41         test_commit E file3 &&
42         git checkout -b branch1 A &&
43         test_commit F file4 &&
44         test_commit G file1 &&
45         test_commit H file5 &&
46         git checkout -b branch2 F &&
47         test_commit I file6 &&
48         git checkout -b conflict-branch A &&
49         test_commit one conflict &&
50         test_commit two conflict &&
51         test_commit three conflict &&
52         test_commit four conflict &&
53         git checkout -b no-conflict-branch A &&
54         test_commit J fileJ &&
55         test_commit K fileK &&
56         test_commit L fileL &&
57         test_commit M fileM &&
58         git checkout -b no-ff-branch A &&
59         test_commit N fileN &&
60         test_commit O fileO &&
61         test_commit P fileP
62 '
63
64 # "exec" commands are run with the user shell by default, but this may
65 # be non-POSIX. For example, if SHELL=zsh then ">file" doesn't work
66 # to create a file. Unsetting SHELL avoids such non-portable behavior
67 # in tests. It must be exported for it to take effect where needed.
68 SHELL=
69 export SHELL
70
71 test_expect_success 'rebase --keep-empty' '
72         git checkout -b emptybranch primary &&
73         git commit --allow-empty -m "empty" &&
74         git rebase --keep-empty -i HEAD~2 &&
75         git log --oneline >actual &&
76         test_line_count = 6 actual
77 '
78
79 test_expect_success 'rebase -i with empty todo list' '
80         cat >expect <<-\EOF &&
81         error: nothing to do
82         EOF
83         (
84                 set_fake_editor &&
85                 test_must_fail env FAKE_LINES="#" \
86                         git rebase -i HEAD^ >output 2>&1
87         ) &&
88         tail -n 1 output >actual &&  # Ignore output about changing todo list
89         test_i18ncmp expect actual
90 '
91
92 test_expect_success 'rebase -i with the exec command' '
93         git checkout primary &&
94         (
95         set_fake_editor &&
96         FAKE_LINES="1 exec_>touch-one
97                 2 exec_>touch-two exec_false exec_>touch-three
98                 3 4 exec_>\"touch-file__name_with_spaces\";_>touch-after-semicolon 5" &&
99         export FAKE_LINES &&
100         test_must_fail git rebase -i A
101         ) &&
102         test_path_is_file touch-one &&
103         test_path_is_file touch-two &&
104         test_path_is_missing touch-three " (should have stopped before)" &&
105         test_cmp_rev C HEAD &&
106         git rebase --continue &&
107         test_path_is_file touch-three &&
108         test_path_is_file "touch-file  name with spaces" &&
109         test_path_is_file touch-after-semicolon &&
110         test_cmp_rev primary HEAD &&
111         rm -f touch-*
112 '
113
114 test_expect_success 'rebase -i with the exec command runs from tree root' '
115         git checkout primary &&
116         mkdir subdir && (cd subdir &&
117         set_fake_editor &&
118         FAKE_LINES="1 exec_>touch-subdir" \
119                 git rebase -i HEAD^
120         ) &&
121         test_path_is_file touch-subdir &&
122         rm -fr subdir
123 '
124
125 test_expect_success 'rebase -i with exec allows git commands in subdirs' '
126         test_when_finished "rm -rf subdir" &&
127         test_when_finished "git rebase --abort ||:" &&
128         git checkout primary &&
129         mkdir subdir && (cd subdir &&
130         set_fake_editor &&
131         FAKE_LINES="1 x_cd_subdir_&&_git_rev-parse_--is-inside-work-tree" \
132                 git rebase -i HEAD^
133         )
134 '
135
136 test_expect_success 'rebase -i sets work tree properly' '
137         test_when_finished "rm -rf subdir" &&
138         test_when_finished "test_might_fail git rebase --abort" &&
139         mkdir subdir &&
140         git rebase -x "(cd subdir && git rev-parse --show-toplevel)" HEAD^ \
141                 >actual &&
142         ! grep "/subdir$" actual
143 '
144
145 test_expect_success 'rebase -i with the exec command checks tree cleanness' '
146         git checkout primary &&
147         (
148                 set_fake_editor &&
149                 test_must_fail env FAKE_LINES="exec_echo_foo_>file1 1" \
150                         git rebase -i HEAD^
151         ) &&
152         test_cmp_rev primary^ HEAD &&
153         git reset --hard &&
154         git rebase --continue
155 '
156
157 test_expect_success 'rebase -x with empty command fails' '
158         test_when_finished "git rebase --abort ||:" &&
159         test_must_fail env git rebase -x "" @ 2>actual &&
160         test_write_lines "error: empty exec command" >expected &&
161         test_i18ncmp expected actual &&
162         test_must_fail env git rebase -x " " @ 2>actual &&
163         test_i18ncmp expected actual
164 '
165
166 test_expect_success 'rebase -x with newline in command fails' '
167         test_when_finished "git rebase --abort ||:" &&
168         test_must_fail env git rebase -x "a${LF}b" @ 2>actual &&
169         test_write_lines "error: exec commands cannot contain newlines" \
170                          >expected &&
171         test_i18ncmp expected actual
172 '
173
174 test_expect_success 'rebase -i with exec of inexistent command' '
175         git checkout primary &&
176         test_when_finished "git rebase --abort" &&
177         (
178                 set_fake_editor &&
179                 test_must_fail env FAKE_LINES="exec_this-command-does-not-exist 1" \
180                         git rebase -i HEAD^ >actual 2>&1
181         ) &&
182         ! grep "Maybe git-rebase is broken" actual
183 '
184
185 test_expect_success 'implicit interactive rebase does not invoke sequence editor' '
186         test_when_finished "git rebase --abort ||:" &&
187         GIT_SEQUENCE_EDITOR="echo bad >" git rebase -x"echo one" @^
188 '
189
190 test_expect_success 'no changes are a nop' '
191         git checkout branch2 &&
192         git rebase -i F &&
193         test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch2" &&
194         test_cmp_rev I HEAD
195 '
196
197 test_expect_success 'test the [branch] option' '
198         git checkout -b dead-end &&
199         git rm file6 &&
200         git commit -m "stop here" &&
201         git rebase -i F branch2 &&
202         test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch2" &&
203         test_cmp_rev I branch2 &&
204         test_cmp_rev I HEAD
205 '
206
207 test_expect_success 'test --onto <branch>' '
208         git checkout -b test-onto branch2 &&
209         git rebase -i --onto branch1 F &&
210         test "$(git symbolic-ref -q HEAD)" = "refs/heads/test-onto" &&
211         test_cmp_rev HEAD^ branch1 &&
212         test_cmp_rev I branch2
213 '
214
215 test_expect_success 'rebase on top of a non-conflicting commit' '
216         git checkout branch1 &&
217         git tag original-branch1 &&
218         git rebase -i branch2 &&
219         test file6 = $(git diff --name-only original-branch1) &&
220         test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch1" &&
221         test_cmp_rev I branch2 &&
222         test_cmp_rev I HEAD~2
223 '
224
225 test_expect_success 'reflog for the branch shows state before rebase' '
226         test_cmp_rev branch1@{1} original-branch1
227 '
228
229 test_expect_success 'reflog for the branch shows correct finish message' '
230         printf "rebase (finish): refs/heads/branch1 onto %s\n" \
231                 "$(git rev-parse branch2)" >expected &&
232         git log -g --pretty=%gs -1 refs/heads/branch1 >actual &&
233         test_cmp expected actual
234 '
235
236 test_expect_success 'exchange two commits' '
237         (
238                 set_fake_editor &&
239                 FAKE_LINES="2 1" git rebase -i HEAD~2
240         ) &&
241         test H = $(git cat-file commit HEAD^ | sed -ne \$p) &&
242         test G = $(git cat-file commit HEAD | sed -ne \$p) &&
243         blob1=$(git rev-parse --short HEAD^:file1) &&
244         blob2=$(git rev-parse --short HEAD:file1) &&
245         commit=$(git rev-parse --short HEAD)
246 '
247
248 test_expect_success 'stop on conflicting pick' '
249         cat >expect <<-EOF &&
250         diff --git a/file1 b/file1
251         index $blob1..$blob2 100644
252         --- a/file1
253         +++ b/file1
254         @@ -1 +1 @@
255         -A
256         +G
257         EOF
258         cat >expect2 <<-EOF &&
259         <<<<<<< HEAD
260         D
261         =======
262         G
263         >>>>>>> $commit (G)
264         EOF
265         git tag new-branch1 &&
266         test_must_fail git rebase -i primary &&
267         test "$(git rev-parse HEAD~3)" = "$(git rev-parse primary)" &&
268         test_cmp expect .git/rebase-merge/patch &&
269         test_cmp expect2 file1 &&
270         test "$(git diff --name-status |
271                 sed -n -e "/^U/s/^U[^a-z]*//p")" = file1 &&
272         test 4 = $(grep -v "^#" < .git/rebase-merge/done | wc -l) &&
273         test 0 = $(grep -c "^[^#]" < .git/rebase-merge/git-rebase-todo)
274 '
275
276 test_expect_success 'show conflicted patch' '
277         GIT_TRACE=1 git rebase --show-current-patch >/dev/null 2>stderr &&
278         grep "show.*REBASE_HEAD" stderr &&
279         # the original stopped-sha1 is abbreviated
280         stopped_sha1="$(git rev-parse $(cat ".git/rebase-merge/stopped-sha"))" &&
281         test "$(git rev-parse REBASE_HEAD)" = "$stopped_sha1"
282 '
283
284 test_expect_success 'abort' '
285         git rebase --abort &&
286         test_cmp_rev new-branch1 HEAD &&
287         test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch1" &&
288         test_path_is_missing .git/rebase-merge
289 '
290
291 test_expect_success 'abort with error when new base cannot be checked out' '
292         git rm --cached file1 &&
293         git commit -m "remove file in base" &&
294         test_must_fail git rebase -i primary > output 2>&1 &&
295         test_i18ngrep "The following untracked working tree files would be overwritten by checkout:" \
296                 output &&
297         test_i18ngrep "file1" output &&
298         test_path_is_missing .git/rebase-merge &&
299         git reset --hard HEAD^
300 '
301
302 test_expect_success 'retain authorship' '
303         echo A > file7 &&
304         git add file7 &&
305         test_tick &&
306         GIT_AUTHOR_NAME="Twerp Snog" git commit -m "different author" &&
307         git tag twerp &&
308         git rebase -i --onto primary HEAD^ &&
309         git show HEAD | grep "^Author: Twerp Snog"
310 '
311
312 test_expect_success 'retain authorship w/ conflicts' '
313         oGIT_AUTHOR_NAME=$GIT_AUTHOR_NAME &&
314         test_when_finished "GIT_AUTHOR_NAME=\$oGIT_AUTHOR_NAME" &&
315
316         git reset --hard twerp &&
317         test_commit a conflict a conflict-a &&
318         git reset --hard twerp &&
319
320         GIT_AUTHOR_NAME=AttributeMe &&
321         export GIT_AUTHOR_NAME &&
322         test_commit b conflict b conflict-b &&
323         GIT_AUTHOR_NAME=$oGIT_AUTHOR_NAME &&
324
325         test_must_fail git rebase -i conflict-a &&
326         echo resolved >conflict &&
327         git add conflict &&
328         git rebase --continue &&
329         test_cmp_rev conflict-a^0 HEAD^ &&
330         git show >out &&
331         grep AttributeMe out
332 '
333
334 test_expect_success 'squash' '
335         git reset --hard twerp &&
336         echo B > file7 &&
337         test_tick &&
338         GIT_AUTHOR_NAME="Nitfol" git commit -m "nitfol" file7 &&
339         echo "******************************" &&
340         (
341                 set_fake_editor &&
342                 FAKE_LINES="1 squash 2" EXPECT_HEADER_COUNT=2 \
343                         git rebase -i --onto primary HEAD~2
344         ) &&
345         test B = $(cat file7) &&
346         test_cmp_rev HEAD^ primary
347 '
348
349 test_expect_success 'retain authorship when squashing' '
350         git show HEAD | grep "^Author: Twerp Snog"
351 '
352
353 test_expect_success REBASE_P '-p handles "no changes" gracefully' '
354         HEAD=$(git rev-parse HEAD) &&
355         git rebase -i -p HEAD^ &&
356         git update-index --refresh &&
357         git diff-files --quiet &&
358         git diff-index --quiet --cached HEAD -- &&
359         test $HEAD = $(git rev-parse HEAD)
360 '
361
362 test_expect_failure REBASE_P 'exchange two commits with -p' '
363         git checkout H &&
364         (
365                 set_fake_editor &&
366                 FAKE_LINES="2 1" git rebase -i -p HEAD~2
367         ) &&
368         test H = $(git cat-file commit HEAD^ | sed -ne \$p) &&
369         test G = $(git cat-file commit HEAD | sed -ne \$p)
370 '
371
372 test_expect_success REBASE_P 'preserve merges with -p' '
373         git checkout -b to-be-preserved primary^ &&
374         : > unrelated-file &&
375         git add unrelated-file &&
376         test_tick &&
377         git commit -m "unrelated" &&
378         git checkout -b another-branch primary &&
379         echo B > file1 &&
380         test_tick &&
381         git commit -m J file1 &&
382         test_tick &&
383         git merge to-be-preserved &&
384         echo C > file1 &&
385         test_tick &&
386         git commit -m K file1 &&
387         echo D > file1 &&
388         test_tick &&
389         git commit -m L1 file1 &&
390         git checkout HEAD^ &&
391         echo 1 > unrelated-file &&
392         test_tick &&
393         git commit -m L2 unrelated-file &&
394         test_tick &&
395         git merge another-branch &&
396         echo E > file1 &&
397         test_tick &&
398         git commit -m M file1 &&
399         git checkout -b to-be-rebased &&
400         test_tick &&
401         git rebase -i -p --onto branch1 primary &&
402         git update-index --refresh &&
403         git diff-files --quiet &&
404         git diff-index --quiet --cached HEAD -- &&
405         test_cmp_rev HEAD~6 branch1 &&
406         test_cmp_rev HEAD~4^2 to-be-preserved &&
407         test_cmp_rev HEAD^^2^ HEAD^^^ &&
408         test $(git show HEAD~5:file1) = B &&
409         test $(git show HEAD~3:file1) = C &&
410         test $(git show HEAD:file1) = E &&
411         test $(git show HEAD:unrelated-file) = 1
412 '
413
414 test_expect_success REBASE_P 'edit ancestor with -p' '
415         (
416                 set_fake_editor &&
417                 FAKE_LINES="1 2 edit 3 4" git rebase -i -p HEAD~3
418         ) &&
419         echo 2 > unrelated-file &&
420         test_tick &&
421         git commit -m L2-modified --amend unrelated-file &&
422         git rebase --continue &&
423         git update-index --refresh &&
424         git diff-files --quiet &&
425         git diff-index --quiet --cached HEAD -- &&
426         test $(git show HEAD:unrelated-file) = 2
427 '
428
429 test_expect_success '--continue tries to commit' '
430         git reset --hard D &&
431         test_tick &&
432         (
433                 set_fake_editor &&
434                 test_must_fail git rebase -i --onto new-branch1 HEAD^ &&
435                 echo resolved > file1 &&
436                 git add file1 &&
437                 FAKE_COMMIT_MESSAGE="chouette!" git rebase --continue
438         ) &&
439         test_cmp_rev HEAD^ new-branch1 &&
440         git show HEAD | grep chouette
441 '
442
443 test_expect_success 'verbose flag is heeded, even after --continue' '
444         git reset --hard primary@{1} &&
445         test_tick &&
446         test_must_fail git rebase -v -i --onto new-branch1 HEAD^ &&
447         echo resolved > file1 &&
448         git add file1 &&
449         git rebase --continue > output &&
450         grep "^ file1 | 2 +-$" output
451 '
452
453 test_expect_success C_LOCALE_OUTPUT 'multi-squash only fires up editor once' '
454         base=$(git rev-parse HEAD~4) &&
455         (
456                 set_fake_editor &&
457                 FAKE_COMMIT_AMEND="ONCE" \
458                         FAKE_LINES="1 squash 2 squash 3 squash 4" \
459                         EXPECT_HEADER_COUNT=4 \
460                         git rebase -i $base
461         ) &&
462         test $base = $(git rev-parse HEAD^) &&
463         test 1 = $(git show | grep ONCE | wc -l)
464 '
465
466 test_expect_success C_LOCALE_OUTPUT 'multi-fixup does not fire up editor' '
467         git checkout -b multi-fixup E &&
468         base=$(git rev-parse HEAD~4) &&
469         (
470                 set_fake_editor &&
471                 FAKE_COMMIT_AMEND="NEVER" \
472                         FAKE_LINES="1 fixup 2 fixup 3 fixup 4" \
473                         git rebase -i $base
474         ) &&
475         test $base = $(git rev-parse HEAD^) &&
476         test 0 = $(git show | grep NEVER | wc -l) &&
477         git checkout @{-1} &&
478         git branch -D multi-fixup
479 '
480
481 test_expect_success 'commit message used after conflict' '
482         git checkout -b conflict-fixup conflict-branch &&
483         base=$(git rev-parse HEAD~4) &&
484         (
485                 set_fake_editor &&
486                 test_must_fail env FAKE_LINES="1 fixup 3 fixup 4" \
487                         git rebase -i $base &&
488                 echo three > conflict &&
489                 git add conflict &&
490                 FAKE_COMMIT_AMEND="ONCE" EXPECT_HEADER_COUNT=2 \
491                         git rebase --continue
492         ) &&
493         test $base = $(git rev-parse HEAD^) &&
494         test 1 = $(git show | grep ONCE | wc -l) &&
495         git checkout @{-1} &&
496         git branch -D conflict-fixup
497 '
498
499 test_expect_success 'commit message retained after conflict' '
500         git checkout -b conflict-squash conflict-branch &&
501         base=$(git rev-parse HEAD~4) &&
502         (
503                 set_fake_editor &&
504                 test_must_fail env FAKE_LINES="1 fixup 3 squash 4" \
505                         git rebase -i $base &&
506                 echo three > conflict &&
507                 git add conflict &&
508                 FAKE_COMMIT_AMEND="TWICE" EXPECT_HEADER_COUNT=2 \
509                         git rebase --continue
510         ) &&
511         test $base = $(git rev-parse HEAD^) &&
512         test 2 = $(git show | grep TWICE | wc -l) &&
513         git checkout @{-1} &&
514         git branch -D conflict-squash
515 '
516
517 test_expect_success C_LOCALE_OUTPUT 'squash and fixup generate correct log messages' '
518         cat >expect-squash-fixup <<-\EOF &&
519         B
520
521         D
522
523         ONCE
524         EOF
525         git checkout -b squash-fixup E &&
526         base=$(git rev-parse HEAD~4) &&
527         (
528                 set_fake_editor &&
529                 FAKE_COMMIT_AMEND="ONCE" \
530                         FAKE_LINES="1 fixup 2 squash 3 fixup 4" \
531                         EXPECT_HEADER_COUNT=4 \
532                         git rebase -i $base
533         ) &&
534         git cat-file commit HEAD | sed -e 1,/^\$/d > actual-squash-fixup &&
535         test_cmp expect-squash-fixup actual-squash-fixup &&
536         git cat-file commit HEAD@{2} |
537                 grep "^# This is a combination of 3 commits\."  &&
538         git cat-file commit HEAD@{3} |
539                 grep "^# This is a combination of 2 commits\."  &&
540         git checkout @{-1} &&
541         git branch -D squash-fixup
542 '
543
544 test_expect_success C_LOCALE_OUTPUT 'squash ignores comments' '
545         git checkout -b skip-comments E &&
546         base=$(git rev-parse HEAD~4) &&
547         (
548                 set_fake_editor &&
549                 FAKE_COMMIT_AMEND="ONCE" \
550                         FAKE_LINES="# 1 # squash 2 # squash 3 # squash 4 #" \
551                         EXPECT_HEADER_COUNT=4 \
552                         git rebase -i $base
553         ) &&
554         test $base = $(git rev-parse HEAD^) &&
555         test 1 = $(git show | grep ONCE | wc -l) &&
556         git checkout @{-1} &&
557         git branch -D skip-comments
558 '
559
560 test_expect_success C_LOCALE_OUTPUT 'squash ignores blank lines' '
561         git checkout -b skip-blank-lines E &&
562         base=$(git rev-parse HEAD~4) &&
563         (
564                 set_fake_editor &&
565                 FAKE_COMMIT_AMEND="ONCE" \
566                         FAKE_LINES="> 1 > squash 2 > squash 3 > squash 4 >" \
567                         EXPECT_HEADER_COUNT=4 \
568                         git rebase -i $base
569         ) &&
570         test $base = $(git rev-parse HEAD^) &&
571         test 1 = $(git show | grep ONCE | wc -l) &&
572         git checkout @{-1} &&
573         git branch -D skip-blank-lines
574 '
575
576 test_expect_success 'squash works as expected' '
577         git checkout -b squash-works no-conflict-branch &&
578         one=$(git rev-parse HEAD~3) &&
579         (
580                 set_fake_editor &&
581                 FAKE_LINES="1 s 3 2" EXPECT_HEADER_COUNT=2 git rebase -i HEAD~3
582         ) &&
583         test $one = $(git rev-parse HEAD~2)
584 '
585
586 test_expect_success 'interrupted squash works as expected' '
587         git checkout -b interrupted-squash conflict-branch &&
588         one=$(git rev-parse HEAD~3) &&
589         (
590                 set_fake_editor &&
591                 test_must_fail env FAKE_LINES="1 squash 3 2" \
592                         git rebase -i HEAD~3
593         ) &&
594         test_write_lines one two four > conflict &&
595         git add conflict &&
596         test_must_fail git rebase --continue &&
597         echo resolved > conflict &&
598         git add conflict &&
599         git rebase --continue &&
600         test $one = $(git rev-parse HEAD~2)
601 '
602
603 test_expect_success 'interrupted squash works as expected (case 2)' '
604         git checkout -b interrupted-squash2 conflict-branch &&
605         one=$(git rev-parse HEAD~3) &&
606         (
607                 set_fake_editor &&
608                 test_must_fail env FAKE_LINES="3 squash 1 2" \
609                         git rebase -i HEAD~3
610         ) &&
611         test_write_lines one four > conflict &&
612         git add conflict &&
613         test_must_fail git rebase --continue &&
614         test_write_lines one two four > conflict &&
615         git add conflict &&
616         test_must_fail git rebase --continue &&
617         echo resolved > conflict &&
618         git add conflict &&
619         git rebase --continue &&
620         test $one = $(git rev-parse HEAD~2)
621 '
622
623 test_expect_success '--continue tries to commit, even for "edit"' '
624         echo unrelated > file7 &&
625         git add file7 &&
626         test_tick &&
627         git commit -m "unrelated change" &&
628         parent=$(git rev-parse HEAD^) &&
629         test_tick &&
630         (
631                 set_fake_editor &&
632                 FAKE_LINES="edit 1" git rebase -i HEAD^ &&
633                 echo edited > file7 &&
634                 git add file7 &&
635                 FAKE_COMMIT_MESSAGE="chouette!" git rebase --continue
636         ) &&
637         test edited = $(git show HEAD:file7) &&
638         git show HEAD | grep chouette &&
639         test $parent = $(git rev-parse HEAD^)
640 '
641
642 test_expect_success 'aborted --continue does not squash commits after "edit"' '
643         old=$(git rev-parse HEAD) &&
644         test_tick &&
645         (
646                 set_fake_editor &&
647                 FAKE_LINES="edit 1" git rebase -i HEAD^ &&
648                 echo "edited again" > file7 &&
649                 git add file7 &&
650                 test_must_fail env FAKE_COMMIT_MESSAGE=" " git rebase --continue
651         ) &&
652         test $old = $(git rev-parse HEAD) &&
653         git rebase --abort
654 '
655
656 test_expect_success 'auto-amend only edited commits after "edit"' '
657         test_tick &&
658         (
659                 set_fake_editor &&
660                 FAKE_LINES="edit 1" git rebase -i HEAD^ &&
661                 echo "edited again" > file7 &&
662                 git add file7 &&
663                 FAKE_COMMIT_MESSAGE="edited file7 again" git commit &&
664                 echo "and again" > file7 &&
665                 git add file7 &&
666                 test_tick &&
667                 test_must_fail env FAKE_COMMIT_MESSAGE="and again" \
668                         git rebase --continue
669         ) &&
670         git rebase --abort
671 '
672
673 test_expect_success 'clean error after failed "exec"' '
674         test_tick &&
675         test_when_finished "git rebase --abort || :" &&
676         (
677                 set_fake_editor &&
678                 test_must_fail env FAKE_LINES="1 exec_false" git rebase -i HEAD^
679         ) &&
680         echo "edited again" > file7 &&
681         git add file7 &&
682         test_must_fail git rebase --continue 2>error &&
683         test_i18ngrep "you have staged changes in your working tree" error
684 '
685
686 test_expect_success 'rebase a detached HEAD' '
687         grandparent=$(git rev-parse HEAD~2) &&
688         git checkout $(git rev-parse HEAD) &&
689         test_tick &&
690         (
691                 set_fake_editor &&
692                 FAKE_LINES="2 1" git rebase -i HEAD~2
693         ) &&
694         test $grandparent = $(git rev-parse HEAD~2)
695 '
696
697 test_expect_success 'rebase a commit violating pre-commit' '
698
699         mkdir -p .git/hooks &&
700         write_script .git/hooks/pre-commit <<-\EOF &&
701         test -z "$(git diff --cached --check)"
702         EOF
703         echo "monde! " >> file1 &&
704         test_tick &&
705         test_must_fail git commit -m doesnt-verify file1 &&
706         git commit -m doesnt-verify --no-verify file1 &&
707         test_tick &&
708         (
709                 set_fake_editor &&
710                 FAKE_LINES=2 git rebase -i HEAD~2
711         )
712 '
713
714 test_expect_success 'rebase with a file named HEAD in worktree' '
715
716         rm -fr .git/hooks &&
717         git reset --hard &&
718         git checkout -b branch3 A &&
719
720         (
721                 GIT_AUTHOR_NAME="Squashed Away" &&
722                 export GIT_AUTHOR_NAME &&
723                 >HEAD &&
724                 git add HEAD &&
725                 git commit -m "Add head" &&
726                 >BODY &&
727                 git add BODY &&
728                 git commit -m "Add body"
729         ) &&
730
731         (
732                 set_fake_editor &&
733                 FAKE_LINES="1 squash 2" git rebase -i @{-1}
734         ) &&
735         test "$(git show -s --pretty=format:%an)" = "Squashed Away"
736
737 '
738
739 test_expect_success 'do "noop" when there is nothing to cherry-pick' '
740
741         git checkout -b branch4 HEAD &&
742         GIT_EDITOR=: git commit --amend \
743                 --author="Somebody else <somebody@else.com>" &&
744         test $(git rev-parse branch3) != $(git rev-parse branch4) &&
745         git rebase -i branch3 &&
746         test_cmp_rev branch3 branch4
747
748 '
749
750 test_expect_success 'submodule rebase setup' '
751         git checkout A &&
752         mkdir sub &&
753         (
754                 cd sub && git init && >elif &&
755                 git add elif && git commit -m "submodule initial"
756         ) &&
757         echo 1 >file1 &&
758         git add file1 sub &&
759         test_tick &&
760         git commit -m "One" &&
761         echo 2 >file1 &&
762         test_tick &&
763         git commit -a -m "Two" &&
764         (
765                 cd sub && echo 3 >elif &&
766                 git commit -a -m "submodule second"
767         ) &&
768         test_tick &&
769         git commit -a -m "Three changes submodule"
770 '
771
772 test_expect_success 'submodule rebase -i' '
773         (
774                 set_fake_editor &&
775                 FAKE_LINES="1 squash 2 3" git rebase -i A
776         )
777 '
778
779 test_expect_success 'submodule conflict setup' '
780         git tag submodule-base &&
781         git checkout HEAD^ &&
782         (
783                 cd sub && git checkout HEAD^ && echo 4 >elif &&
784                 git add elif && git commit -m "submodule conflict"
785         ) &&
786         git add sub &&
787         test_tick &&
788         git commit -m "Conflict in submodule" &&
789         git tag submodule-topic
790 '
791
792 test_expect_success 'rebase -i continue with only submodule staged' '
793         test_must_fail git rebase -i submodule-base &&
794         git add sub &&
795         git rebase --continue &&
796         test $(git rev-parse submodule-base) != $(git rev-parse HEAD)
797 '
798
799 test_expect_success 'rebase -i continue with unstaged submodule' '
800         git checkout submodule-topic &&
801         git reset --hard &&
802         test_must_fail git rebase -i submodule-base &&
803         git reset &&
804         git rebase --continue &&
805         test_cmp_rev submodule-base HEAD
806 '
807
808 test_expect_success 'avoid unnecessary reset' '
809         git checkout primary &&
810         git reset --hard &&
811         test-tool chmtime =123456789 file3 &&
812         git update-index --refresh &&
813         HEAD=$(git rev-parse HEAD) &&
814         git rebase -i HEAD~4 &&
815         test $HEAD = $(git rev-parse HEAD) &&
816         MTIME=$(test-tool chmtime --get file3) &&
817         test 123456789 = $MTIME
818 '
819
820 test_expect_success 'reword' '
821         git checkout -b reword-branch primary &&
822         (
823                 set_fake_editor &&
824                 FAKE_LINES="1 2 3 reword 4" FAKE_COMMIT_MESSAGE="E changed" \
825                         git rebase -i A &&
826                 git show HEAD | grep "E changed" &&
827                 test $(git rev-parse primary) != $(git rev-parse HEAD) &&
828                 test_cmp_rev primary^ HEAD^ &&
829                 FAKE_LINES="1 2 reword 3 4" FAKE_COMMIT_MESSAGE="D changed" \
830                         git rebase -i A &&
831                 git show HEAD^ | grep "D changed" &&
832                 FAKE_LINES="reword 1 2 3 4" FAKE_COMMIT_MESSAGE="B changed" \
833                         git rebase -i A &&
834                 git show HEAD~3 | grep "B changed" &&
835                 FAKE_LINES="1 r 2 pick 3 p 4" FAKE_COMMIT_MESSAGE="C changed" \
836                         git rebase -i A
837         ) &&
838         git show HEAD~2 | grep "C changed"
839 '
840
841 test_expect_success 'rebase -i can copy notes' '
842         git config notes.rewrite.rebase true &&
843         git config notes.rewriteRef "refs/notes/*" &&
844         test_commit n1 &&
845         test_commit n2 &&
846         test_commit n3 &&
847         git notes add -m"a note" n3 &&
848         git rebase -i --onto n1 n2 &&
849         test "a note" = "$(git notes show HEAD)"
850 '
851
852 test_expect_success 'rebase -i can copy notes over a fixup' '
853         cat >expect <<-\EOF &&
854         an earlier note
855
856         a note
857         EOF
858         git reset --hard n3 &&
859         git notes add -m"an earlier note" n2 &&
860         (
861                 set_fake_editor &&
862                 GIT_NOTES_REWRITE_MODE=concatenate FAKE_LINES="1 f 2" \
863                         git rebase -i n1
864         ) &&
865         git notes show > output &&
866         test_cmp expect output
867 '
868
869 test_expect_success 'rebase while detaching HEAD' '
870         git symbolic-ref HEAD &&
871         grandparent=$(git rev-parse HEAD~2) &&
872         test_tick &&
873         (
874                 set_fake_editor &&
875                 FAKE_LINES="2 1" git rebase -i HEAD~2 HEAD^0
876         ) &&
877         test $grandparent = $(git rev-parse HEAD~2) &&
878         test_must_fail git symbolic-ref HEAD
879 '
880
881 test_tick # Ensure that the rebased commits get a different timestamp.
882 test_expect_success 'always cherry-pick with --no-ff' '
883         git checkout no-ff-branch &&
884         git tag original-no-ff-branch &&
885         git rebase -i --no-ff A &&
886         for p in 0 1 2
887         do
888                 test ! $(git rev-parse HEAD~$p) = $(git rev-parse original-no-ff-branch~$p) &&
889                 git diff HEAD~$p original-no-ff-branch~$p > out &&
890                 test_must_be_empty out
891         done &&
892         test_cmp_rev HEAD~3 original-no-ff-branch~3 &&
893         git diff HEAD~3 original-no-ff-branch~3 > out &&
894         test_must_be_empty out
895 '
896
897 test_expect_success 'set up commits with funny messages' '
898         git checkout -b funny A &&
899         echo >>file1 &&
900         test_tick &&
901         git commit -a -m "end with slash\\" &&
902         echo >>file1 &&
903         test_tick &&
904         git commit -a -m "something (\000) that looks like octal" &&
905         echo >>file1 &&
906         test_tick &&
907         git commit -a -m "something (\n) that looks like a newline" &&
908         echo >>file1 &&
909         test_tick &&
910         git commit -a -m "another commit"
911 '
912
913 test_expect_success 'rebase-i history with funny messages' '
914         git rev-list A..funny >expect &&
915         test_tick &&
916         (
917                 set_fake_editor &&
918                 FAKE_LINES="1 2 3 4" git rebase -i A
919         ) &&
920         git rev-list A.. >actual &&
921         test_cmp expect actual
922 '
923
924 test_expect_success 'prepare for rebase -i --exec' '
925         git checkout primary &&
926         git checkout -b execute &&
927         test_commit one_exec main.txt one_exec &&
928         test_commit two_exec main.txt two_exec &&
929         test_commit three_exec main.txt three_exec
930 '
931
932 test_expect_success 'running "git rebase -i --exec git show HEAD"' '
933         (
934                 set_fake_editor &&
935                 git rebase -i --exec "git show HEAD" HEAD~2 >actual &&
936                 FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD" &&
937                 export FAKE_LINES &&
938                 git rebase -i HEAD~2 >expect
939         ) &&
940         sed -e "1,9d" expect >expected &&
941         test_cmp expected actual
942 '
943
944 test_expect_success 'running "git rebase --exec git show HEAD -i"' '
945         git reset --hard execute &&
946         (
947                 set_fake_editor &&
948                 git rebase --exec "git show HEAD" -i HEAD~2 >actual &&
949                 FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD" &&
950                 export FAKE_LINES &&
951                 git rebase -i HEAD~2 >expect
952         ) &&
953         sed -e "1,9d" expect >expected &&
954         test_cmp expected actual
955 '
956
957 test_expect_success 'running "git rebase -ix git show HEAD"' '
958         git reset --hard execute &&
959         (
960                 set_fake_editor &&
961                 git rebase -ix "git show HEAD" HEAD~2 >actual &&
962                 FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD" &&
963                 export FAKE_LINES &&
964                 git rebase -i HEAD~2 >expect
965         ) &&
966         sed -e "1,9d" expect >expected &&
967         test_cmp expected actual
968 '
969
970
971 test_expect_success 'rebase -ix with several <CMD>' '
972         git reset --hard execute &&
973         (
974                 set_fake_editor &&
975                 git rebase -ix "git show HEAD; pwd" HEAD~2 >actual &&
976                 FAKE_LINES="1 exec_git_show_HEAD;_pwd 2 exec_git_show_HEAD;_pwd" &&
977                 export FAKE_LINES &&
978                 git rebase -i HEAD~2 >expect
979         ) &&
980         sed -e "1,9d" expect >expected &&
981         test_cmp expected actual
982 '
983
984 test_expect_success 'rebase -ix with several instances of --exec' '
985         git reset --hard execute &&
986         (
987                 set_fake_editor &&
988                 git rebase -i --exec "git show HEAD" --exec "pwd" HEAD~2 >actual &&
989                 FAKE_LINES="1 exec_git_show_HEAD exec_pwd 2
990                                 exec_git_show_HEAD exec_pwd" &&
991                 export FAKE_LINES &&
992                 git rebase -i HEAD~2 >expect
993         ) &&
994         sed -e "1,11d" expect >expected &&
995         test_cmp expected actual
996 '
997
998 test_expect_success C_LOCALE_OUTPUT 'rebase -ix with --autosquash' '
999         git reset --hard execute &&
1000         git checkout -b autosquash &&
1001         echo second >second.txt &&
1002         git add second.txt &&
1003         git commit -m "fixup! two_exec" &&
1004         echo bis >bis.txt &&
1005         git add bis.txt &&
1006         git commit -m "fixup! two_exec" &&
1007         git checkout -b autosquash_actual &&
1008         git rebase -i --exec "git show HEAD" --autosquash HEAD~4 >actual &&
1009         git checkout autosquash &&
1010         (
1011                 set_fake_editor &&
1012                 git checkout -b autosquash_expected &&
1013                 FAKE_LINES="1 fixup 3 fixup 4 exec_git_show_HEAD 2 exec_git_show_HEAD" &&
1014                 export FAKE_LINES &&
1015                 git rebase -i HEAD~4 >expect
1016         ) &&
1017         sed -e "1,13d" expect >expected &&
1018         test_cmp expected actual
1019 '
1020
1021 test_expect_success 'rebase --exec works without -i ' '
1022         git reset --hard execute &&
1023         rm -rf exec_output &&
1024         EDITOR="echo >invoked_editor" git rebase --exec "echo a line >>exec_output"  HEAD~2 2>actual &&
1025         test_i18ngrep  "Successfully rebased and updated" actual &&
1026         test_line_count = 2 exec_output &&
1027         test_path_is_missing invoked_editor
1028 '
1029
1030 test_expect_success 'rebase -i --exec without <CMD>' '
1031         git reset --hard execute &&
1032         test_must_fail git rebase -i --exec 2>actual &&
1033         test_i18ngrep "requires a value" actual &&
1034         git checkout primary
1035 '
1036
1037 test_expect_success 'rebase -i --root re-order and drop commits' '
1038         git checkout E &&
1039         (
1040                 set_fake_editor &&
1041                 FAKE_LINES="3 1 2 5" git rebase -i --root
1042         ) &&
1043         test E = $(git cat-file commit HEAD | sed -ne \$p) &&
1044         test B = $(git cat-file commit HEAD^ | sed -ne \$p) &&
1045         test A = $(git cat-file commit HEAD^^ | sed -ne \$p) &&
1046         test C = $(git cat-file commit HEAD^^^ | sed -ne \$p) &&
1047         test 0 = $(git cat-file commit HEAD^^^ | grep -c ^parent\ )
1048 '
1049
1050 test_expect_success 'rebase -i --root retain root commit author and message' '
1051         git checkout A &&
1052         echo B >file7 &&
1053         git add file7 &&
1054         GIT_AUTHOR_NAME="Twerp Snog" git commit -m "different author" &&
1055         (
1056                 set_fake_editor &&
1057                 FAKE_LINES="2" git rebase -i --root
1058         ) &&
1059         git cat-file commit HEAD | grep -q "^author Twerp Snog" &&
1060         git cat-file commit HEAD | grep -q "^different author$"
1061 '
1062
1063 test_expect_success 'rebase -i --root temporary sentinel commit' '
1064         git checkout B &&
1065         (
1066                 set_fake_editor &&
1067                 test_must_fail env FAKE_LINES="2" git rebase -i --root
1068         ) &&
1069         git cat-file commit HEAD | grep "^tree $EMPTY_TREE" &&
1070         git rebase --abort
1071 '
1072
1073 test_expect_success 'rebase -i --root fixup root commit' '
1074         git checkout B &&
1075         (
1076                 set_fake_editor &&
1077                 FAKE_LINES="1 fixup 2" git rebase -i --root
1078         ) &&
1079         test A = $(git cat-file commit HEAD | sed -ne \$p) &&
1080         test B = $(git show HEAD:file1) &&
1081         test 0 = $(git cat-file commit HEAD | grep -c ^parent\ )
1082 '
1083
1084 test_expect_success 'rebase -i --root reword original root commit' '
1085         test_when_finished "test_might_fail git rebase --abort" &&
1086         git checkout -b reword-original-root-branch primary &&
1087         (
1088                 set_fake_editor &&
1089                 FAKE_LINES="reword 1 2" FAKE_COMMIT_MESSAGE="A changed" \
1090                         git rebase -i --root
1091         ) &&
1092         git show HEAD^ | grep "A changed" &&
1093         test -z "$(git show -s --format=%p HEAD^)"
1094 '
1095
1096 test_expect_success 'rebase -i --root reword new root commit' '
1097         test_when_finished "test_might_fail git rebase --abort" &&
1098         git checkout -b reword-now-root-branch primary &&
1099         (
1100                 set_fake_editor &&
1101                 FAKE_LINES="reword 3 1" FAKE_COMMIT_MESSAGE="C changed" \
1102                 git rebase -i --root
1103         ) &&
1104         git show HEAD^ | grep "C changed" &&
1105         test -z "$(git show -s --format=%p HEAD^)"
1106 '
1107
1108 test_expect_success 'rebase -i --root when root has untracked file conflict' '
1109         test_when_finished "reset_rebase" &&
1110         git checkout -b failing-root-pick A &&
1111         echo x >file2 &&
1112         git rm file1 &&
1113         git commit -m "remove file 1 add file 2" &&
1114         echo z >file1 &&
1115         (
1116                 set_fake_editor &&
1117                 test_must_fail env FAKE_LINES="1 2" git rebase -i --root
1118         ) &&
1119         rm file1 &&
1120         git rebase --continue &&
1121         test "$(git log -1 --format=%B)" = "remove file 1 add file 2" &&
1122         test "$(git rev-list --count HEAD)" = 2
1123 '
1124
1125 test_expect_success 'rebase -i --root reword root when root has untracked file conflict' '
1126         test_when_finished "reset_rebase" &&
1127         echo z>file1 &&
1128         (
1129                 set_fake_editor &&
1130                 test_must_fail env FAKE_LINES="reword 1 2" \
1131                         FAKE_COMMIT_MESSAGE="Modified A" git rebase -i --root &&
1132                 rm file1 &&
1133                 FAKE_COMMIT_MESSAGE="Reworded A" git rebase --continue
1134         ) &&
1135         test "$(git log -1 --format=%B HEAD^)" = "Reworded A" &&
1136         test "$(git rev-list --count HEAD)" = 2
1137 '
1138
1139 test_expect_success C_LOCALE_OUTPUT 'rebase --edit-todo does not work on non-interactive rebase' '
1140         git checkout reword-original-root-branch &&
1141         git reset --hard &&
1142         git checkout conflict-branch &&
1143         (
1144                 set_fake_editor &&
1145                 test_must_fail git rebase -f --apply --onto HEAD~2 HEAD~ &&
1146                 test_must_fail git rebase --edit-todo
1147         ) &&
1148         git rebase --abort
1149 '
1150
1151 test_expect_success 'rebase --edit-todo can be used to modify todo' '
1152         git reset --hard &&
1153         git checkout no-conflict-branch^0 &&
1154         (
1155                 set_fake_editor &&
1156                 FAKE_LINES="edit 1 2 3" git rebase -i HEAD~3 &&
1157                 FAKE_LINES="2 1" git rebase --edit-todo &&
1158                 git rebase --continue
1159         ) &&
1160         test M = $(git cat-file commit HEAD^ | sed -ne \$p) &&
1161         test L = $(git cat-file commit HEAD | sed -ne \$p)
1162 '
1163
1164 test_expect_success 'rebase -i produces readable reflog' '
1165         git reset --hard &&
1166         git branch -f branch-reflog-test H &&
1167         git rebase -i --onto I F branch-reflog-test &&
1168         cat >expect <<-\EOF &&
1169         rebase (finish): returning to refs/heads/branch-reflog-test
1170         rebase (pick): H
1171         rebase (pick): G
1172         rebase (start): checkout I
1173         EOF
1174         git reflog -n4 HEAD |
1175         sed "s/[^:]*: //" >actual &&
1176         test_cmp expect actual
1177 '
1178
1179 test_expect_success 'rebase -i respects core.commentchar' '
1180         git reset --hard &&
1181         git checkout E^0 &&
1182         test_config core.commentchar "\\" &&
1183         write_script remove-all-but-first.sh <<-\EOF &&
1184         sed -e "2,\$s/^/\\\\/" "$1" >"$1.tmp" &&
1185         mv "$1.tmp" "$1"
1186         EOF
1187         (
1188                 test_set_editor "$(pwd)/remove-all-but-first.sh" &&
1189                 git rebase -i B
1190         ) &&
1191         test B = $(git cat-file commit HEAD^ | sed -ne \$p)
1192 '
1193
1194 test_expect_success 'rebase -i respects core.commentchar=auto' '
1195         test_config core.commentchar auto &&
1196         write_script copy-edit-script.sh <<-\EOF &&
1197         cp "$1" edit-script
1198         EOF
1199         test_when_finished "git rebase --abort || :" &&
1200         (
1201                 test_set_editor "$(pwd)/copy-edit-script.sh" &&
1202                 git rebase -i HEAD^
1203         ) &&
1204         test -z "$(grep -ve "^#" -e "^\$" -e "^pick" edit-script)"
1205 '
1206
1207 test_expect_success 'rebase -i, with <onto> and <upstream> specified as :/quuxery' '
1208         test_when_finished "git branch -D torebase" &&
1209         git checkout -b torebase branch1 &&
1210         upstream=$(git rev-parse ":/J") &&
1211         onto=$(git rev-parse ":/A") &&
1212         git rebase --onto $onto $upstream &&
1213         git reset --hard branch1 &&
1214         git rebase --onto ":/A" ":/J" &&
1215         git checkout branch1
1216 '
1217
1218 test_expect_success 'rebase -i with --strategy and -X' '
1219         git checkout -b conflict-merge-use-theirs conflict-branch &&
1220         git reset --hard HEAD^ &&
1221         echo five >conflict &&
1222         echo Z >file1 &&
1223         git commit -a -m "one file conflict" &&
1224         EDITOR=true git rebase -i --strategy=recursive -Xours conflict-branch &&
1225         test $(git show conflict-branch:conflict) = $(cat conflict) &&
1226         test $(cat file1) = Z
1227 '
1228
1229 test_expect_success 'interrupted rebase -i with --strategy and -X' '
1230         git checkout -b conflict-merge-use-theirs-interrupted conflict-branch &&
1231         git reset --hard HEAD^ &&
1232         >breakpoint &&
1233         git add breakpoint &&
1234         git commit -m "breakpoint for interactive mode" &&
1235         echo five >conflict &&
1236         echo Z >file1 &&
1237         git commit -a -m "one file conflict" &&
1238         (
1239                 set_fake_editor &&
1240                 FAKE_LINES="edit 1 2" git rebase -i --strategy=recursive \
1241                         -Xours conflict-branch
1242         ) &&
1243         git rebase --continue &&
1244         test $(git show conflict-branch:conflict) = $(cat conflict) &&
1245         test $(cat file1) = Z
1246 '
1247
1248 test_expect_success 'rebase -i error on commits with \ in message' '
1249         current_head=$(git rev-parse HEAD) &&
1250         test_when_finished "git rebase --abort; git reset --hard $current_head; rm -f error" &&
1251         test_commit TO-REMOVE will-conflict old-content &&
1252         test_commit "\temp" will-conflict new-content dummy &&
1253         test_must_fail env EDITOR=true git rebase -i HEAD^ --onto HEAD^^ 2>error &&
1254         test_expect_code 1 grep  "      emp" error
1255 '
1256
1257 test_expect_success 'short commit ID setup' '
1258         test_when_finished "git checkout primary" &&
1259         git checkout --orphan collide &&
1260         git rm -rf . &&
1261         (
1262         unset test_tick &&
1263         test_commit collide1 collide &&
1264         test_commit --notick collide2 collide &&
1265         test_commit --notick collide3 collide
1266         )
1267 '
1268
1269 if test -n "$GIT_TEST_FIND_COLLIDER"
1270 then
1271         author="$(unset test_tick; test_tick; git var GIT_AUTHOR_IDENT)"
1272         committer="$(unset test_tick; test_tick; git var GIT_COMMITTER_IDENT)"
1273         blob="$(git rev-parse collide2:collide)"
1274         from="$(git rev-parse collide1^0)"
1275         repl="commit refs/heads/collider-&\\n"
1276         repl="${repl}author $author\\ncommitter $committer\\n"
1277         repl="${repl}data <<EOF\\ncollide2 &\\nEOF\\n"
1278         repl="${repl}from $from\\nM 100644 $blob collide\\n"
1279         test_seq 1 32768 | sed "s|.*|$repl|" >script &&
1280         git fast-import <script &&
1281         git pack-refs &&
1282         git for-each-ref >refs &&
1283         grep "^$(test_oid t3404_collision)" <refs >matches &&
1284         cat matches &&
1285         test_line_count -gt 2 matches || {
1286                 echo "Could not find a collider" >&2
1287                 exit 1
1288         }
1289 fi
1290
1291 test_expect_success 'short commit ID collide' '
1292         test_oid_cache <<-EOF &&
1293         # collision-related constants
1294         t3404_collision sha1:6bcd
1295         t3404_collision sha256:0161
1296         t3404_collider  sha1:ac4f2ee
1297         t3404_collider  sha256:16697
1298         EOF
1299         test_when_finished "reset_rebase && git checkout primary" &&
1300         git checkout collide &&
1301         colliding_id=$(test_oid t3404_collision) &&
1302         hexsz=$(test_oid hexsz) &&
1303         test $colliding_id = "$(git rev-parse HEAD | cut -c 1-4)" &&
1304         test_config core.abbrev 4 &&
1305         (
1306                 unset test_tick &&
1307                 test_tick &&
1308                 set_fake_editor &&
1309                 FAKE_COMMIT_MESSAGE="collide2 $(test_oid t3404_collider)" \
1310                 FAKE_LINES="reword 1 break 2" git rebase -i HEAD~2 &&
1311                 test $colliding_id = "$(git rev-parse HEAD | cut -c 1-4)" &&
1312                 grep "^pick $colliding_id " \
1313                         .git/rebase-merge/git-rebase-todo.tmp &&
1314                 grep "^pick [0-9a-f]\{$hexsz\}" \
1315                         .git/rebase-merge/git-rebase-todo &&
1316                 grep "^pick [0-9a-f]\{$hexsz\}" \
1317                         .git/rebase-merge/git-rebase-todo.backup &&
1318                 git rebase --continue
1319         ) &&
1320         collide2="$(git rev-parse HEAD~1 | cut -c 1-4)" &&
1321         collide3="$(git rev-parse collide3 | cut -c 1-4)" &&
1322         test "$collide2" = "$collide3"
1323 '
1324
1325 test_expect_success 'respect core.abbrev' '
1326         git config core.abbrev 12 &&
1327         (
1328                 set_cat_todo_editor &&
1329                 test_must_fail git rebase -i HEAD~4 >todo-list
1330         ) &&
1331         test 4 = $(grep -c "pick [0-9a-f]\{12,\}" todo-list)
1332 '
1333
1334 test_expect_success 'todo count' '
1335         write_script dump-raw.sh <<-\EOF &&
1336                 cat "$1"
1337         EOF
1338         (
1339                 test_set_editor "$(pwd)/dump-raw.sh" &&
1340                 git rebase -i HEAD~4 >actual
1341         ) &&
1342         test_i18ngrep "^# Rebase ..* onto ..* ([0-9]" actual
1343 '
1344
1345 test_expect_success 'rebase -i commits that overwrite untracked files (pick)' '
1346         git checkout --force branch2 &&
1347         git clean -f &&
1348         (
1349                 set_fake_editor &&
1350                 FAKE_LINES="edit 1 2" git rebase -i A
1351         ) &&
1352         test_cmp_rev HEAD F &&
1353         test_path_is_missing file6 &&
1354         >file6 &&
1355         test_must_fail git rebase --continue &&
1356         test_cmp_rev HEAD F &&
1357         rm file6 &&
1358         git rebase --continue &&
1359         test_cmp_rev HEAD I
1360 '
1361
1362 test_expect_success 'rebase -i commits that overwrite untracked files (squash)' '
1363         git checkout --force branch2 &&
1364         git clean -f &&
1365         git tag original-branch2 &&
1366         (
1367                 set_fake_editor &&
1368                 FAKE_LINES="edit 1 squash 2" git rebase -i A
1369         ) &&
1370         test_cmp_rev HEAD F &&
1371         test_path_is_missing file6 &&
1372         >file6 &&
1373         test_must_fail git rebase --continue &&
1374         test_cmp_rev HEAD F &&
1375         rm file6 &&
1376         git rebase --continue &&
1377         test $(git cat-file commit HEAD | sed -ne \$p) = I &&
1378         git reset --hard original-branch2
1379 '
1380
1381 test_expect_success 'rebase -i commits that overwrite untracked files (no ff)' '
1382         git checkout --force branch2 &&
1383         git clean -f &&
1384         (
1385                 set_fake_editor &&
1386                 FAKE_LINES="edit 1 2" git rebase -i --no-ff A
1387         ) &&
1388         test $(git cat-file commit HEAD | sed -ne \$p) = F &&
1389         test_path_is_missing file6 &&
1390         >file6 &&
1391         test_must_fail git rebase --continue &&
1392         test $(git cat-file commit HEAD | sed -ne \$p) = F &&
1393         rm file6 &&
1394         git rebase --continue &&
1395         test $(git cat-file commit HEAD | sed -ne \$p) = I
1396 '
1397
1398 test_expect_success 'rebase --continue removes CHERRY_PICK_HEAD' '
1399         git checkout -b commit-to-skip &&
1400         for double in X 3 1
1401         do
1402                 test_seq 5 | sed "s/$double/&&/" >seq &&
1403                 git add seq &&
1404                 test_tick &&
1405                 git commit -m seq-$double
1406         done &&
1407         git tag seq-onto &&
1408         git reset --hard HEAD~2 &&
1409         git cherry-pick seq-onto &&
1410         (
1411                 set_fake_editor &&
1412                 test_must_fail env FAKE_LINES= git rebase -i seq-onto
1413         ) &&
1414         test -d .git/rebase-merge &&
1415         git rebase --continue &&
1416         git diff --exit-code seq-onto &&
1417         test ! -d .git/rebase-merge &&
1418         test ! -f .git/CHERRY_PICK_HEAD
1419 '
1420
1421 rebase_setup_and_clean () {
1422         test_when_finished "
1423                 git checkout primary &&
1424                 test_might_fail git branch -D $1 &&
1425                 test_might_fail git rebase --abort
1426         " &&
1427         git checkout -b $1 ${2:-primary}
1428 }
1429
1430 test_expect_success 'drop' '
1431         rebase_setup_and_clean drop-test &&
1432         (
1433                 set_fake_editor &&
1434                 FAKE_LINES="1 drop 2 3 d 4 5" git rebase -i --root
1435         ) &&
1436         test E = $(git cat-file commit HEAD | sed -ne \$p) &&
1437         test C = $(git cat-file commit HEAD^ | sed -ne \$p) &&
1438         test A = $(git cat-file commit HEAD^^ | sed -ne \$p)
1439 '
1440
1441 test_expect_success 'rebase -i respects rebase.missingCommitsCheck = ignore' '
1442         test_config rebase.missingCommitsCheck ignore &&
1443         rebase_setup_and_clean missing-commit &&
1444         (
1445                 set_fake_editor &&
1446                 FAKE_LINES="1 2 3 4" git rebase -i --root 2>actual
1447         ) &&
1448         test D = $(git cat-file commit HEAD | sed -ne \$p) &&
1449         test_i18ngrep \
1450                 "Successfully rebased and updated refs/heads/missing-commit" \
1451                 actual
1452 '
1453
1454 test_expect_success 'rebase -i respects rebase.missingCommitsCheck = warn' '
1455         cat >expect <<-EOF &&
1456         Warning: some commits may have been dropped accidentally.
1457         Dropped commits (newer to older):
1458          - $(git rev-list --pretty=oneline --abbrev-commit -1 primary)
1459         To avoid this message, use "drop" to explicitly remove a commit.
1460         EOF
1461         test_config rebase.missingCommitsCheck warn &&
1462         rebase_setup_and_clean missing-commit &&
1463         (
1464                 set_fake_editor &&
1465                 FAKE_LINES="1 2 3 4" git rebase -i --root 2>actual.2
1466         ) &&
1467         head -n4 actual.2 >actual &&
1468         test_i18ncmp expect actual &&
1469         test D = $(git cat-file commit HEAD | sed -ne \$p)
1470 '
1471
1472 test_expect_success 'rebase -i respects rebase.missingCommitsCheck = error' '
1473         cat >expect <<-EOF &&
1474         Warning: some commits may have been dropped accidentally.
1475         Dropped commits (newer to older):
1476          - $(git rev-list --pretty=oneline --abbrev-commit -1 primary)
1477          - $(git rev-list --pretty=oneline --abbrev-commit -1 primary~2)
1478         To avoid this message, use "drop" to explicitly remove a commit.
1479
1480         Use '\''git config rebase.missingCommitsCheck'\'' to change the level of warnings.
1481         The possible behaviours are: ignore, warn, error.
1482
1483         You can fix this with '\''git rebase --edit-todo'\'' and then run '\''git rebase --continue'\''.
1484         Or you can abort the rebase with '\''git rebase --abort'\''.
1485         EOF
1486         test_config rebase.missingCommitsCheck error &&
1487         rebase_setup_and_clean missing-commit &&
1488         (
1489                 set_fake_editor &&
1490                 test_must_fail env FAKE_LINES="1 2 4" \
1491                         git rebase -i --root 2>actual &&
1492                 test_i18ncmp expect actual &&
1493                 cp .git/rebase-merge/git-rebase-todo.backup \
1494                         .git/rebase-merge/git-rebase-todo &&
1495                 FAKE_LINES="1 2 drop 3 4 drop 5" git rebase --edit-todo
1496         ) &&
1497         git rebase --continue &&
1498         test D = $(git cat-file commit HEAD | sed -ne \$p) &&
1499         test B = $(git cat-file commit HEAD^ | sed -ne \$p)
1500 '
1501
1502 test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = ignore' '
1503         test_config rebase.missingCommitsCheck ignore &&
1504         rebase_setup_and_clean missing-commit &&
1505         (
1506                 set_fake_editor &&
1507                 FAKE_LINES="break 1 2 3 4 5" git rebase -i --root &&
1508                 FAKE_LINES="1 2 3 4" git rebase --edit-todo &&
1509                 git rebase --continue 2>actual
1510         ) &&
1511         test D = $(git cat-file commit HEAD | sed -ne \$p) &&
1512         test_i18ngrep \
1513                 "Successfully rebased and updated refs/heads/missing-commit" \
1514                 actual
1515 '
1516
1517 test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = warn' '
1518         cat >expect <<-EOF &&
1519         error: invalid line 1: badcmd $(git rev-list --pretty=oneline --abbrev-commit -1 primary~4)
1520         Warning: some commits may have been dropped accidentally.
1521         Dropped commits (newer to older):
1522          - $(git rev-list --pretty=oneline --abbrev-commit -1 primary)
1523          - $(git rev-list --pretty=oneline --abbrev-commit -1 primary~4)
1524         To avoid this message, use "drop" to explicitly remove a commit.
1525         EOF
1526         head -n4 expect >expect.2 &&
1527         tail -n1 expect >>expect.2 &&
1528         tail -n4 expect.2 >expect.3 &&
1529         test_config rebase.missingCommitsCheck warn &&
1530         rebase_setup_and_clean missing-commit &&
1531         (
1532                 set_fake_editor &&
1533                 test_must_fail env FAKE_LINES="bad 1 2 3 4 5" \
1534                         git rebase -i --root &&
1535                 cp .git/rebase-merge/git-rebase-todo.backup orig &&
1536                 FAKE_LINES="2 3 4" git rebase --edit-todo 2>actual.2 &&
1537                 head -n6 actual.2 >actual &&
1538                 test_i18ncmp expect actual &&
1539                 cp orig .git/rebase-merge/git-rebase-todo &&
1540                 FAKE_LINES="1 2 3 4" git rebase --edit-todo 2>actual.2 &&
1541                 head -n4 actual.2 >actual &&
1542                 test_i18ncmp expect.3 actual &&
1543                 git rebase --continue 2>actual
1544         ) &&
1545         test D = $(git cat-file commit HEAD | sed -ne \$p) &&
1546         test_i18ngrep \
1547                 "Successfully rebased and updated refs/heads/missing-commit" \
1548                 actual
1549 '
1550
1551 test_expect_success 'rebase --edit-todo respects rebase.missingCommitsCheck = error' '
1552         cat >expect <<-EOF &&
1553         error: invalid line 1: badcmd $(git rev-list --pretty=oneline --abbrev-commit -1 primary~4)
1554         Warning: some commits may have been dropped accidentally.
1555         Dropped commits (newer to older):
1556          - $(git rev-list --pretty=oneline --abbrev-commit -1 primary)
1557          - $(git rev-list --pretty=oneline --abbrev-commit -1 primary~4)
1558         To avoid this message, use "drop" to explicitly remove a commit.
1559
1560         Use '\''git config rebase.missingCommitsCheck'\'' to change the level of warnings.
1561         The possible behaviours are: ignore, warn, error.
1562
1563         You can fix this with '\''git rebase --edit-todo'\'' and then run '\''git rebase --continue'\''.
1564         Or you can abort the rebase with '\''git rebase --abort'\''.
1565         EOF
1566         tail -n11 expect >expect.2 &&
1567         head -n3 expect.2 >expect.3 &&
1568         tail -n7 expect.2 >>expect.3 &&
1569         test_config rebase.missingCommitsCheck error &&
1570         rebase_setup_and_clean missing-commit &&
1571         (
1572                 set_fake_editor &&
1573                 test_must_fail env FAKE_LINES="bad 1 2 3 4 5" \
1574                         git rebase -i --root &&
1575                 cp .git/rebase-merge/git-rebase-todo.backup orig &&
1576                 test_must_fail env FAKE_LINES="2 3 4" \
1577                         git rebase --edit-todo 2>actual &&
1578                 test_i18ncmp expect actual &&
1579                 test_must_fail git rebase --continue 2>actual &&
1580                 test_i18ncmp expect.2 actual &&
1581                 test_must_fail git rebase --edit-todo &&
1582                 cp orig .git/rebase-merge/git-rebase-todo &&
1583                 test_must_fail env FAKE_LINES="1 2 3 4" \
1584                         git rebase --edit-todo 2>actual &&
1585                 test_i18ncmp expect.3 actual &&
1586                 test_must_fail git rebase --continue 2>actual &&
1587                 test_i18ncmp expect.3 actual &&
1588                 cp orig .git/rebase-merge/git-rebase-todo &&
1589                 FAKE_LINES="1 2 3 4 drop 5" git rebase --edit-todo &&
1590                 git rebase --continue 2>actual
1591         ) &&
1592         test D = $(git cat-file commit HEAD | sed -ne \$p) &&
1593         test_i18ngrep \
1594                 "Successfully rebased and updated refs/heads/missing-commit" \
1595                 actual
1596 '
1597
1598 test_expect_success 'rebase.missingCommitsCheck = error after resolving conflicts' '
1599         test_config rebase.missingCommitsCheck error &&
1600         (
1601                 set_fake_editor &&
1602                 FAKE_LINES="drop 1 break 2 3 4" git rebase -i A E
1603         ) &&
1604         git rebase --edit-todo &&
1605         test_must_fail git rebase --continue &&
1606         echo x >file1 &&
1607         git add file1 &&
1608         git rebase --continue
1609 '
1610
1611 test_expect_success 'rebase.missingCommitsCheck = error when editing for a second time' '
1612         test_config rebase.missingCommitsCheck error &&
1613         (
1614                 set_fake_editor &&
1615                 FAKE_LINES="1 break 2 3" git rebase -i A D &&
1616                 cp .git/rebase-merge/git-rebase-todo todo &&
1617                 test_must_fail env FAKE_LINES=2 git rebase --edit-todo &&
1618                 GIT_SEQUENCE_EDITOR="cp todo" git rebase --edit-todo &&
1619                 git rebase --continue
1620         )
1621 '
1622
1623 test_expect_success 'respects rebase.abbreviateCommands with fixup, squash and exec' '
1624         rebase_setup_and_clean abbrevcmd &&
1625         test_commit "first" file1.txt "first line" first &&
1626         test_commit "second" file1.txt "another line" second &&
1627         test_commit "fixup! first" file2.txt "first line again" first_fixup &&
1628         test_commit "squash! second" file1.txt "another line here" second_squash &&
1629         cat >expected <<-EOF &&
1630         p $(git rev-list --abbrev-commit -1 first) first
1631         f $(git rev-list --abbrev-commit -1 first_fixup) fixup! first
1632         x git show HEAD
1633         p $(git rev-list --abbrev-commit -1 second) second
1634         s $(git rev-list --abbrev-commit -1 second_squash) squash! second
1635         x git show HEAD
1636         EOF
1637         git checkout abbrevcmd &&
1638         test_config rebase.abbreviateCommands true &&
1639         (
1640                 set_cat_todo_editor &&
1641                 test_must_fail git rebase -i --exec "git show HEAD" \
1642                         --autosquash primary >actual
1643         ) &&
1644         test_cmp expected actual
1645 '
1646
1647 test_expect_success 'static check of bad command' '
1648         rebase_setup_and_clean bad-cmd &&
1649         (
1650                 set_fake_editor &&
1651                 test_must_fail env FAKE_LINES="1 2 3 bad 4 5" \
1652                 git rebase -i --root 2>actual &&
1653                 test_i18ngrep "badcmd $(git rev-list --oneline -1 primary~1)" \
1654                                 actual &&
1655                 test_i18ngrep "You can fix this with .git rebase --edit-todo.." \
1656                                 actual &&
1657                 FAKE_LINES="1 2 3 drop 4 5" git rebase --edit-todo
1658         ) &&
1659         git rebase --continue &&
1660         test E = $(git cat-file commit HEAD | sed -ne \$p) &&
1661         test C = $(git cat-file commit HEAD^ | sed -ne \$p)
1662 '
1663
1664 test_expect_success 'tabs and spaces are accepted in the todolist' '
1665         rebase_setup_and_clean indented-comment &&
1666         write_script add-indent.sh <<-\EOF &&
1667         (
1668                 # Turn single spaces into space/tab mix
1669                 sed "1s/ /      /g; 2s/ /  /g; 3s/ /    /g" "$1"
1670                 printf "\n\t# comment\n #more\n\t # comment\n"
1671         ) >"$1.new"
1672         mv "$1.new" "$1"
1673         EOF
1674         (
1675                 test_set_editor "$(pwd)/add-indent.sh" &&
1676                 git rebase -i HEAD^^^
1677         ) &&
1678         test E = $(git cat-file commit HEAD | sed -ne \$p)
1679 '
1680
1681 test_expect_success 'static check of bad SHA-1' '
1682         rebase_setup_and_clean bad-sha &&
1683         (
1684                 set_fake_editor &&
1685                 test_must_fail env FAKE_LINES="1 2 edit fakesha 3 4 5 #" \
1686                         git rebase -i --root 2>actual &&
1687                         test_i18ngrep "edit XXXXXXX False commit" actual &&
1688                         test_i18ngrep "You can fix this with .git rebase --edit-todo.." \
1689                                         actual &&
1690                 FAKE_LINES="1 2 4 5 6" git rebase --edit-todo
1691         ) &&
1692         git rebase --continue &&
1693         test E = $(git cat-file commit HEAD | sed -ne \$p)
1694 '
1695
1696 test_expect_success 'editor saves as CR/LF' '
1697         git checkout -b with-crlf &&
1698         write_script add-crs.sh <<-\EOF &&
1699         sed -e "s/\$/Q/" <"$1" | tr Q "\\015" >"$1".new &&
1700         mv -f "$1".new "$1"
1701         EOF
1702         (
1703                 test_set_editor "$(pwd)/add-crs.sh" &&
1704                 git rebase -i HEAD^
1705         )
1706 '
1707
1708 test_expect_success 'rebase -i --gpg-sign=<key-id>' '
1709         test_when_finished "test_might_fail git rebase --abort" &&
1710         (
1711                 set_fake_editor &&
1712                 FAKE_LINES="edit 1" git rebase -i --gpg-sign="\"S I Gner\"" \
1713                         HEAD^ >out 2>err
1714         ) &&
1715         test_i18ngrep "$SQ-S\"S I Gner\"$SQ" err
1716 '
1717
1718 test_expect_success 'rebase -i --gpg-sign=<key-id> overrides commit.gpgSign' '
1719         test_when_finished "test_might_fail git rebase --abort" &&
1720         test_config commit.gpgsign true &&
1721         (
1722                 set_fake_editor &&
1723                 FAKE_LINES="edit 1" git rebase -i --gpg-sign="\"S I Gner\"" \
1724                         HEAD^ >out 2>err
1725         ) &&
1726         test_i18ngrep "$SQ-S\"S I Gner\"$SQ" err
1727 '
1728
1729 test_expect_success 'valid author header after --root swap' '
1730         rebase_setup_and_clean author-header no-conflict-branch &&
1731         git commit --amend --author="Au ${SQ}thor <author@example.com>" --no-edit &&
1732         git cat-file commit HEAD | grep ^author >expected &&
1733         (
1734                 set_fake_editor &&
1735                 FAKE_LINES="5 1" git rebase -i --root
1736         ) &&
1737         git cat-file commit HEAD^ | grep ^author >actual &&
1738         test_cmp expected actual
1739 '
1740
1741 test_expect_success 'valid author header when author contains single quote' '
1742         rebase_setup_and_clean author-header no-conflict-branch &&
1743         git commit --amend --author="Au ${SQ}thor <author@example.com>" --no-edit &&
1744         git cat-file commit HEAD | grep ^author >expected &&
1745         (
1746                 set_fake_editor &&
1747                 FAKE_LINES="2" git rebase -i HEAD~2
1748         ) &&
1749         git cat-file commit HEAD | grep ^author >actual &&
1750         test_cmp expected actual
1751 '
1752
1753 test_expect_success 'post-commit hook is called' '
1754         test_when_finished "rm -f .git/hooks/post-commit" &&
1755         >actual &&
1756         mkdir -p .git/hooks &&
1757         write_script .git/hooks/post-commit <<-\EOS &&
1758         git rev-parse HEAD >>actual
1759         EOS
1760         (
1761                 set_fake_editor &&
1762                 FAKE_LINES="edit 4 1 reword 2 fixup 3" git rebase -i A E &&
1763                 echo x>file3 &&
1764                 git add file3 &&
1765                 FAKE_COMMIT_MESSAGE=edited git rebase --continue
1766         ) &&
1767         git rev-parse HEAD@{5} HEAD@{4} HEAD@{3} HEAD@{2} HEAD@{1} HEAD \
1768                 >expect &&
1769         test_cmp expect actual
1770 '
1771
1772 test_expect_success 'correct error message for partial commit after empty pick' '
1773         test_when_finished "git rebase --abort" &&
1774         (
1775                 set_fake_editor &&
1776                 FAKE_LINES="2 1 1" &&
1777                 export FAKE_LINES &&
1778                 test_must_fail git rebase -i A D
1779         ) &&
1780         echo x >file1 &&
1781         test_must_fail git commit file1 2>err &&
1782         test_i18ngrep "cannot do a partial commit during a rebase." err
1783 '
1784
1785 test_expect_success 'correct error message for commit --amend after empty pick' '
1786         test_when_finished "git rebase --abort" &&
1787         (
1788                 set_fake_editor &&
1789                 FAKE_LINES="1 1" &&
1790                 export FAKE_LINES &&
1791                 test_must_fail git rebase -i A D
1792         ) &&
1793         echo x>file1 &&
1794         test_must_fail git commit -a --amend 2>err &&
1795         test_i18ngrep "middle of a rebase -- cannot amend." err
1796 '
1797
1798 test_expect_success 'todo has correct onto hash' '
1799         GIT_SEQUENCE_EDITOR=cat git rebase -i no-conflict-branch~4 no-conflict-branch >actual &&
1800         onto=$(git rev-parse --short HEAD~4) &&
1801         test_i18ngrep "^# Rebase ..* onto $onto" actual
1802 '
1803
1804 test_expect_success 'ORIG_HEAD is updated correctly' '
1805         test_when_finished "git checkout primary && git branch -D test-orig-head" &&
1806         git checkout -b test-orig-head A &&
1807         git commit --allow-empty -m A1 &&
1808         git commit --allow-empty -m A2 &&
1809         git commit --allow-empty -m A3 &&
1810         git commit --allow-empty -m A4 &&
1811         git rebase primary &&
1812         test_cmp_rev ORIG_HEAD test-orig-head@{1}
1813 '
1814
1815 # This must be the last test in this file
1816 test_expect_success '$EDITOR and friends are unchanged' '
1817         test_editor_unchanged
1818 '
1819
1820 test_done