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 git rebase -x "" @ 2>actual &&
153 test_write_lines "error: empty exec command" >expected &&
154 test_i18ncmp expected actual &&
155 test_must_fail 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 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 'no changes are a nop' '
179 git checkout branch2 &&
182 test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch2" &&
183 test $(git rev-parse I) = $(git rev-parse HEAD)
186 test_expect_success 'test the [branch] option' '
187 git checkout -b dead-end &&
189 git commit -m "stop here" &&
191 git rebase -i F branch2 &&
192 test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch2" &&
193 test $(git rev-parse I) = $(git rev-parse branch2) &&
194 test $(git rev-parse I) = $(git rev-parse HEAD)
197 test_expect_success 'test --onto <branch>' '
198 git checkout -b test-onto branch2 &&
200 git rebase -i --onto branch1 F &&
201 test "$(git symbolic-ref -q HEAD)" = "refs/heads/test-onto" &&
202 test $(git rev-parse HEAD^) = $(git rev-parse branch1) &&
203 test $(git rev-parse I) = $(git rev-parse branch2)
206 test_expect_success 'rebase on top of a non-conflicting commit' '
207 git checkout branch1 &&
208 git tag original-branch1 &&
210 git rebase -i branch2 &&
211 test file6 = $(git diff --name-only original-branch1) &&
212 test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch1" &&
213 test $(git rev-parse I) = $(git rev-parse branch2) &&
214 test $(git rev-parse I) = $(git rev-parse HEAD~2)
217 test_expect_success 'reflog for the branch shows state before rebase' '
218 test $(git rev-parse branch1@{1}) = $(git rev-parse original-branch1)
221 test_expect_success 'reflog for the branch shows correct finish message' '
222 printf "rebase -i (finish): refs/heads/branch1 onto %s\n" \
223 "$(git rev-parse branch2)" >expected &&
224 git log -g --pretty=%gs -1 refs/heads/branch1 >actual &&
225 test_cmp expected actual
228 test_expect_success 'exchange two commits' '
230 FAKE_LINES="2 1" git rebase -i HEAD~2 &&
231 test H = $(git cat-file commit HEAD^ | sed -ne \$p) &&
232 test G = $(git cat-file commit HEAD | sed -ne \$p)
236 diff --git a/file1 b/file1
237 index f70f10e..fd79235 100644
253 test_expect_success 'stop on conflicting pick' '
254 git tag new-branch1 &&
256 test_must_fail git rebase -i master &&
257 test "$(git rev-parse HEAD~3)" = "$(git rev-parse master)" &&
258 test_cmp expect .git/rebase-merge/patch &&
259 test_cmp expect2 file1 &&
260 test "$(git diff --name-status |
261 sed -n -e "/^U/s/^U[^a-z]*//p")" = file1 &&
262 test 4 = $(grep -v "^#" < .git/rebase-merge/done | wc -l) &&
263 test 0 = $(grep -c "^[^#]" < .git/rebase-merge/git-rebase-todo)
266 test_expect_success 'show conflicted patch' '
267 GIT_TRACE=1 git rebase --show-current-patch >/dev/null 2>stderr &&
268 grep "show.*REBASE_HEAD" stderr &&
269 # the original stopped-sha1 is abbreviated
270 stopped_sha1="$(git rev-parse $(cat ".git/rebase-merge/stopped-sha"))" &&
271 test "$(git rev-parse REBASE_HEAD)" = "$stopped_sha1"
274 test_expect_success 'abort' '
275 git rebase --abort &&
276 test $(git rev-parse new-branch1) = $(git rev-parse HEAD) &&
277 test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch1" &&
278 test_path_is_missing .git/rebase-merge
281 test_expect_success 'abort with error when new base cannot be checked out' '
282 git rm --cached file1 &&
283 git commit -m "remove file in base" &&
285 test_must_fail git rebase -i master > output 2>&1 &&
286 test_i18ngrep "The following untracked working tree files would be overwritten by checkout:" \
288 test_i18ngrep "file1" output &&
289 test_path_is_missing .git/rebase-merge &&
290 git reset --hard HEAD^
293 test_expect_success 'retain authorship' '
297 GIT_AUTHOR_NAME="Twerp Snog" git commit -m "different author" &&
300 git rebase -i --onto master HEAD^ &&
301 git show HEAD | grep "^Author: Twerp Snog"
304 test_expect_success 'retain authorship w/ conflicts' '
305 oGIT_AUTHOR_NAME=$GIT_AUTHOR_NAME &&
306 test_when_finished "GIT_AUTHOR_NAME=\$oGIT_AUTHOR_NAME" &&
308 git reset --hard twerp &&
309 test_commit a conflict a conflict-a &&
310 git reset --hard twerp &&
312 GIT_AUTHOR_NAME=AttributeMe &&
313 export GIT_AUTHOR_NAME &&
314 test_commit b conflict b conflict-b &&
315 GIT_AUTHOR_NAME=$oGIT_AUTHOR_NAME &&
318 test_must_fail git rebase -i conflict-a &&
319 echo resolved >conflict &&
321 git rebase --continue &&
322 test $(git rev-parse conflict-a^0) = $(git rev-parse HEAD^) &&
327 test_expect_success 'squash' '
328 git reset --hard twerp &&
331 GIT_AUTHOR_NAME="Nitfol" git commit -m "nitfol" file7 &&
332 echo "******************************" &&
334 FAKE_LINES="1 squash 2" EXPECT_HEADER_COUNT=2 \
335 git rebase -i --onto master HEAD~2 &&
336 test B = $(cat file7) &&
337 test $(git rev-parse HEAD^) = $(git rev-parse master)
340 test_expect_success 'retain authorship when squashing' '
341 git show HEAD | grep "^Author: Twerp Snog"
344 test_expect_success REBASE_P '-p handles "no changes" gracefully' '
345 HEAD=$(git rev-parse HEAD) &&
347 git rebase -i -p HEAD^ &&
348 git update-index --refresh &&
349 git diff-files --quiet &&
350 git diff-index --quiet --cached HEAD -- &&
351 test $HEAD = $(git rev-parse HEAD)
354 test_expect_failure REBASE_P 'exchange two commits with -p' '
357 FAKE_LINES="2 1" git rebase -i -p HEAD~2 &&
358 test H = $(git cat-file commit HEAD^ | sed -ne \$p) &&
359 test G = $(git cat-file commit HEAD | sed -ne \$p)
362 test_expect_success REBASE_P 'preserve merges with -p' '
363 git checkout -b to-be-preserved master^ &&
364 : > unrelated-file &&
365 git add unrelated-file &&
367 git commit -m "unrelated" &&
368 git checkout -b another-branch master &&
371 git commit -m J file1 &&
373 git merge to-be-preserved &&
376 git commit -m K file1 &&
379 git commit -m L1 file1 &&
380 git checkout HEAD^ &&
381 echo 1 > unrelated-file &&
383 git commit -m L2 unrelated-file &&
385 git merge another-branch &&
388 git commit -m M file1 &&
389 git checkout -b to-be-rebased &&
392 git rebase -i -p --onto branch1 master &&
393 git update-index --refresh &&
394 git diff-files --quiet &&
395 git diff-index --quiet --cached HEAD -- &&
396 test $(git rev-parse HEAD~6) = $(git rev-parse branch1) &&
397 test $(git rev-parse HEAD~4^2) = $(git rev-parse to-be-preserved) &&
398 test $(git rev-parse HEAD^^2^) = $(git rev-parse HEAD^^^) &&
399 test $(git show HEAD~5:file1) = B &&
400 test $(git show HEAD~3:file1) = C &&
401 test $(git show HEAD:file1) = E &&
402 test $(git show HEAD:unrelated-file) = 1
405 test_expect_success REBASE_P 'edit ancestor with -p' '
407 FAKE_LINES="1 2 edit 3 4" git rebase -i -p HEAD~3 &&
408 echo 2 > unrelated-file &&
410 git commit -m L2-modified --amend unrelated-file &&
411 git rebase --continue &&
412 git update-index --refresh &&
413 git diff-files --quiet &&
414 git diff-index --quiet --cached HEAD -- &&
415 test $(git show HEAD:unrelated-file) = 2
418 test_expect_success '--continue tries to commit' '
419 git reset --hard D &&
422 test_must_fail git rebase -i --onto new-branch1 HEAD^ &&
423 echo resolved > file1 &&
425 FAKE_COMMIT_MESSAGE="chouette!" git rebase --continue &&
426 test $(git rev-parse HEAD^) = $(git rev-parse new-branch1) &&
427 git show HEAD | grep chouette
430 test_expect_success 'verbose flag is heeded, even after --continue' '
431 git reset --hard master@{1} &&
434 test_must_fail git rebase -v -i --onto new-branch1 HEAD^ &&
435 echo resolved > file1 &&
437 git rebase --continue > output &&
438 grep "^ file1 | 2 +-$" output
441 test_expect_success C_LOCALE_OUTPUT 'multi-squash only fires up editor once' '
442 base=$(git rev-parse HEAD~4) &&
444 FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="1 squash 2 squash 3 squash 4" \
445 EXPECT_HEADER_COUNT=4 \
446 git rebase -i $base &&
447 test $base = $(git rev-parse HEAD^) &&
448 test 1 = $(git show | grep ONCE | wc -l)
451 test_expect_success C_LOCALE_OUTPUT 'multi-fixup does not fire up editor' '
452 git checkout -b multi-fixup E &&
453 base=$(git rev-parse HEAD~4) &&
455 FAKE_COMMIT_AMEND="NEVER" FAKE_LINES="1 fixup 2 fixup 3 fixup 4" \
456 git rebase -i $base &&
457 test $base = $(git rev-parse HEAD^) &&
458 test 0 = $(git show | grep NEVER | wc -l) &&
459 git checkout @{-1} &&
460 git branch -D multi-fixup
463 test_expect_success 'commit message used after conflict' '
464 git checkout -b conflict-fixup conflict-branch &&
465 base=$(git rev-parse HEAD~4) &&
467 test_must_fail env FAKE_LINES="1 fixup 3 fixup 4" git rebase -i $base &&
468 echo three > conflict &&
470 FAKE_COMMIT_AMEND="ONCE" EXPECT_HEADER_COUNT=2 \
471 git rebase --continue &&
472 test $base = $(git rev-parse HEAD^) &&
473 test 1 = $(git show | grep ONCE | wc -l) &&
474 git checkout @{-1} &&
475 git branch -D conflict-fixup
478 test_expect_success 'commit message retained after conflict' '
479 git checkout -b conflict-squash conflict-branch &&
480 base=$(git rev-parse HEAD~4) &&
482 test_must_fail env FAKE_LINES="1 fixup 3 squash 4" git rebase -i $base &&
483 echo three > conflict &&
485 FAKE_COMMIT_AMEND="TWICE" EXPECT_HEADER_COUNT=2 \
486 git rebase --continue &&
487 test $base = $(git rev-parse HEAD^) &&
488 test 2 = $(git show | grep TWICE | wc -l) &&
489 git checkout @{-1} &&
490 git branch -D conflict-squash
493 cat > expect-squash-fixup << EOF
501 test_expect_success C_LOCALE_OUTPUT 'squash and fixup generate correct log messages' '
502 git checkout -b squash-fixup E &&
503 base=$(git rev-parse HEAD~4) &&
505 FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="1 fixup 2 squash 3 fixup 4" \
506 EXPECT_HEADER_COUNT=4 \
507 git rebase -i $base &&
508 git cat-file commit HEAD | sed -e 1,/^\$/d > actual-squash-fixup &&
509 test_cmp expect-squash-fixup actual-squash-fixup &&
510 git cat-file commit HEAD@{2} |
511 grep "^# This is a combination of 3 commits\." &&
512 git cat-file commit HEAD@{3} |
513 grep "^# This is a combination of 2 commits\." &&
514 git checkout @{-1} &&
515 git branch -D squash-fixup
518 test_expect_success C_LOCALE_OUTPUT 'squash ignores comments' '
519 git checkout -b skip-comments E &&
520 base=$(git rev-parse HEAD~4) &&
522 FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="# 1 # squash 2 # squash 3 # squash 4 #" \
523 EXPECT_HEADER_COUNT=4 \
524 git rebase -i $base &&
525 test $base = $(git rev-parse HEAD^) &&
526 test 1 = $(git show | grep ONCE | wc -l) &&
527 git checkout @{-1} &&
528 git branch -D skip-comments
531 test_expect_success C_LOCALE_OUTPUT 'squash ignores blank lines' '
532 git checkout -b skip-blank-lines E &&
533 base=$(git rev-parse HEAD~4) &&
535 FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="> 1 > squash 2 > squash 3 > squash 4 >" \
536 EXPECT_HEADER_COUNT=4 \
537 git rebase -i $base &&
538 test $base = $(git rev-parse HEAD^) &&
539 test 1 = $(git show | grep ONCE | wc -l) &&
540 git checkout @{-1} &&
541 git branch -D skip-blank-lines
544 test_expect_success 'squash works as expected' '
545 git checkout -b squash-works no-conflict-branch &&
546 one=$(git rev-parse HEAD~3) &&
548 FAKE_LINES="1 s 3 2" EXPECT_HEADER_COUNT=2 \
549 git rebase -i HEAD~3 &&
550 test $one = $(git rev-parse HEAD~2)
553 test_expect_success 'interrupted squash works as expected' '
554 git checkout -b interrupted-squash conflict-branch &&
555 one=$(git rev-parse HEAD~3) &&
557 test_must_fail env FAKE_LINES="1 squash 3 2" git rebase -i HEAD~3 &&
558 test_write_lines one two four > conflict &&
560 test_must_fail git rebase --continue &&
561 echo resolved > conflict &&
563 git rebase --continue &&
564 test $one = $(git rev-parse HEAD~2)
567 test_expect_success 'interrupted squash works as expected (case 2)' '
568 git checkout -b interrupted-squash2 conflict-branch &&
569 one=$(git rev-parse HEAD~3) &&
571 test_must_fail env FAKE_LINES="3 squash 1 2" git rebase -i HEAD~3 &&
572 test_write_lines one four > conflict &&
574 test_must_fail git rebase --continue &&
575 test_write_lines one two four > conflict &&
577 test_must_fail git rebase --continue &&
578 echo resolved > conflict &&
580 git rebase --continue &&
581 test $one = $(git rev-parse HEAD~2)
584 test_expect_success '--continue tries to commit, even for "edit"' '
585 echo unrelated > file7 &&
588 git commit -m "unrelated change" &&
589 parent=$(git rev-parse HEAD^) &&
592 FAKE_LINES="edit 1" git rebase -i HEAD^ &&
593 echo edited > file7 &&
595 FAKE_COMMIT_MESSAGE="chouette!" git rebase --continue &&
596 test edited = $(git show HEAD:file7) &&
597 git show HEAD | grep chouette &&
598 test $parent = $(git rev-parse HEAD^)
601 test_expect_success 'aborted --continue does not squash commits after "edit"' '
602 old=$(git rev-parse HEAD) &&
605 FAKE_LINES="edit 1" git rebase -i HEAD^ &&
606 echo "edited again" > file7 &&
608 test_must_fail env FAKE_COMMIT_MESSAGE=" " git rebase --continue &&
609 test $old = $(git rev-parse HEAD) &&
613 test_expect_success 'auto-amend only edited commits after "edit"' '
616 FAKE_LINES="edit 1" git rebase -i HEAD^ &&
617 echo "edited again" > file7 &&
619 FAKE_COMMIT_MESSAGE="edited file7 again" git commit &&
620 echo "and again" > file7 &&
623 test_must_fail env FAKE_COMMIT_MESSAGE="and again" git rebase --continue &&
627 test_expect_success 'clean error after failed "exec"' '
629 test_when_finished "git rebase --abort || :" &&
631 test_must_fail env FAKE_LINES="1 exec_false" git rebase -i HEAD^ &&
632 echo "edited again" > file7 &&
634 test_must_fail git rebase --continue 2>error &&
635 test_i18ngrep "you have staged changes in your working tree" error
638 test_expect_success 'rebase a detached HEAD' '
639 grandparent=$(git rev-parse HEAD~2) &&
640 git checkout $(git rev-parse HEAD) &&
643 FAKE_LINES="2 1" git rebase -i HEAD~2 &&
644 test $grandparent = $(git rev-parse HEAD~2)
647 test_expect_success 'rebase a commit violating pre-commit' '
649 mkdir -p .git/hooks &&
650 write_script .git/hooks/pre-commit <<-\EOF &&
651 test -z "$(git diff --cached --check)"
653 echo "monde! " >> file1 &&
655 test_must_fail git commit -m doesnt-verify file1 &&
656 git commit -m doesnt-verify --no-verify file1 &&
659 FAKE_LINES=2 git rebase -i HEAD~2
663 test_expect_success 'rebase with a file named HEAD in worktree' '
667 git checkout -b branch3 A &&
670 GIT_AUTHOR_NAME="Squashed Away" &&
671 export GIT_AUTHOR_NAME &&
674 git commit -m "Add head" &&
677 git commit -m "Add body"
681 FAKE_LINES="1 squash 2" git rebase -i @{-1} &&
682 test "$(git show -s --pretty=format:%an)" = "Squashed Away"
686 test_expect_success 'do "noop" when there is nothing to cherry-pick' '
688 git checkout -b branch4 HEAD &&
689 GIT_EDITOR=: git commit --amend \
690 --author="Somebody else <somebody@else.com>" &&
691 test $(git rev-parse branch3) != $(git rev-parse branch4) &&
693 git rebase -i branch3 &&
694 test $(git rev-parse branch3) = $(git rev-parse branch4)
698 test_expect_success 'submodule rebase setup' '
702 cd sub && git init && >elif &&
703 git add elif && git commit -m "submodule initial"
708 git commit -m "One" &&
711 git commit -a -m "Two" &&
713 cd sub && echo 3 >elif &&
714 git commit -a -m "submodule second"
718 git commit -a -m "Three changes submodule"
721 test_expect_success 'submodule rebase -i' '
723 FAKE_LINES="1 squash 2 3" git rebase -i A
726 test_expect_success 'submodule conflict setup' '
727 git tag submodule-base &&
728 git checkout HEAD^ &&
730 cd sub && git checkout HEAD^ && echo 4 >elif &&
731 git add elif && git commit -m "submodule conflict"
735 git commit -m "Conflict in submodule" &&
736 git tag submodule-topic
739 test_expect_success 'rebase -i continue with only submodule staged' '
741 test_must_fail git rebase -i submodule-base &&
743 git rebase --continue &&
744 test $(git rev-parse submodule-base) != $(git rev-parse HEAD)
747 test_expect_success 'rebase -i continue with unstaged submodule' '
748 git checkout submodule-topic &&
751 test_must_fail git rebase -i submodule-base &&
753 git rebase --continue &&
754 test $(git rev-parse submodule-base) = $(git rev-parse HEAD)
757 test_expect_success 'avoid unnecessary reset' '
758 git checkout master &&
760 test-tool chmtime =123456789 file3 &&
761 git update-index --refresh &&
762 HEAD=$(git rev-parse HEAD) &&
764 git rebase -i HEAD~4 &&
765 test $HEAD = $(git rev-parse HEAD) &&
766 MTIME=$(test-tool chmtime --get file3) &&
767 test 123456789 = $MTIME
770 test_expect_success 'reword' '
771 git checkout -b reword-branch master &&
773 FAKE_LINES="1 2 3 reword 4" FAKE_COMMIT_MESSAGE="E changed" git rebase -i A &&
774 git show HEAD | grep "E changed" &&
775 test $(git rev-parse master) != $(git rev-parse HEAD) &&
776 test $(git rev-parse master^) = $(git rev-parse HEAD^) &&
777 FAKE_LINES="1 2 reword 3 4" FAKE_COMMIT_MESSAGE="D changed" git rebase -i A &&
778 git show HEAD^ | grep "D changed" &&
779 FAKE_LINES="reword 1 2 3 4" FAKE_COMMIT_MESSAGE="B changed" git rebase -i A &&
780 git show HEAD~3 | grep "B changed" &&
781 FAKE_LINES="1 r 2 pick 3 p 4" FAKE_COMMIT_MESSAGE="C changed" git rebase -i A &&
782 git show HEAD~2 | grep "C changed"
785 test_expect_success 'rebase -i can copy notes' '
786 git config notes.rewrite.rebase true &&
787 git config notes.rewriteRef "refs/notes/*" &&
791 git notes add -m"a note" n3 &&
793 git rebase -i --onto n1 n2 &&
794 test "a note" = "$(git notes show HEAD)"
803 test_expect_success 'rebase -i can copy notes over a fixup' '
804 git reset --hard n3 &&
805 git notes add -m"an earlier note" n2 &&
807 GIT_NOTES_REWRITE_MODE=concatenate FAKE_LINES="1 f 2" git rebase -i n1 &&
808 git notes show > output &&
809 test_cmp expect output
812 test_expect_success 'rebase while detaching HEAD' '
813 git symbolic-ref HEAD &&
814 grandparent=$(git rev-parse HEAD~2) &&
817 FAKE_LINES="2 1" git rebase -i HEAD~2 HEAD^0 &&
818 test $grandparent = $(git rev-parse HEAD~2) &&
819 test_must_fail git symbolic-ref HEAD
822 test_tick # Ensure that the rebased commits get a different timestamp.
823 test_expect_success 'always cherry-pick with --no-ff' '
824 git checkout no-ff-branch &&
825 git tag original-no-ff-branch &&
827 git rebase -i --no-ff A &&
830 test ! $(git rev-parse HEAD~$p) = $(git rev-parse original-no-ff-branch~$p) &&
831 git diff HEAD~$p original-no-ff-branch~$p > out &&
832 test_must_be_empty out
834 test $(git rev-parse HEAD~3) = $(git rev-parse original-no-ff-branch~3) &&
835 git diff HEAD~3 original-no-ff-branch~3 > out &&
836 test_must_be_empty out
839 test_expect_success 'set up commits with funny messages' '
840 git checkout -b funny A &&
843 git commit -a -m "end with slash\\" &&
846 git commit -a -m "something (\000) that looks like octal" &&
849 git commit -a -m "something (\n) that looks like a newline" &&
852 git commit -a -m "another commit"
855 test_expect_success 'rebase-i history with funny messages' '
856 git rev-list A..funny >expect &&
859 FAKE_LINES="1 2 3 4" git rebase -i A &&
860 git rev-list A.. >actual &&
861 test_cmp expect actual
864 test_expect_success 'prepare for rebase -i --exec' '
865 git checkout master &&
866 git checkout -b execute &&
867 test_commit one_exec main.txt one_exec &&
868 test_commit two_exec main.txt two_exec &&
869 test_commit three_exec main.txt three_exec
872 test_expect_success 'running "git rebase -i --exec git show HEAD"' '
874 git rebase -i --exec "git show HEAD" HEAD~2 >actual &&
876 FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD" &&
878 git rebase -i HEAD~2 >expect
880 sed -e "1,9d" expect >expected &&
881 test_cmp expected actual
884 test_expect_success 'running "git rebase --exec git show HEAD -i"' '
885 git reset --hard execute &&
887 git rebase --exec "git show HEAD" -i HEAD~2 >actual &&
889 FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD" &&
891 git rebase -i HEAD~2 >expect
893 sed -e "1,9d" expect >expected &&
894 test_cmp expected actual
897 test_expect_success 'running "git rebase -ix git show HEAD"' '
898 git reset --hard execute &&
900 git rebase -ix "git show HEAD" HEAD~2 >actual &&
902 FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD" &&
904 git rebase -i HEAD~2 >expect
906 sed -e "1,9d" expect >expected &&
907 test_cmp expected actual
911 test_expect_success 'rebase -ix with several <CMD>' '
912 git reset --hard execute &&
914 git rebase -ix "git show HEAD; pwd" HEAD~2 >actual &&
916 FAKE_LINES="1 exec_git_show_HEAD;_pwd 2 exec_git_show_HEAD;_pwd" &&
918 git rebase -i HEAD~2 >expect
920 sed -e "1,9d" expect >expected &&
921 test_cmp expected actual
924 test_expect_success 'rebase -ix with several instances of --exec' '
925 git reset --hard execute &&
927 git rebase -i --exec "git show HEAD" --exec "pwd" HEAD~2 >actual &&
929 FAKE_LINES="1 exec_git_show_HEAD exec_pwd 2
930 exec_git_show_HEAD exec_pwd" &&
932 git rebase -i HEAD~2 >expect
934 sed -e "1,11d" expect >expected &&
935 test_cmp expected actual
938 test_expect_success C_LOCALE_OUTPUT 'rebase -ix with --autosquash' '
939 git reset --hard execute &&
940 git checkout -b autosquash &&
941 echo second >second.txt &&
942 git add second.txt &&
943 git commit -m "fixup! two_exec" &&
946 git commit -m "fixup! two_exec" &&
949 git checkout -b autosquash_actual &&
950 git rebase -i --exec "git show HEAD" --autosquash HEAD~4 >actual
952 git checkout autosquash &&
954 git checkout -b autosquash_expected &&
955 FAKE_LINES="1 fixup 3 fixup 4 exec_git_show_HEAD 2 exec_git_show_HEAD" &&
957 git rebase -i HEAD~4 >expect
959 sed -e "1,13d" expect >expected &&
960 test_cmp expected actual
963 test_expect_success 'rebase --exec works without -i ' '
964 git reset --hard execute &&
965 rm -rf exec_output &&
966 EDITOR="echo >invoked_editor" git rebase --exec "echo a line >>exec_output" HEAD~2 2>actual &&
967 test_i18ngrep "Successfully rebased and updated" actual &&
968 test_line_count = 2 exec_output &&
969 test_path_is_missing invoked_editor
972 test_expect_success 'rebase -i --exec without <CMD>' '
973 git reset --hard execute &&
975 test_must_fail git rebase -i --exec 2>actual &&
976 test_i18ngrep "requires a value" actual &&
980 test_expect_success 'rebase -i --root re-order and drop commits' '
983 FAKE_LINES="3 1 2 5" git rebase -i --root &&
984 test E = $(git cat-file commit HEAD | sed -ne \$p) &&
985 test B = $(git cat-file commit HEAD^ | sed -ne \$p) &&
986 test A = $(git cat-file commit HEAD^^ | sed -ne \$p) &&
987 test C = $(git cat-file commit HEAD^^^ | sed -ne \$p) &&
988 test 0 = $(git cat-file commit HEAD^^^ | grep -c ^parent\ )
991 test_expect_success 'rebase -i --root retain root commit author and message' '
995 GIT_AUTHOR_NAME="Twerp Snog" git commit -m "different author" &&
997 FAKE_LINES="2" git rebase -i --root &&
998 git cat-file commit HEAD | grep -q "^author Twerp Snog" &&
999 git cat-file commit HEAD | grep -q "^different author$"
1002 test_expect_success 'rebase -i --root temporary sentinel commit' '
1005 test_must_fail env FAKE_LINES="2" git rebase -i --root &&
1006 git cat-file commit HEAD | grep "^tree 4b825dc642cb" &&
1010 test_expect_success 'rebase -i --root fixup root commit' '
1013 FAKE_LINES="1 fixup 2" git rebase -i --root &&
1014 test A = $(git cat-file commit HEAD | sed -ne \$p) &&
1015 test B = $(git show HEAD:file1) &&
1016 test 0 = $(git cat-file commit HEAD | grep -c ^parent\ )
1019 test_expect_success 'rebase -i --root reword root commit' '
1020 test_when_finished "test_might_fail git rebase --abort" &&
1021 git checkout -b reword-root-branch master &&
1023 FAKE_LINES="reword 1 2" FAKE_COMMIT_MESSAGE="A changed" \
1024 git rebase -i --root &&
1025 git show HEAD^ | grep "A changed" &&
1026 test -z "$(git show -s --format=%p HEAD^)"
1029 test_expect_success 'rebase -i --root when root has untracked file confilct' '
1030 test_when_finished "reset_rebase" &&
1031 git checkout -b failing-root-pick A &&
1034 git commit -m "remove file 1 add file 2" &&
1037 test_must_fail env FAKE_LINES="1 2" git rebase -i --root &&
1039 git rebase --continue &&
1040 test "$(git log -1 --format=%B)" = "remove file 1 add file 2" &&
1041 test "$(git rev-list --count HEAD)" = 2
1044 test_expect_success 'rebase -i --root reword root when root has untracked file conflict' '
1045 test_when_finished "reset_rebase" &&
1048 test_must_fail env FAKE_LINES="reword 1 2" \
1049 FAKE_COMMIT_MESSAGE="Modified A" git rebase -i --root &&
1051 FAKE_COMMIT_MESSAGE="Reworded A" git rebase --continue &&
1052 test "$(git log -1 --format=%B HEAD^)" = "Reworded A" &&
1053 test "$(git rev-list --count HEAD)" = 2
1056 test_expect_success C_LOCALE_OUTPUT 'rebase --edit-todo does not work on non-interactive rebase' '
1057 git checkout reword-root-branch &&
1059 git checkout conflict-branch &&
1061 test_must_fail git rebase --onto HEAD~2 HEAD~ &&
1062 test_must_fail git rebase --edit-todo &&
1066 test_expect_success 'rebase --edit-todo can be used to modify todo' '
1068 git checkout no-conflict-branch^0 &&
1070 FAKE_LINES="edit 1 2 3" git rebase -i HEAD~3 &&
1071 FAKE_LINES="2 1" git rebase --edit-todo &&
1072 git rebase --continue &&
1073 test M = $(git cat-file commit HEAD^ | sed -ne \$p) &&
1074 test L = $(git cat-file commit HEAD | sed -ne \$p)
1077 test_expect_success 'rebase -i produces readable reflog' '
1079 git branch -f branch-reflog-test H &&
1081 git rebase -i --onto I F branch-reflog-test &&
1082 cat >expect <<-\EOF &&
1083 rebase -i (finish): returning to refs/heads/branch-reflog-test
1086 rebase -i (start): checkout I
1088 git reflog -n4 HEAD |
1089 sed "s/[^:]*: //" >actual &&
1090 test_cmp expect actual
1093 test_expect_success 'rebase -i respects core.commentchar' '
1096 test_config core.commentchar "\\" &&
1097 write_script remove-all-but-first.sh <<-\EOF &&
1098 sed -e "2,\$s/^/\\\\/" "$1" >"$1.tmp" &&
1101 test_set_editor "$(pwd)/remove-all-but-first.sh" &&
1103 test B = $(git cat-file commit HEAD^ | sed -ne \$p)
1106 test_expect_success 'rebase -i respects core.commentchar=auto' '
1107 test_config core.commentchar auto &&
1108 write_script copy-edit-script.sh <<-\EOF &&
1111 test_set_editor "$(pwd)/copy-edit-script.sh" &&
1112 test_when_finished "git rebase --abort || :" &&
1113 git rebase -i HEAD^ &&
1114 test -z "$(grep -ve "^#" -e "^\$" -e "^pick" edit-script)"
1117 test_expect_success 'rebase -i, with <onto> and <upstream> specified as :/quuxery' '
1118 test_when_finished "git branch -D torebase" &&
1119 git checkout -b torebase branch1 &&
1120 upstream=$(git rev-parse ":/J") &&
1121 onto=$(git rev-parse ":/A") &&
1122 git rebase --onto $onto $upstream &&
1123 git reset --hard branch1 &&
1124 git rebase --onto ":/A" ":/J" &&
1125 git checkout branch1
1128 test_expect_success 'rebase -i with --strategy and -X' '
1129 git checkout -b conflict-merge-use-theirs conflict-branch &&
1130 git reset --hard HEAD^ &&
1131 echo five >conflict &&
1133 git commit -a -m "one file conflict" &&
1134 EDITOR=true git rebase -i --strategy=recursive -Xours conflict-branch &&
1135 test $(git show conflict-branch:conflict) = $(cat conflict) &&
1136 test $(cat file1) = Z
1139 test_expect_success 'interrupted rebase -i with --strategy and -X' '
1140 git checkout -b conflict-merge-use-theirs-interrupted conflict-branch &&
1141 git reset --hard HEAD^ &&
1143 git add breakpoint &&
1144 git commit -m "breakpoint for interactive mode" &&
1145 echo five >conflict &&
1147 git commit -a -m "one file conflict" &&
1149 FAKE_LINES="edit 1 2" git rebase -i --strategy=recursive -Xours conflict-branch &&
1150 git rebase --continue &&
1151 test $(git show conflict-branch:conflict) = $(cat conflict) &&
1152 test $(cat file1) = Z
1155 test_expect_success 'rebase -i error on commits with \ in message' '
1156 current_head=$(git rev-parse HEAD) &&
1157 test_when_finished "git rebase --abort; git reset --hard $current_head; rm -f error" &&
1158 test_commit TO-REMOVE will-conflict old-content &&
1159 test_commit "\temp" will-conflict new-content dummy &&
1160 test_must_fail env EDITOR=true git rebase -i HEAD^ --onto HEAD^^ 2>error &&
1161 test_expect_code 1 grep " emp" error
1164 test_expect_success 'short SHA-1 setup' '
1165 test_when_finished "git checkout master" &&
1166 git checkout --orphan collide &&
1170 test_commit collide1 collide &&
1171 test_commit --notick collide2 collide &&
1172 test_commit --notick collide3 collide
1176 test_expect_success 'short SHA-1 collide' '
1177 test_when_finished "reset_rebase && git checkout master" &&
1178 git checkout collide &&
1183 FAKE_COMMIT_MESSAGE="collide2 ac4f2ee" \
1184 FAKE_LINES="reword 1 2" git rebase -i HEAD~2
1188 test_expect_success 'respect core.abbrev' '
1189 git config core.abbrev 12 &&
1190 set_cat_todo_editor &&
1191 test_must_fail git rebase -i HEAD~4 >todo-list &&
1192 test 4 = $(grep -c "pick [0-9a-f]\{12,\}" todo-list)
1195 test_expect_success 'todo count' '
1196 write_script dump-raw.sh <<-\EOF &&
1199 test_set_editor "$(pwd)/dump-raw.sh" &&
1200 git rebase -i HEAD~4 >actual &&
1201 test_i18ngrep "^# Rebase ..* onto ..* ([0-9]" actual
1204 test_expect_success 'rebase -i commits that overwrite untracked files (pick)' '
1205 git checkout --force branch2 &&
1208 FAKE_LINES="edit 1 2" git rebase -i A &&
1209 test_cmp_rev HEAD F &&
1210 test_path_is_missing file6 &&
1212 test_must_fail git rebase --continue &&
1213 test_cmp_rev HEAD F &&
1215 git rebase --continue &&
1219 test_expect_success 'rebase -i commits that overwrite untracked files (squash)' '
1220 git checkout --force branch2 &&
1222 git tag original-branch2 &&
1224 FAKE_LINES="edit 1 squash 2" git rebase -i A &&
1225 test_cmp_rev HEAD F &&
1226 test_path_is_missing file6 &&
1228 test_must_fail git rebase --continue &&
1229 test_cmp_rev HEAD F &&
1231 git rebase --continue &&
1232 test $(git cat-file commit HEAD | sed -ne \$p) = I &&
1233 git reset --hard original-branch2
1236 test_expect_success 'rebase -i commits that overwrite untracked files (no ff)' '
1237 git checkout --force branch2 &&
1240 FAKE_LINES="edit 1 2" git rebase -i --no-ff A &&
1241 test $(git cat-file commit HEAD | sed -ne \$p) = F &&
1242 test_path_is_missing file6 &&
1244 test_must_fail git rebase --continue &&
1245 test $(git cat-file commit HEAD | sed -ne \$p) = F &&
1247 git rebase --continue &&
1248 test $(git cat-file commit HEAD | sed -ne \$p) = I
1251 test_expect_success 'rebase --continue removes CHERRY_PICK_HEAD' '
1252 git checkout -b commit-to-skip &&
1255 test_seq 5 | sed "s/$double/&&/" >seq &&
1258 git commit -m seq-$double
1261 git reset --hard HEAD~2 &&
1262 git cherry-pick seq-onto &&
1264 test_must_fail env FAKE_LINES= git rebase -i seq-onto &&
1265 test -d .git/rebase-merge &&
1266 git rebase --continue &&
1267 git diff --exit-code seq-onto &&
1268 test ! -d .git/rebase-merge &&
1269 test ! -f .git/CHERRY_PICK_HEAD
1272 rebase_setup_and_clean () {
1273 test_when_finished "
1274 git checkout master &&
1275 test_might_fail git branch -D $1 &&
1276 test_might_fail git rebase --abort
1278 git checkout -b $1 ${2:-master}
1281 test_expect_success 'drop' '
1282 rebase_setup_and_clean drop-test &&
1284 FAKE_LINES="1 drop 2 3 d 4 5" git rebase -i --root &&
1285 test E = $(git cat-file commit HEAD | sed -ne \$p) &&
1286 test C = $(git cat-file commit HEAD^ | sed -ne \$p) &&
1287 test A = $(git cat-file commit HEAD^^ | sed -ne \$p)
1290 test_expect_success 'rebase -i respects rebase.missingCommitsCheck = ignore' '
1291 test_config rebase.missingCommitsCheck ignore &&
1292 rebase_setup_and_clean missing-commit &&
1294 FAKE_LINES="1 2 3 4" \
1295 git rebase -i --root 2>actual &&
1296 test D = $(git cat-file commit HEAD | sed -ne \$p) &&
1298 "Successfully rebased and updated refs/heads/missing-commit" \
1303 Warning: some commits may have been dropped accidentally.
1304 Dropped commits (newer to older):
1305 - $(git rev-list --pretty=oneline --abbrev-commit -1 master)
1306 To avoid this message, use "drop" to explicitly remove a commit.
1308 Use 'git config rebase.missingCommitsCheck' to change the level of warnings.
1309 The possible behaviours are: ignore, warn, error.
1315 Successfully rebased and updated refs/heads/missing-commit.
1322 test_expect_success 'rebase -i respects rebase.missingCommitsCheck = warn' '
1323 test_config rebase.missingCommitsCheck warn &&
1324 rebase_setup_and_clean missing-commit &&
1326 FAKE_LINES="1 2 3 4" \
1327 git rebase -i --root 2>actual.2 &&
1328 cr_to_nl <actual.2 >actual &&
1329 test_i18ncmp expect actual &&
1330 test D = $(git cat-file commit HEAD | sed -ne \$p)
1334 Warning: some commits may have been dropped accidentally.
1335 Dropped commits (newer to older):
1336 - $(git rev-list --pretty=oneline --abbrev-commit -1 master)
1337 - $(git rev-list --pretty=oneline --abbrev-commit -1 master~2)
1338 To avoid this message, use "drop" to explicitly remove a commit.
1340 Use 'git config rebase.missingCommitsCheck' to change the level of warnings.
1341 The possible behaviours are: ignore, warn, error.
1343 You can fix this with 'git rebase --edit-todo' and then run 'git rebase --continue'.
1344 Or you can abort the rebase with 'git rebase --abort'.
1347 test_expect_success 'rebase -i respects rebase.missingCommitsCheck = error' '
1348 test_config rebase.missingCommitsCheck error &&
1349 rebase_setup_and_clean missing-commit &&
1351 test_must_fail env FAKE_LINES="1 2 4" \
1352 git rebase -i --root 2>actual &&
1353 test_i18ncmp expect actual &&
1354 cp .git/rebase-merge/git-rebase-todo.backup \
1355 .git/rebase-merge/git-rebase-todo &&
1356 FAKE_LINES="1 2 drop 3 4 drop 5" \
1357 git rebase --edit-todo &&
1358 git rebase --continue &&
1359 test D = $(git cat-file commit HEAD | sed -ne \$p) &&
1360 test B = $(git cat-file commit HEAD^ | sed -ne \$p)
1363 test_expect_success 'respects rebase.abbreviateCommands with fixup, squash and exec' '
1364 rebase_setup_and_clean abbrevcmd &&
1365 test_commit "first" file1.txt "first line" first &&
1366 test_commit "second" file1.txt "another line" second &&
1367 test_commit "fixup! first" file2.txt "first line again" first_fixup &&
1368 test_commit "squash! second" file1.txt "another line here" second_squash &&
1369 cat >expected <<-EOF &&
1370 p $(git rev-list --abbrev-commit -1 first) first
1371 f $(git rev-list --abbrev-commit -1 first_fixup) fixup! first
1373 p $(git rev-list --abbrev-commit -1 second) second
1374 s $(git rev-list --abbrev-commit -1 second_squash) squash! second
1377 git checkout abbrevcmd &&
1378 set_cat_todo_editor &&
1379 test_config rebase.abbreviateCommands true &&
1380 test_must_fail git rebase -i --exec "git show HEAD" \
1381 --autosquash master >actual &&
1382 test_cmp expected actual
1385 test_expect_success 'static check of bad command' '
1386 rebase_setup_and_clean bad-cmd &&
1388 test_must_fail env FAKE_LINES="1 2 3 bad 4 5" \
1389 git rebase -i --root 2>actual &&
1390 test_i18ngrep "badcmd $(git rev-list --oneline -1 master~1)" actual &&
1391 test_i18ngrep "You can fix this with .git rebase --edit-todo.." actual &&
1392 FAKE_LINES="1 2 3 drop 4 5" git rebase --edit-todo &&
1393 git rebase --continue &&
1394 test E = $(git cat-file commit HEAD | sed -ne \$p) &&
1395 test C = $(git cat-file commit HEAD^ | sed -ne \$p)
1398 test_expect_success 'tabs and spaces are accepted in the todolist' '
1399 rebase_setup_and_clean indented-comment &&
1400 write_script add-indent.sh <<-\EOF &&
1402 # Turn single spaces into space/tab mix
1403 sed "1s/ / /g; 2s/ / /g; 3s/ / /g" "$1"
1404 printf "\n\t# comment\n #more\n\t # comment\n"
1408 test_set_editor "$(pwd)/add-indent.sh" &&
1409 git rebase -i HEAD^^^ &&
1410 test E = $(git cat-file commit HEAD | sed -ne \$p)
1413 test_expect_success 'static check of bad SHA-1' '
1414 rebase_setup_and_clean bad-sha &&
1416 test_must_fail env FAKE_LINES="1 2 edit fakesha 3 4 5 #" \
1417 git rebase -i --root 2>actual &&
1418 test_i18ngrep "edit XXXXXXX False commit" actual &&
1419 test_i18ngrep "You can fix this with .git rebase --edit-todo.." actual &&
1420 FAKE_LINES="1 2 4 5 6" git rebase --edit-todo &&
1421 git rebase --continue &&
1422 test E = $(git cat-file commit HEAD | sed -ne \$p)
1425 test_expect_success 'editor saves as CR/LF' '
1426 git checkout -b with-crlf &&
1427 write_script add-crs.sh <<-\EOF &&
1428 sed -e "s/\$/Q/" <"$1" | tr Q "\\015" >"$1".new &&
1432 test_set_editor "$(pwd)/add-crs.sh" &&
1438 test_expect_success 'rebase -i --gpg-sign=<key-id>' '
1439 test_when_finished "test_might_fail git rebase --abort" &&
1441 FAKE_LINES="edit 1" git rebase -i --gpg-sign="\"S I Gner\"" HEAD^ \
1443 test_i18ngrep "$SQ-S\"S I Gner\"$SQ" err
1446 test_expect_success 'rebase -i --gpg-sign=<key-id> overrides commit.gpgSign' '
1447 test_when_finished "test_might_fail git rebase --abort" &&
1448 test_config commit.gpgsign true &&
1450 FAKE_LINES="edit 1" git rebase -i --gpg-sign="\"S I Gner\"" HEAD^ \
1452 test_i18ngrep "$SQ-S\"S I Gner\"$SQ" err
1455 test_expect_success 'valid author header after --root swap' '
1456 rebase_setup_and_clean author-header no-conflict-branch &&
1458 git commit --amend --author="Au ${SQ}thor <author@example.com>" --no-edit &&
1459 git cat-file commit HEAD | grep ^author >expected &&
1460 FAKE_LINES="5 1" git rebase -i --root &&
1461 git cat-file commit HEAD^ | grep ^author >actual &&
1462 test_cmp expected actual
1465 test_expect_success 'valid author header when author contains single quote' '
1466 rebase_setup_and_clean author-header no-conflict-branch &&
1468 git commit --amend --author="Au ${SQ}thor <author@example.com>" --no-edit &&
1469 git cat-file commit HEAD | grep ^author >expected &&
1470 FAKE_LINES="2" git rebase -i HEAD~2 &&
1471 git cat-file commit HEAD | grep ^author >actual &&
1472 test_cmp expected actual