3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description
='git rebase interactive
8 This test runs git rebase "interactively", by faking an edit, and verifies
9 that the result still makes sense.
13 one - two - three - four (conflict-branch)
15 A - B - C - D - E (master)
21 | J - K - L - M (no-conflict-branch)
23 N - O - P (no-ff-branch)
25 where A, B, D and G all touch file1, and one, two, three, four all
26 touch file "conflict".
30 .
"$TEST_DIRECTORY"/lib-rebase.sh
32 # WARNING: Modifications to the initial repository can change the SHA ID used
33 # in the expect2 file for the 'stop on conflicting pick' test.
35 test_expect_success
'setup' '
36 test_commit A file1 &&
37 test_commit B file1 &&
38 test_commit C file2 &&
39 test_commit D file1 &&
40 test_commit E file3 &&
41 git checkout -b branch1 A &&
42 test_commit F file4 &&
43 test_commit G file1 &&
44 test_commit H file5 &&
45 git checkout -b branch2 F &&
46 test_commit I file6 &&
47 git checkout -b conflict-branch A &&
48 test_commit one conflict &&
49 test_commit two conflict &&
50 test_commit three conflict &&
51 test_commit four conflict &&
52 git checkout -b no-conflict-branch A &&
53 test_commit J fileJ &&
54 test_commit K fileK &&
55 test_commit L fileL &&
56 test_commit M fileM &&
57 git checkout -b no-ff-branch A &&
58 test_commit N fileN &&
59 test_commit O fileO &&
63 # "exec" commands are run with the user shell by default, but this may
64 # be non-POSIX. For example, if SHELL=zsh then ">file" doesn't work
65 # to create a file. Unsetting SHELL avoids such non-portable behavior
66 # in tests. It must be exported for it to take effect where needed.
70 test_expect_success
'rebase --keep-empty' '
71 git checkout -b emptybranch master &&
72 git commit --allow-empty -m "empty" &&
73 git rebase --keep-empty -i HEAD~2 &&
74 git log --oneline >actual &&
75 test_line_count = 6 actual
82 test_expect_success
'rebase -i with empty HEAD' '
84 test_must_fail env FAKE_LINES="1 exec_true" git rebase -i HEAD^ >actual 2>&1 &&
85 test_i18ncmp expect actual
88 test_expect_success
'rebase -i with the exec command' '
89 git checkout master &&
92 FAKE_LINES="1 exec_>touch-one
93 2 exec_>touch-two exec_false exec_>touch-three
94 3 4 exec_>\"touch-file__name_with_spaces\";_>touch-after-semicolon 5" &&
96 test_must_fail git rebase -i A
98 test_path_is_file touch-one &&
99 test_path_is_file touch-two &&
100 test_path_is_missing touch-three " (should have stopped before)" &&
101 test_cmp_rev C HEAD &&
102 git rebase --continue &&
103 test_path_is_file touch-three &&
104 test_path_is_file "touch-file name with spaces" &&
105 test_path_is_file touch-after-semicolon &&
106 test_cmp_rev master HEAD &&
110 test_expect_success
'rebase -i with the exec command runs from tree root' '
111 git checkout master &&
112 mkdir subdir && (cd subdir &&
114 FAKE_LINES="1 exec_>touch-subdir" \
117 test_path_is_file touch-subdir &&
121 test_expect_success
'rebase -i with exec allows git commands in subdirs' '
122 test_when_finished "rm -rf subdir" &&
123 test_when_finished "git rebase --abort ||:" &&
124 git checkout master &&
125 mkdir subdir && (cd subdir &&
127 FAKE_LINES="1 x_cd_subdir_&&_git_rev-parse_--is-inside-work-tree" \
132 test_expect_success
'rebase -i sets work tree properly' '
133 test_when_finished "rm -rf subdir" &&
134 test_when_finished "test_might_fail git rebase --abort" &&
136 git rebase -x "(cd subdir && git rev-parse --show-toplevel)" HEAD^ \
138 ! grep "/subdir$" actual
141 test_expect_success
'rebase -i with the exec command checks tree cleanness' '
142 git checkout master &&
144 test_must_fail env FAKE_LINES="exec_echo_foo_>file1 1" git rebase -i HEAD^ &&
145 test_cmp_rev master^ HEAD &&
147 git rebase --continue
150 test_expect_success
'rebase -x with empty command fails' '
151 test_when_finished "git rebase --abort ||:" &&
152 test_must_fail env git rebase -x "" @ 2>actual &&
153 test_write_lines "error: empty exec command" >expected &&
154 test_i18ncmp expected actual &&
155 test_must_fail env git rebase -x " " @ 2>actual &&
156 test_i18ncmp expected actual
161 test_expect_success
'rebase -x with newline in command fails' '
162 test_when_finished "git rebase --abort ||:" &&
163 test_must_fail env git rebase -x "a${LF}b" @ 2>actual &&
164 test_write_lines "error: exec commands cannot contain newlines" \
166 test_i18ncmp expected actual
169 test_expect_success
'rebase -i with exec of inexistent command' '
170 git checkout master &&
171 test_when_finished "git rebase --abort" &&
173 test_must_fail env FAKE_LINES="exec_this-command-does-not-exist 1" \
174 git rebase -i HEAD^ >actual 2>&1 &&
175 ! grep "Maybe git-rebase is broken" actual
178 test_expect_success
'implicit interactive rebase does not invoke sequence editor' '
179 test_when_finished "git rebase --abort ||:" &&
180 GIT_SEQUENCE_EDITOR="echo bad >" git rebase -x"echo one" @^
183 test_expect_success
'no changes are a nop' '
184 git checkout branch2 &&
187 test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch2" &&
188 test $(git rev-parse I) = $(git rev-parse HEAD)
191 test_expect_success
'test the [branch] option' '
192 git checkout -b dead-end &&
194 git commit -m "stop here" &&
196 git rebase -i F branch2 &&
197 test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch2" &&
198 test $(git rev-parse I) = $(git rev-parse branch2) &&
199 test $(git rev-parse I) = $(git rev-parse HEAD)
202 test_expect_success
'test --onto <branch>' '
203 git checkout -b test-onto branch2 &&
205 git rebase -i --onto branch1 F &&
206 test "$(git symbolic-ref -q HEAD)" = "refs/heads/test-onto" &&
207 test $(git rev-parse HEAD^) = $(git rev-parse branch1) &&
208 test $(git rev-parse I) = $(git rev-parse branch2)
211 test_expect_success
'rebase on top of a non-conflicting commit' '
212 git checkout branch1 &&
213 git tag original-branch1 &&
215 git rebase -i branch2 &&
216 test file6 = $(git diff --name-only original-branch1) &&
217 test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch1" &&
218 test $(git rev-parse I) = $(git rev-parse branch2) &&
219 test $(git rev-parse I) = $(git rev-parse HEAD~2)
222 test_expect_success
'reflog for the branch shows state before rebase' '
223 test $(git rev-parse branch1@{1}) = $(git rev-parse original-branch1)
226 test_expect_success
'reflog for the branch shows correct finish message' '
227 printf "rebase -i (finish): refs/heads/branch1 onto %s\n" \
228 "$(git rev-parse branch2)" >expected &&
229 git log -g --pretty=%gs -1 refs/heads/branch1 >actual &&
230 test_cmp expected actual
233 test_expect_success
'exchange two commits' '
235 FAKE_LINES="2 1" git rebase -i HEAD~2 &&
236 test H = $(git cat-file commit HEAD^ | sed -ne \$p) &&
237 test G = $(git cat-file commit HEAD | sed -ne \$p)
241 diff --git a/file1 b/file1
242 index f70f10e..fd79235 100644
258 test_expect_success
'stop on conflicting pick' '
259 git tag new-branch1 &&
261 test_must_fail git rebase -i master &&
262 test "$(git rev-parse HEAD~3)" = "$(git rev-parse master)" &&
263 test_cmp expect .git/rebase-merge/patch &&
264 test_cmp expect2 file1 &&
265 test "$(git diff --name-status |
266 sed -n -e "/^U/s/^U[^a-z]*//p")" = file1 &&
267 test 4 = $(grep -v "^#" < .git/rebase-merge/done | wc -l) &&
268 test 0 = $(grep -c "^[^#]" < .git/rebase-merge/git-rebase-todo)
271 test_expect_success
'show conflicted patch' '
272 GIT_TRACE=1 git rebase --show-current-patch >/dev/null 2>stderr &&
273 grep "show.*REBASE_HEAD" stderr &&
274 # the original stopped-sha1 is abbreviated
275 stopped_sha1="$(git rev-parse $(cat ".git/rebase-merge/stopped-sha"))" &&
276 test "$(git rev-parse REBASE_HEAD)" = "$stopped_sha1"
279 test_expect_success
'abort' '
280 git rebase --abort &&
281 test $(git rev-parse new-branch1) = $(git rev-parse HEAD) &&
282 test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch1" &&
283 test_path_is_missing .git/rebase-merge
286 test_expect_success
'abort with error when new base cannot be checked out' '
287 git rm --cached file1 &&
288 git commit -m "remove file in base" &&
290 test_must_fail git rebase -i master > output 2>&1 &&
291 test_i18ngrep "The following untracked working tree files would be overwritten by checkout:" \
293 test_i18ngrep "file1" output &&
294 test_path_is_missing .git/rebase-merge &&
295 git reset --hard HEAD^
298 test_expect_success
'retain authorship' '
302 GIT_AUTHOR_NAME="Twerp Snog" git commit -m "different author" &&
305 git rebase -i --onto master HEAD^ &&
306 git show HEAD | grep "^Author: Twerp Snog"
309 test_expect_success
'retain authorship w/ conflicts' '
310 oGIT_AUTHOR_NAME=$GIT_AUTHOR_NAME &&
311 test_when_finished "GIT_AUTHOR_NAME=\$oGIT_AUTHOR_NAME" &&
313 git reset --hard twerp &&
314 test_commit a conflict a conflict-a &&
315 git reset --hard twerp &&
317 GIT_AUTHOR_NAME=AttributeMe &&
318 export GIT_AUTHOR_NAME &&
319 test_commit b conflict b conflict-b &&
320 GIT_AUTHOR_NAME=$oGIT_AUTHOR_NAME &&
323 test_must_fail git rebase -i conflict-a &&
324 echo resolved >conflict &&
326 git rebase --continue &&
327 test $(git rev-parse conflict-a^0) = $(git rev-parse HEAD^) &&
332 test_expect_success
'squash' '
333 git reset --hard twerp &&
336 GIT_AUTHOR_NAME="Nitfol" git commit -m "nitfol" file7 &&
337 echo "******************************" &&
339 FAKE_LINES="1 squash 2" EXPECT_HEADER_COUNT=2 \
340 git rebase -i --onto master HEAD~2 &&
341 test B = $(cat file7) &&
342 test $(git rev-parse HEAD^) = $(git rev-parse master)
345 test_expect_success
'retain authorship when squashing' '
346 git show HEAD | grep "^Author: Twerp Snog"
349 test_expect_success REBASE_P
'-p handles "no changes" gracefully' '
350 HEAD=$(git rev-parse HEAD) &&
352 git rebase -i -p HEAD^ &&
353 git update-index --refresh &&
354 git diff-files --quiet &&
355 git diff-index --quiet --cached HEAD -- &&
356 test $HEAD = $(git rev-parse HEAD)
359 test_expect_failure REBASE_P
'exchange two commits with -p' '
362 FAKE_LINES="2 1" git rebase -i -p HEAD~2 &&
363 test H = $(git cat-file commit HEAD^ | sed -ne \$p) &&
364 test G = $(git cat-file commit HEAD | sed -ne \$p)
367 test_expect_success REBASE_P
'preserve merges with -p' '
368 git checkout -b to-be-preserved master^ &&
369 : > unrelated-file &&
370 git add unrelated-file &&
372 git commit -m "unrelated" &&
373 git checkout -b another-branch master &&
376 git commit -m J file1 &&
378 git merge to-be-preserved &&
381 git commit -m K file1 &&
384 git commit -m L1 file1 &&
385 git checkout HEAD^ &&
386 echo 1 > unrelated-file &&
388 git commit -m L2 unrelated-file &&
390 git merge another-branch &&
393 git commit -m M file1 &&
394 git checkout -b to-be-rebased &&
397 git rebase -i -p --onto branch1 master &&
398 git update-index --refresh &&
399 git diff-files --quiet &&
400 git diff-index --quiet --cached HEAD -- &&
401 test $(git rev-parse HEAD~6) = $(git rev-parse branch1) &&
402 test $(git rev-parse HEAD~4^2) = $(git rev-parse to-be-preserved) &&
403 test $(git rev-parse HEAD^^2^) = $(git rev-parse HEAD^^^) &&
404 test $(git show HEAD~5:file1) = B &&
405 test $(git show HEAD~3:file1) = C &&
406 test $(git show HEAD:file1) = E &&
407 test $(git show HEAD:unrelated-file) = 1
410 test_expect_success REBASE_P
'edit ancestor with -p' '
412 FAKE_LINES="1 2 edit 3 4" git rebase -i -p HEAD~3 &&
413 echo 2 > unrelated-file &&
415 git commit -m L2-modified --amend unrelated-file &&
416 git rebase --continue &&
417 git update-index --refresh &&
418 git diff-files --quiet &&
419 git diff-index --quiet --cached HEAD -- &&
420 test $(git show HEAD:unrelated-file) = 2
423 test_expect_success
'--continue tries to commit' '
424 git reset --hard D &&
427 test_must_fail git rebase -i --onto new-branch1 HEAD^ &&
428 echo resolved > file1 &&
430 FAKE_COMMIT_MESSAGE="chouette!" git rebase --continue &&
431 test $(git rev-parse HEAD^) = $(git rev-parse new-branch1) &&
432 git show HEAD | grep chouette
435 test_expect_success
'verbose flag is heeded, even after --continue' '
436 git reset --hard master@{1} &&
439 test_must_fail git rebase -v -i --onto new-branch1 HEAD^ &&
440 echo resolved > file1 &&
442 git rebase --continue > output &&
443 grep "^ file1 | 2 +-$" output
446 test_expect_success C_LOCALE_OUTPUT
'multi-squash only fires up editor once' '
447 base=$(git rev-parse HEAD~4) &&
449 FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="1 squash 2 squash 3 squash 4" \
450 EXPECT_HEADER_COUNT=4 \
451 git rebase -i $base &&
452 test $base = $(git rev-parse HEAD^) &&
453 test 1 = $(git show | grep ONCE | wc -l)
456 test_expect_success C_LOCALE_OUTPUT
'multi-fixup does not fire up editor' '
457 git checkout -b multi-fixup E &&
458 base=$(git rev-parse HEAD~4) &&
460 FAKE_COMMIT_AMEND="NEVER" FAKE_LINES="1 fixup 2 fixup 3 fixup 4" \
461 git rebase -i $base &&
462 test $base = $(git rev-parse HEAD^) &&
463 test 0 = $(git show | grep NEVER | wc -l) &&
464 git checkout @{-1} &&
465 git branch -D multi-fixup
468 test_expect_success
'commit message used after conflict' '
469 git checkout -b conflict-fixup conflict-branch &&
470 base=$(git rev-parse HEAD~4) &&
472 test_must_fail env FAKE_LINES="1 fixup 3 fixup 4" git rebase -i $base &&
473 echo three > conflict &&
475 FAKE_COMMIT_AMEND="ONCE" EXPECT_HEADER_COUNT=2 \
476 git rebase --continue &&
477 test $base = $(git rev-parse HEAD^) &&
478 test 1 = $(git show | grep ONCE | wc -l) &&
479 git checkout @{-1} &&
480 git branch -D conflict-fixup
483 test_expect_success
'commit message retained after conflict' '
484 git checkout -b conflict-squash conflict-branch &&
485 base=$(git rev-parse HEAD~4) &&
487 test_must_fail env FAKE_LINES="1 fixup 3 squash 4" git rebase -i $base &&
488 echo three > conflict &&
490 FAKE_COMMIT_AMEND="TWICE" EXPECT_HEADER_COUNT=2 \
491 git rebase --continue &&
492 test $base = $(git rev-parse HEAD^) &&
493 test 2 = $(git show | grep TWICE | wc -l) &&
494 git checkout @{-1} &&
495 git branch -D conflict-squash
498 cat > expect-squash-fixup
<< EOF
506 test_expect_success C_LOCALE_OUTPUT
'squash and fixup generate correct log messages' '
507 git checkout -b squash-fixup E &&
508 base=$(git rev-parse HEAD~4) &&
510 FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="1 fixup 2 squash 3 fixup 4" \
511 EXPECT_HEADER_COUNT=4 \
512 git rebase -i $base &&
513 git cat-file commit HEAD | sed -e 1,/^\$/d > actual-squash-fixup &&
514 test_cmp expect-squash-fixup actual-squash-fixup &&
515 git cat-file commit HEAD@{2} |
516 grep "^# This is a combination of 3 commits\." &&
517 git cat-file commit HEAD@{3} |
518 grep "^# This is a combination of 2 commits\." &&
519 git checkout @{-1} &&
520 git branch -D squash-fixup
523 test_expect_success C_LOCALE_OUTPUT
'squash ignores comments' '
524 git checkout -b skip-comments E &&
525 base=$(git rev-parse HEAD~4) &&
527 FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="# 1 # squash 2 # squash 3 # squash 4 #" \
528 EXPECT_HEADER_COUNT=4 \
529 git rebase -i $base &&
530 test $base = $(git rev-parse HEAD^) &&
531 test 1 = $(git show | grep ONCE | wc -l) &&
532 git checkout @{-1} &&
533 git branch -D skip-comments
536 test_expect_success C_LOCALE_OUTPUT
'squash ignores blank lines' '
537 git checkout -b skip-blank-lines E &&
538 base=$(git rev-parse HEAD~4) &&
540 FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="> 1 > squash 2 > squash 3 > squash 4 >" \
541 EXPECT_HEADER_COUNT=4 \
542 git rebase -i $base &&
543 test $base = $(git rev-parse HEAD^) &&
544 test 1 = $(git show | grep ONCE | wc -l) &&
545 git checkout @{-1} &&
546 git branch -D skip-blank-lines
549 test_expect_success
'squash works as expected' '
550 git checkout -b squash-works no-conflict-branch &&
551 one=$(git rev-parse HEAD~3) &&
553 FAKE_LINES="1 s 3 2" EXPECT_HEADER_COUNT=2 \
554 git rebase -i HEAD~3 &&
555 test $one = $(git rev-parse HEAD~2)
558 test_expect_success
'interrupted squash works as expected' '
559 git checkout -b interrupted-squash conflict-branch &&
560 one=$(git rev-parse HEAD~3) &&
562 test_must_fail env FAKE_LINES="1 squash 3 2" git rebase -i HEAD~3 &&
563 test_write_lines one two four > conflict &&
565 test_must_fail git rebase --continue &&
566 echo resolved > conflict &&
568 git rebase --continue &&
569 test $one = $(git rev-parse HEAD~2)
572 test_expect_success
'interrupted squash works as expected (case 2)' '
573 git checkout -b interrupted-squash2 conflict-branch &&
574 one=$(git rev-parse HEAD~3) &&
576 test_must_fail env FAKE_LINES="3 squash 1 2" git rebase -i HEAD~3 &&
577 test_write_lines one four > conflict &&
579 test_must_fail git rebase --continue &&
580 test_write_lines one two four > conflict &&
582 test_must_fail git rebase --continue &&
583 echo resolved > conflict &&
585 git rebase --continue &&
586 test $one = $(git rev-parse HEAD~2)
589 test_expect_success
'--continue tries to commit, even for "edit"' '
590 echo unrelated > file7 &&
593 git commit -m "unrelated change" &&
594 parent=$(git rev-parse HEAD^) &&
597 FAKE_LINES="edit 1" git rebase -i HEAD^ &&
598 echo edited > file7 &&
600 FAKE_COMMIT_MESSAGE="chouette!" git rebase --continue &&
601 test edited = $(git show HEAD:file7) &&
602 git show HEAD | grep chouette &&
603 test $parent = $(git rev-parse HEAD^)
606 test_expect_success
'aborted --continue does not squash commits after "edit"' '
607 old=$(git rev-parse HEAD) &&
610 FAKE_LINES="edit 1" git rebase -i HEAD^ &&
611 echo "edited again" > file7 &&
613 test_must_fail env FAKE_COMMIT_MESSAGE=" " git rebase --continue &&
614 test $old = $(git rev-parse HEAD) &&
618 test_expect_success
'auto-amend only edited commits after "edit"' '
621 FAKE_LINES="edit 1" git rebase -i HEAD^ &&
622 echo "edited again" > file7 &&
624 FAKE_COMMIT_MESSAGE="edited file7 again" git commit &&
625 echo "and again" > file7 &&
628 test_must_fail env FAKE_COMMIT_MESSAGE="and again" git rebase --continue &&
632 test_expect_success
'clean error after failed "exec"' '
634 test_when_finished "git rebase --abort || :" &&
636 test_must_fail env FAKE_LINES="1 exec_false" git rebase -i HEAD^ &&
637 echo "edited again" > file7 &&
639 test_must_fail git rebase --continue 2>error &&
640 test_i18ngrep "you have staged changes in your working tree" error
643 test_expect_success
'rebase a detached HEAD' '
644 grandparent=$(git rev-parse HEAD~2) &&
645 git checkout $(git rev-parse HEAD) &&
648 FAKE_LINES="2 1" git rebase -i HEAD~2 &&
649 test $grandparent = $(git rev-parse HEAD~2)
652 test_expect_success
'rebase a commit violating pre-commit' '
654 mkdir -p .git/hooks &&
655 write_script .git/hooks/pre-commit <<-\EOF &&
656 test -z "$(git diff --cached --check)"
658 echo "monde! " >> file1 &&
660 test_must_fail git commit -m doesnt-verify file1 &&
661 git commit -m doesnt-verify --no-verify file1 &&
664 FAKE_LINES=2 git rebase -i HEAD~2
668 test_expect_success
'rebase with a file named HEAD in worktree' '
672 git checkout -b branch3 A &&
675 GIT_AUTHOR_NAME="Squashed Away" &&
676 export GIT_AUTHOR_NAME &&
679 git commit -m "Add head" &&
682 git commit -m "Add body"
686 FAKE_LINES="1 squash 2" git rebase -i @{-1} &&
687 test "$(git show -s --pretty=format:%an)" = "Squashed Away"
691 test_expect_success
'do "noop" when there is nothing to cherry-pick' '
693 git checkout -b branch4 HEAD &&
694 GIT_EDITOR=: git commit --amend \
695 --author="Somebody else <somebody@else.com>" &&
696 test $(git rev-parse branch3) != $(git rev-parse branch4) &&
698 git rebase -i branch3 &&
699 test $(git rev-parse branch3) = $(git rev-parse branch4)
703 test_expect_success
'submodule rebase setup' '
707 cd sub && git init && >elif &&
708 git add elif && git commit -m "submodule initial"
713 git commit -m "One" &&
716 git commit -a -m "Two" &&
718 cd sub && echo 3 >elif &&
719 git commit -a -m "submodule second"
723 git commit -a -m "Three changes submodule"
726 test_expect_success
'submodule rebase -i' '
728 FAKE_LINES="1 squash 2 3" git rebase -i A
731 test_expect_success
'submodule conflict setup' '
732 git tag submodule-base &&
733 git checkout HEAD^ &&
735 cd sub && git checkout HEAD^ && echo 4 >elif &&
736 git add elif && git commit -m "submodule conflict"
740 git commit -m "Conflict in submodule" &&
741 git tag submodule-topic
744 test_expect_success
'rebase -i continue with only submodule staged' '
746 test_must_fail git rebase -i submodule-base &&
748 git rebase --continue &&
749 test $(git rev-parse submodule-base) != $(git rev-parse HEAD)
752 test_expect_success
'rebase -i continue with unstaged submodule' '
753 git checkout submodule-topic &&
756 test_must_fail git rebase -i submodule-base &&
758 git rebase --continue &&
759 test $(git rev-parse submodule-base) = $(git rev-parse HEAD)
762 test_expect_success
'avoid unnecessary reset' '
763 git checkout master &&
765 test-tool chmtime =123456789 file3 &&
766 git update-index --refresh &&
767 HEAD=$(git rev-parse HEAD) &&
769 git rebase -i HEAD~4 &&
770 test $HEAD = $(git rev-parse HEAD) &&
771 MTIME=$(test-tool chmtime --get file3) &&
772 test 123456789 = $MTIME
775 test_expect_success
'reword' '
776 git checkout -b reword-branch master &&
778 FAKE_LINES="1 2 3 reword 4" FAKE_COMMIT_MESSAGE="E changed" git rebase -i A &&
779 git show HEAD | grep "E changed" &&
780 test $(git rev-parse master) != $(git rev-parse HEAD) &&
781 test $(git rev-parse master^) = $(git rev-parse HEAD^) &&
782 FAKE_LINES="1 2 reword 3 4" FAKE_COMMIT_MESSAGE="D changed" git rebase -i A &&
783 git show HEAD^ | grep "D changed" &&
784 FAKE_LINES="reword 1 2 3 4" FAKE_COMMIT_MESSAGE="B changed" git rebase -i A &&
785 git show HEAD~3 | grep "B changed" &&
786 FAKE_LINES="1 r 2 pick 3 p 4" FAKE_COMMIT_MESSAGE="C changed" git rebase -i A &&
787 git show HEAD~2 | grep "C changed"
790 test_expect_success
'rebase -i can copy notes' '
791 git config notes.rewrite.rebase true &&
792 git config notes.rewriteRef "refs/notes/*" &&
796 git notes add -m"a note" n3 &&
798 git rebase -i --onto n1 n2 &&
799 test "a note" = "$(git notes show HEAD)"
808 test_expect_success
'rebase -i can copy notes over a fixup' '
809 git reset --hard n3 &&
810 git notes add -m"an earlier note" n2 &&
812 GIT_NOTES_REWRITE_MODE=concatenate FAKE_LINES="1 f 2" git rebase -i n1 &&
813 git notes show > output &&
814 test_cmp expect output
817 test_expect_success
'rebase while detaching HEAD' '
818 git symbolic-ref HEAD &&
819 grandparent=$(git rev-parse HEAD~2) &&
822 FAKE_LINES="2 1" git rebase -i HEAD~2 HEAD^0 &&
823 test $grandparent = $(git rev-parse HEAD~2) &&
824 test_must_fail git symbolic-ref HEAD
827 test_tick
# Ensure that the rebased commits get a different timestamp.
828 test_expect_success
'always cherry-pick with --no-ff' '
829 git checkout no-ff-branch &&
830 git tag original-no-ff-branch &&
832 git rebase -i --no-ff A &&
835 test ! $(git rev-parse HEAD~$p) = $(git rev-parse original-no-ff-branch~$p) &&
836 git diff HEAD~$p original-no-ff-branch~$p > out &&
837 test_must_be_empty out
839 test $(git rev-parse HEAD~3) = $(git rev-parse original-no-ff-branch~3) &&
840 git diff HEAD~3 original-no-ff-branch~3 > out &&
841 test_must_be_empty out
844 test_expect_success
'set up commits with funny messages' '
845 git checkout -b funny A &&
848 git commit -a -m "end with slash\\" &&
851 git commit -a -m "something (\000) that looks like octal" &&
854 git commit -a -m "something (\n) that looks like a newline" &&
857 git commit -a -m "another commit"
860 test_expect_success
'rebase-i history with funny messages' '
861 git rev-list A..funny >expect &&
864 FAKE_LINES="1 2 3 4" git rebase -i A &&
865 git rev-list A.. >actual &&
866 test_cmp expect actual
869 test_expect_success
'prepare for rebase -i --exec' '
870 git checkout master &&
871 git checkout -b execute &&
872 test_commit one_exec main.txt one_exec &&
873 test_commit two_exec main.txt two_exec &&
874 test_commit three_exec main.txt three_exec
877 test_expect_success
'running "git rebase -i --exec git show HEAD"' '
879 git rebase -i --exec "git show HEAD" HEAD~2 >actual &&
881 FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD" &&
883 git rebase -i HEAD~2 >expect
885 sed -e "1,9d" expect >expected &&
886 test_cmp expected actual
889 test_expect_success
'running "git rebase --exec git show HEAD -i"' '
890 git reset --hard execute &&
892 git rebase --exec "git show HEAD" -i HEAD~2 >actual &&
894 FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD" &&
896 git rebase -i HEAD~2 >expect
898 sed -e "1,9d" expect >expected &&
899 test_cmp expected actual
902 test_expect_success
'running "git rebase -ix git show HEAD"' '
903 git reset --hard execute &&
905 git rebase -ix "git show HEAD" HEAD~2 >actual &&
907 FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD" &&
909 git rebase -i HEAD~2 >expect
911 sed -e "1,9d" expect >expected &&
912 test_cmp expected actual
916 test_expect_success
'rebase -ix with several <CMD>' '
917 git reset --hard execute &&
919 git rebase -ix "git show HEAD; pwd" HEAD~2 >actual &&
921 FAKE_LINES="1 exec_git_show_HEAD;_pwd 2 exec_git_show_HEAD;_pwd" &&
923 git rebase -i HEAD~2 >expect
925 sed -e "1,9d" expect >expected &&
926 test_cmp expected actual
929 test_expect_success
'rebase -ix with several instances of --exec' '
930 git reset --hard execute &&
932 git rebase -i --exec "git show HEAD" --exec "pwd" HEAD~2 >actual &&
934 FAKE_LINES="1 exec_git_show_HEAD exec_pwd 2
935 exec_git_show_HEAD exec_pwd" &&
937 git rebase -i HEAD~2 >expect
939 sed -e "1,11d" expect >expected &&
940 test_cmp expected actual
943 test_expect_success C_LOCALE_OUTPUT
'rebase -ix with --autosquash' '
944 git reset --hard execute &&
945 git checkout -b autosquash &&
946 echo second >second.txt &&
947 git add second.txt &&
948 git commit -m "fixup! two_exec" &&
951 git commit -m "fixup! two_exec" &&
954 git checkout -b autosquash_actual &&
955 git rebase -i --exec "git show HEAD" --autosquash HEAD~4 >actual
957 git checkout autosquash &&
959 git checkout -b autosquash_expected &&
960 FAKE_LINES="1 fixup 3 fixup 4 exec_git_show_HEAD 2 exec_git_show_HEAD" &&
962 git rebase -i HEAD~4 >expect
964 sed -e "1,13d" expect >expected &&
965 test_cmp expected actual
968 test_expect_success
'rebase --exec works without -i ' '
969 git reset --hard execute &&
970 rm -rf exec_output &&
971 EDITOR="echo >invoked_editor" git rebase --exec "echo a line >>exec_output" HEAD~2 2>actual &&
972 test_i18ngrep "Successfully rebased and updated" actual &&
973 test_line_count = 2 exec_output &&
974 test_path_is_missing invoked_editor
977 test_expect_success
'rebase -i --exec without <CMD>' '
978 git reset --hard execute &&
980 test_must_fail git rebase -i --exec 2>actual &&
981 test_i18ngrep "requires a value" actual &&
985 test_expect_success
'rebase -i --root re-order and drop commits' '
988 FAKE_LINES="3 1 2 5" git rebase -i --root &&
989 test E = $(git cat-file commit HEAD | sed -ne \$p) &&
990 test B = $(git cat-file commit HEAD^ | sed -ne \$p) &&
991 test A = $(git cat-file commit HEAD^^ | sed -ne \$p) &&
992 test C = $(git cat-file commit HEAD^^^ | sed -ne \$p) &&
993 test 0 = $(git cat-file commit HEAD^^^ | grep -c ^parent\ )
996 test_expect_success
'rebase -i --root retain root commit author and message' '
1000 GIT_AUTHOR_NAME="Twerp Snog" git commit -m "different author" &&
1002 FAKE_LINES="2" git rebase -i --root &&
1003 git cat-file commit HEAD | grep -q "^author Twerp Snog" &&
1004 git cat-file commit HEAD | grep -q "^different author$"
1007 test_expect_success
'rebase -i --root temporary sentinel commit' '
1010 test_must_fail env FAKE_LINES="2" git rebase -i --root &&
1011 git cat-file commit HEAD | grep "^tree 4b825dc642cb" &&
1015 test_expect_success
'rebase -i --root fixup root commit' '
1018 FAKE_LINES="1 fixup 2" git rebase -i --root &&
1019 test A = $(git cat-file commit HEAD | sed -ne \$p) &&
1020 test B = $(git show HEAD:file1) &&
1021 test 0 = $(git cat-file commit HEAD | grep -c ^parent\ )
1024 test_expect_success
'rebase -i --root reword root commit' '
1025 test_when_finished "test_might_fail git rebase --abort" &&
1026 git checkout -b reword-root-branch master &&
1028 FAKE_LINES="reword 1 2" FAKE_COMMIT_MESSAGE="A changed" \
1029 git rebase -i --root &&
1030 git show HEAD^ | grep "A changed" &&
1031 test -z "$(git show -s --format=%p HEAD^)"
1034 test_expect_success
'rebase -i --root when root has untracked file confilct' '
1035 test_when_finished "reset_rebase" &&
1036 git checkout -b failing-root-pick A &&
1039 git commit -m "remove file 1 add file 2" &&
1042 test_must_fail env FAKE_LINES="1 2" git rebase -i --root &&
1044 git rebase --continue &&
1045 test "$(git log -1 --format=%B)" = "remove file 1 add file 2" &&
1046 test "$(git rev-list --count HEAD)" = 2
1049 test_expect_success
'rebase -i --root reword root when root has untracked file conflict' '
1050 test_when_finished "reset_rebase" &&
1053 test_must_fail env FAKE_LINES="reword 1 2" \
1054 FAKE_COMMIT_MESSAGE="Modified A" git rebase -i --root &&
1056 FAKE_COMMIT_MESSAGE="Reworded A" git rebase --continue &&
1057 test "$(git log -1 --format=%B HEAD^)" = "Reworded A" &&
1058 test "$(git rev-list --count HEAD)" = 2
1061 test_expect_success C_LOCALE_OUTPUT
'rebase --edit-todo does not work on non-interactive rebase' '
1062 git checkout reword-root-branch &&
1064 git checkout conflict-branch &&
1066 test_must_fail git rebase --onto HEAD~2 HEAD~ &&
1067 test_must_fail git rebase --edit-todo &&
1071 test_expect_success
'rebase --edit-todo can be used to modify todo' '
1073 git checkout no-conflict-branch^0 &&
1075 FAKE_LINES="edit 1 2 3" git rebase -i HEAD~3 &&
1076 FAKE_LINES="2 1" git rebase --edit-todo &&
1077 git rebase --continue &&
1078 test M = $(git cat-file commit HEAD^ | sed -ne \$p) &&
1079 test L = $(git cat-file commit HEAD | sed -ne \$p)
1082 test_expect_success
'rebase -i produces readable reflog' '
1084 git branch -f branch-reflog-test H &&
1086 git rebase -i --onto I F branch-reflog-test &&
1087 cat >expect <<-\EOF &&
1088 rebase -i (finish): returning to refs/heads/branch-reflog-test
1091 rebase -i (start): checkout I
1093 git reflog -n4 HEAD |
1094 sed "s/[^:]*: //" >actual &&
1095 test_cmp expect actual
1098 test_expect_success
'rebase -i respects core.commentchar' '
1101 test_config core.commentchar "\\" &&
1102 write_script remove-all-but-first.sh <<-\EOF &&
1103 sed -e "2,\$s/^/\\\\/" "$1" >"$1.tmp" &&
1106 test_set_editor "$(pwd)/remove-all-but-first.sh" &&
1108 test B = $(git cat-file commit HEAD^ | sed -ne \$p)
1111 test_expect_success
'rebase -i respects core.commentchar=auto' '
1112 test_config core.commentchar auto &&
1113 write_script copy-edit-script.sh <<-\EOF &&
1116 test_set_editor "$(pwd)/copy-edit-script.sh" &&
1117 test_when_finished "git rebase --abort || :" &&
1118 git rebase -i HEAD^ &&
1119 test -z "$(grep -ve "^#" -e "^\$" -e "^pick" edit-script)"
1122 test_expect_success
'rebase -i, with <onto> and <upstream> specified as :/quuxery' '
1123 test_when_finished "git branch -D torebase" &&
1124 git checkout -b torebase branch1 &&
1125 upstream=$(git rev-parse ":/J") &&
1126 onto=$(git rev-parse ":/A") &&
1127 git rebase --onto $onto $upstream &&
1128 git reset --hard branch1 &&
1129 git rebase --onto ":/A" ":/J" &&
1130 git checkout branch1
1133 test_expect_success
'rebase -i with --strategy and -X' '
1134 git checkout -b conflict-merge-use-theirs conflict-branch &&
1135 git reset --hard HEAD^ &&
1136 echo five >conflict &&
1138 git commit -a -m "one file conflict" &&
1139 EDITOR=true git rebase -i --strategy=recursive -Xours conflict-branch &&
1140 test $(git show conflict-branch:conflict) = $(cat conflict) &&
1141 test $(cat file1) = Z
1144 test_expect_success
'interrupted rebase -i with --strategy and -X' '
1145 git checkout -b conflict-merge-use-theirs-interrupted conflict-branch &&
1146 git reset --hard HEAD^ &&
1148 git add breakpoint &&
1149 git commit -m "breakpoint for interactive mode" &&
1150 echo five >conflict &&
1152 git commit -a -m "one file conflict" &&
1154 FAKE_LINES="edit 1 2" git rebase -i --strategy=recursive -Xours conflict-branch &&
1155 git rebase --continue &&
1156 test $(git show conflict-branch:conflict) = $(cat conflict) &&
1157 test $(cat file1) = Z
1160 test_expect_success
'rebase -i error on commits with \ in message' '
1161 current_head=$(git rev-parse HEAD) &&
1162 test_when_finished "git rebase --abort; git reset --hard $current_head; rm -f error" &&
1163 test_commit TO-REMOVE will-conflict old-content &&
1164 test_commit "\temp" will-conflict new-content dummy &&
1165 test_must_fail env EDITOR=true git rebase -i HEAD^ --onto HEAD^^ 2>error &&
1166 test_expect_code 1 grep " emp" error
1169 test_expect_success
'short SHA-1 setup' '
1170 test_when_finished "git checkout master" &&
1171 git checkout --orphan collide &&
1175 test_commit collide1 collide &&
1176 test_commit --notick collide2 collide &&
1177 test_commit --notick collide3 collide
1181 test_expect_success
'short SHA-1 collide' '
1182 test_when_finished "reset_rebase && git checkout master" &&
1183 git checkout collide &&
1188 FAKE_COMMIT_MESSAGE="collide2 ac4f2ee" \
1189 FAKE_LINES="reword 1 2" git rebase -i HEAD~2
1193 test_expect_success
'respect core.abbrev' '
1194 git config core.abbrev 12 &&
1195 set_cat_todo_editor &&
1196 test_must_fail git rebase -i HEAD~4 >todo-list &&
1197 test 4 = $(grep -c "pick [0-9a-f]\{12,\}" todo-list)
1200 test_expect_success
'todo count' '
1201 write_script dump-raw.sh <<-\EOF &&
1204 test_set_editor "$(pwd)/dump-raw.sh" &&
1205 git rebase -i HEAD~4 >actual &&
1206 test_i18ngrep "^# Rebase ..* onto ..* ([0-9]" actual
1209 test_expect_success
'rebase -i commits that overwrite untracked files (pick)' '
1210 git checkout --force branch2 &&
1213 FAKE_LINES="edit 1 2" git rebase -i A &&
1214 test_cmp_rev HEAD F &&
1215 test_path_is_missing file6 &&
1217 test_must_fail git rebase --continue &&
1218 test_cmp_rev HEAD F &&
1220 git rebase --continue &&
1224 test_expect_success
'rebase -i commits that overwrite untracked files (squash)' '
1225 git checkout --force branch2 &&
1227 git tag original-branch2 &&
1229 FAKE_LINES="edit 1 squash 2" git rebase -i A &&
1230 test_cmp_rev HEAD F &&
1231 test_path_is_missing file6 &&
1233 test_must_fail git rebase --continue &&
1234 test_cmp_rev HEAD F &&
1236 git rebase --continue &&
1237 test $(git cat-file commit HEAD | sed -ne \$p) = I &&
1238 git reset --hard original-branch2
1241 test_expect_success
'rebase -i commits that overwrite untracked files (no ff)' '
1242 git checkout --force branch2 &&
1245 FAKE_LINES="edit 1 2" git rebase -i --no-ff A &&
1246 test $(git cat-file commit HEAD | sed -ne \$p) = F &&
1247 test_path_is_missing file6 &&
1249 test_must_fail git rebase --continue &&
1250 test $(git cat-file commit HEAD | sed -ne \$p) = F &&
1252 git rebase --continue &&
1253 test $(git cat-file commit HEAD | sed -ne \$p) = I
1256 test_expect_success
'rebase --continue removes CHERRY_PICK_HEAD' '
1257 git checkout -b commit-to-skip &&
1260 test_seq 5 | sed "s/$double/&&/" >seq &&
1263 git commit -m seq-$double
1266 git reset --hard HEAD~2 &&
1267 git cherry-pick seq-onto &&
1269 test_must_fail env FAKE_LINES= git rebase -i seq-onto &&
1270 test -d .git/rebase-merge &&
1271 git rebase --continue &&
1272 git diff --exit-code seq-onto &&
1273 test ! -d .git/rebase-merge &&
1274 test ! -f .git/CHERRY_PICK_HEAD
1277 rebase_setup_and_clean
() {
1278 test_when_finished
"
1279 git checkout master &&
1280 test_might_fail git branch -D $1 &&
1281 test_might_fail git rebase --abort
1283 git checkout
-b $1 ${2:-master}
1286 test_expect_success
'drop' '
1287 rebase_setup_and_clean drop-test &&
1289 FAKE_LINES="1 drop 2 3 d 4 5" git rebase -i --root &&
1290 test E = $(git cat-file commit HEAD | sed -ne \$p) &&
1291 test C = $(git cat-file commit HEAD^ | sed -ne \$p) &&
1292 test A = $(git cat-file commit HEAD^^ | sed -ne \$p)
1295 test_expect_success
'rebase -i respects rebase.missingCommitsCheck = ignore' '
1296 test_config rebase.missingCommitsCheck ignore &&
1297 rebase_setup_and_clean missing-commit &&
1299 FAKE_LINES="1 2 3 4" \
1300 git rebase -i --root 2>actual &&
1301 test D = $(git cat-file commit HEAD | sed -ne \$p) &&
1303 "Successfully rebased and updated refs/heads/missing-commit" \
1308 Warning: some commits may have been dropped accidentally.
1309 Dropped commits (newer to older):
1310 - $(git rev-list --pretty=oneline --abbrev-commit -1 master)
1311 To avoid this message, use "drop" to explicitly remove a commit.
1313 Use 'git config rebase.missingCommitsCheck' to change the level of warnings.
1314 The possible behaviours are: ignore, warn, error.
1320 Successfully rebased and updated refs/heads/missing-commit.
1327 test_expect_success
'rebase -i respects rebase.missingCommitsCheck = warn' '
1328 test_config rebase.missingCommitsCheck warn &&
1329 rebase_setup_and_clean missing-commit &&
1331 FAKE_LINES="1 2 3 4" \
1332 git rebase -i --root 2>actual.2 &&
1333 cr_to_nl <actual.2 >actual &&
1334 test_i18ncmp expect actual &&
1335 test D = $(git cat-file commit HEAD | sed -ne \$p)
1339 Warning: some commits may have been dropped accidentally.
1340 Dropped commits (newer to older):
1341 - $(git rev-list --pretty=oneline --abbrev-commit -1 master)
1342 - $(git rev-list --pretty=oneline --abbrev-commit -1 master~2)
1343 To avoid this message, use "drop" to explicitly remove a commit.
1345 Use 'git config rebase.missingCommitsCheck' to change the level of warnings.
1346 The possible behaviours are: ignore, warn, error.
1348 You can fix this with 'git rebase --edit-todo' and then run 'git rebase --continue'.
1349 Or you can abort the rebase with 'git rebase --abort'.
1352 test_expect_success
'rebase -i respects rebase.missingCommitsCheck = error' '
1353 test_config rebase.missingCommitsCheck error &&
1354 rebase_setup_and_clean missing-commit &&
1356 test_must_fail env FAKE_LINES="1 2 4" \
1357 git rebase -i --root 2>actual &&
1358 test_i18ncmp expect actual &&
1359 cp .git/rebase-merge/git-rebase-todo.backup \
1360 .git/rebase-merge/git-rebase-todo &&
1361 FAKE_LINES="1 2 drop 3 4 drop 5" \
1362 git rebase --edit-todo &&
1363 git rebase --continue &&
1364 test D = $(git cat-file commit HEAD | sed -ne \$p) &&
1365 test B = $(git cat-file commit HEAD^ | sed -ne \$p)
1368 test_expect_success
'respects rebase.abbreviateCommands with fixup, squash and exec' '
1369 rebase_setup_and_clean abbrevcmd &&
1370 test_commit "first" file1.txt "first line" first &&
1371 test_commit "second" file1.txt "another line" second &&
1372 test_commit "fixup! first" file2.txt "first line again" first_fixup &&
1373 test_commit "squash! second" file1.txt "another line here" second_squash &&
1374 cat >expected <<-EOF &&
1375 p $(git rev-list --abbrev-commit -1 first) first
1376 f $(git rev-list --abbrev-commit -1 first_fixup) fixup! first
1378 p $(git rev-list --abbrev-commit -1 second) second
1379 s $(git rev-list --abbrev-commit -1 second_squash) squash! second
1382 git checkout abbrevcmd &&
1383 set_cat_todo_editor &&
1384 test_config rebase.abbreviateCommands true &&
1385 test_must_fail git rebase -i --exec "git show HEAD" \
1386 --autosquash master >actual &&
1387 test_cmp expected actual
1390 test_expect_success
'static check of bad command' '
1391 rebase_setup_and_clean bad-cmd &&
1393 test_must_fail env FAKE_LINES="1 2 3 bad 4 5" \
1394 git rebase -i --root 2>actual &&
1395 test_i18ngrep "badcmd $(git rev-list --oneline -1 master~1)" actual &&
1396 test_i18ngrep "You can fix this with .git rebase --edit-todo.." actual &&
1397 FAKE_LINES="1 2 3 drop 4 5" git rebase --edit-todo &&
1398 git rebase --continue &&
1399 test E = $(git cat-file commit HEAD | sed -ne \$p) &&
1400 test C = $(git cat-file commit HEAD^ | sed -ne \$p)
1403 test_expect_success
'tabs and spaces are accepted in the todolist' '
1404 rebase_setup_and_clean indented-comment &&
1405 write_script add-indent.sh <<-\EOF &&
1407 # Turn single spaces into space/tab mix
1408 sed "1s/ / /g; 2s/ / /g; 3s/ / /g" "$1"
1409 printf "\n\t# comment\n #more\n\t # comment\n"
1413 test_set_editor "$(pwd)/add-indent.sh" &&
1414 git rebase -i HEAD^^^ &&
1415 test E = $(git cat-file commit HEAD | sed -ne \$p)
1418 test_expect_success
'static check of bad SHA-1' '
1419 rebase_setup_and_clean bad-sha &&
1421 test_must_fail env FAKE_LINES="1 2 edit fakesha 3 4 5 #" \
1422 git rebase -i --root 2>actual &&
1423 test_i18ngrep "edit XXXXXXX False commit" actual &&
1424 test_i18ngrep "You can fix this with .git rebase --edit-todo.." actual &&
1425 FAKE_LINES="1 2 4 5 6" git rebase --edit-todo &&
1426 git rebase --continue &&
1427 test E = $(git cat-file commit HEAD | sed -ne \$p)
1430 test_expect_success
'editor saves as CR/LF' '
1431 git checkout -b with-crlf &&
1432 write_script add-crs.sh <<-\EOF &&
1433 sed -e "s/\$/Q/" <"$1" | tr Q "\\015" >"$1".new &&
1437 test_set_editor "$(pwd)/add-crs.sh" &&
1443 test_expect_success
'rebase -i --gpg-sign=<key-id>' '
1444 test_when_finished "test_might_fail git rebase --abort" &&
1446 FAKE_LINES="edit 1" git rebase -i --gpg-sign="\"S I Gner\"" HEAD^ \
1448 test_i18ngrep "$SQ-S\"S I Gner\"$SQ" err
1451 test_expect_success
'rebase -i --gpg-sign=<key-id> overrides commit.gpgSign' '
1452 test_when_finished "test_might_fail git rebase --abort" &&
1453 test_config commit.gpgsign true &&
1455 FAKE_LINES="edit 1" git rebase -i --gpg-sign="\"S I Gner\"" HEAD^ \
1457 test_i18ngrep "$SQ-S\"S I Gner\"$SQ" err
1460 test_expect_success
'valid author header after --root swap' '
1461 rebase_setup_and_clean author-header no-conflict-branch &&
1463 git commit --amend --author="Au ${SQ}thor <author@example.com>" --no-edit &&
1464 git cat-file commit HEAD | grep ^author >expected &&
1465 FAKE_LINES="5 1" git rebase -i --root &&
1466 git cat-file commit HEAD^ | grep ^author >actual &&
1467 test_cmp expected actual
1470 test_expect_success
'valid author header when author contains single quote' '
1471 rebase_setup_and_clean author-header no-conflict-branch &&
1473 git commit --amend --author="Au ${SQ}thor <author@example.com>" --no-edit &&
1474 git cat-file commit HEAD | grep ^author >expected &&
1475 FAKE_LINES="2" git rebase -i HEAD~2 &&
1476 git cat-file commit HEAD | grep ^author >actual &&
1477 test_cmp expected actual