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 test_expect_success 'setup' '
33 test_commit A file1 &&
34 test_commit B file1 &&
35 test_commit C file2 &&
36 test_commit D file1 &&
37 test_commit E file3 &&
38 git checkout -b branch1 A &&
39 test_commit F file4 &&
40 test_commit G file1 &&
41 test_commit H file5 &&
42 git checkout -b branch2 F &&
43 test_commit I file6 &&
44 git checkout -b conflict-branch A &&
45 test_commit one conflict &&
46 test_commit two conflict &&
47 test_commit three conflict &&
48 test_commit four conflict &&
49 git checkout -b no-conflict-branch A &&
50 test_commit J fileJ &&
51 test_commit K fileK &&
52 test_commit L fileL &&
53 test_commit M fileM &&
54 git checkout -b no-ff-branch A &&
55 test_commit N fileN &&
56 test_commit O fileO &&
60 # "exec" commands are run with the user shell by default, but this may
61 # be non-POSIX. For example, if SHELL=zsh then ">file" doesn't work
62 # to create a file. Unsetting SHELL avoids such non-portable behavior
63 # in tests. It must be exported for it to take effect where needed.
67 test_expect_success 'rebase --keep-empty' '
68 git checkout -b emptybranch master &&
69 git commit --allow-empty -m "empty" &&
70 git rebase --keep-empty -i HEAD~2 &&
71 git log --oneline >actual &&
72 test_line_count = 6 actual
75 test_expect_success 'rebase -i with empty HEAD' '
76 cat >expect <<-\EOF &&
80 test_must_fail env FAKE_LINES="1 exec_true" git rebase -i HEAD^ >actual 2>&1 &&
81 test_i18ncmp expect actual
84 test_expect_success 'rebase -i with the exec command' '
85 git checkout master &&
88 FAKE_LINES="1 exec_>touch-one
89 2 exec_>touch-two exec_false exec_>touch-three
90 3 4 exec_>\"touch-file__name_with_spaces\";_>touch-after-semicolon 5" &&
92 test_must_fail git rebase -i A
94 test_path_is_file touch-one &&
95 test_path_is_file touch-two &&
96 test_path_is_missing touch-three " (should have stopped before)" &&
97 test_cmp_rev C HEAD &&
98 git rebase --continue &&
99 test_path_is_file touch-three &&
100 test_path_is_file "touch-file name with spaces" &&
101 test_path_is_file touch-after-semicolon &&
102 test_cmp_rev master HEAD &&
106 test_expect_success 'rebase -i with the exec command runs from tree root' '
107 git checkout master &&
108 mkdir subdir && (cd subdir &&
110 FAKE_LINES="1 exec_>touch-subdir" \
113 test_path_is_file touch-subdir &&
117 test_expect_success 'rebase -i with exec allows git commands in subdirs' '
118 test_when_finished "rm -rf subdir" &&
119 test_when_finished "git rebase --abort ||:" &&
120 git checkout master &&
121 mkdir subdir && (cd subdir &&
123 FAKE_LINES="1 x_cd_subdir_&&_git_rev-parse_--is-inside-work-tree" \
128 test_expect_success 'rebase -i sets work tree properly' '
129 test_when_finished "rm -rf subdir" &&
130 test_when_finished "test_might_fail git rebase --abort" &&
132 git rebase -x "(cd subdir && git rev-parse --show-toplevel)" HEAD^ \
134 ! grep "/subdir$" actual
137 test_expect_success 'rebase -i with the exec command checks tree cleanness' '
138 git checkout master &&
140 test_must_fail env FAKE_LINES="exec_echo_foo_>file1 1" git rebase -i HEAD^ &&
141 test_cmp_rev master^ HEAD &&
143 git rebase --continue
146 test_expect_success 'rebase -x with empty command fails' '
147 test_when_finished "git rebase --abort ||:" &&
148 test_must_fail env git rebase -x "" @ 2>actual &&
149 test_write_lines "error: empty exec command" >expected &&
150 test_i18ncmp expected actual &&
151 test_must_fail env git rebase -x " " @ 2>actual &&
152 test_i18ncmp expected actual
155 test_expect_success 'rebase -x with newline in command fails' '
156 test_when_finished "git rebase --abort ||:" &&
157 test_must_fail env git rebase -x "a${LF}b" @ 2>actual &&
158 test_write_lines "error: exec commands cannot contain newlines" \
160 test_i18ncmp expected actual
163 test_expect_success 'rebase -i with exec of inexistent command' '
164 git checkout master &&
165 test_when_finished "git rebase --abort" &&
167 test_must_fail env FAKE_LINES="exec_this-command-does-not-exist 1" \
168 git rebase -i HEAD^ >actual 2>&1 &&
169 ! grep "Maybe git-rebase is broken" actual
172 test_expect_success 'implicit interactive rebase does not invoke sequence editor' '
173 test_when_finished "git rebase --abort ||:" &&
174 GIT_SEQUENCE_EDITOR="echo bad >" git rebase -x"echo one" @^
177 test_expect_success 'no changes are a nop' '
178 git checkout branch2 &&
181 test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch2" &&
182 test $(git rev-parse I) = $(git rev-parse HEAD)
185 test_expect_success 'test the [branch] option' '
186 git checkout -b dead-end &&
188 git commit -m "stop here" &&
190 git rebase -i F branch2 &&
191 test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch2" &&
192 test $(git rev-parse I) = $(git rev-parse branch2) &&
193 test $(git rev-parse I) = $(git rev-parse HEAD)
196 test_expect_success 'test --onto <branch>' '
197 git checkout -b test-onto branch2 &&
199 git rebase -i --onto branch1 F &&
200 test "$(git symbolic-ref -q HEAD)" = "refs/heads/test-onto" &&
201 test $(git rev-parse HEAD^) = $(git rev-parse branch1) &&
202 test $(git rev-parse I) = $(git rev-parse branch2)
205 test_expect_success 'rebase on top of a non-conflicting commit' '
206 git checkout branch1 &&
207 git tag original-branch1 &&
209 git rebase -i branch2 &&
210 test file6 = $(git diff --name-only original-branch1) &&
211 test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch1" &&
212 test $(git rev-parse I) = $(git rev-parse branch2) &&
213 test $(git rev-parse I) = $(git rev-parse HEAD~2)
216 test_expect_success 'reflog for the branch shows state before rebase' '
217 test $(git rev-parse branch1@{1}) = $(git rev-parse original-branch1)
220 test_expect_success 'reflog for the branch shows correct finish message' '
221 printf "rebase -i (finish): refs/heads/branch1 onto %s\n" \
222 "$(git rev-parse branch2)" >expected &&
223 git log -g --pretty=%gs -1 refs/heads/branch1 >actual &&
224 test_cmp expected actual
227 test_expect_success 'exchange two commits' '
229 FAKE_LINES="2 1" git rebase -i HEAD~2 &&
230 test H = $(git cat-file commit HEAD^ | sed -ne \$p) &&
231 test G = $(git cat-file commit HEAD | sed -ne \$p) &&
232 blob1=$(git rev-parse --short HEAD^:file1) &&
233 blob2=$(git rev-parse --short HEAD:file1) &&
234 commit=$(git rev-parse --short HEAD)
237 test_expect_success 'stop on conflicting pick' '
238 cat >expect <<-EOF &&
239 diff --git a/file1 b/file1
240 index $blob1..$blob2 100644
247 cat >expect2 <<-EOF &&
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 test_expect_success C_LOCALE_OUTPUT 'squash and fixup generate correct log messages' '
494 cat >expect-squash-fixup <<-\EOF &&
501 git checkout -b squash-fixup E &&
502 base=$(git rev-parse HEAD~4) &&
504 FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="1 fixup 2 squash 3 fixup 4" \
505 EXPECT_HEADER_COUNT=4 \
506 git rebase -i $base &&
507 git cat-file commit HEAD | sed -e 1,/^\$/d > actual-squash-fixup &&
508 test_cmp expect-squash-fixup actual-squash-fixup &&
509 git cat-file commit HEAD@{2} |
510 grep "^# This is a combination of 3 commits\." &&
511 git cat-file commit HEAD@{3} |
512 grep "^# This is a combination of 2 commits\." &&
513 git checkout @{-1} &&
514 git branch -D squash-fixup
517 test_expect_success C_LOCALE_OUTPUT 'squash ignores comments' '
518 git checkout -b skip-comments E &&
519 base=$(git rev-parse HEAD~4) &&
521 FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="# 1 # squash 2 # squash 3 # squash 4 #" \
522 EXPECT_HEADER_COUNT=4 \
523 git rebase -i $base &&
524 test $base = $(git rev-parse HEAD^) &&
525 test 1 = $(git show | grep ONCE | wc -l) &&
526 git checkout @{-1} &&
527 git branch -D skip-comments
530 test_expect_success C_LOCALE_OUTPUT 'squash ignores blank lines' '
531 git checkout -b skip-blank-lines E &&
532 base=$(git rev-parse HEAD~4) &&
534 FAKE_COMMIT_AMEND="ONCE" FAKE_LINES="> 1 > squash 2 > squash 3 > squash 4 >" \
535 EXPECT_HEADER_COUNT=4 \
536 git rebase -i $base &&
537 test $base = $(git rev-parse HEAD^) &&
538 test 1 = $(git show | grep ONCE | wc -l) &&
539 git checkout @{-1} &&
540 git branch -D skip-blank-lines
543 test_expect_success 'squash works as expected' '
544 git checkout -b squash-works no-conflict-branch &&
545 one=$(git rev-parse HEAD~3) &&
547 FAKE_LINES="1 s 3 2" EXPECT_HEADER_COUNT=2 \
548 git rebase -i HEAD~3 &&
549 test $one = $(git rev-parse HEAD~2)
552 test_expect_success 'interrupted squash works as expected' '
553 git checkout -b interrupted-squash conflict-branch &&
554 one=$(git rev-parse HEAD~3) &&
556 test_must_fail env FAKE_LINES="1 squash 3 2" git rebase -i HEAD~3 &&
557 test_write_lines one two four > conflict &&
559 test_must_fail git rebase --continue &&
560 echo resolved > conflict &&
562 git rebase --continue &&
563 test $one = $(git rev-parse HEAD~2)
566 test_expect_success 'interrupted squash works as expected (case 2)' '
567 git checkout -b interrupted-squash2 conflict-branch &&
568 one=$(git rev-parse HEAD~3) &&
570 test_must_fail env FAKE_LINES="3 squash 1 2" git rebase -i HEAD~3 &&
571 test_write_lines one four > conflict &&
573 test_must_fail git rebase --continue &&
574 test_write_lines one two four > conflict &&
576 test_must_fail git rebase --continue &&
577 echo resolved > conflict &&
579 git rebase --continue &&
580 test $one = $(git rev-parse HEAD~2)
583 test_expect_success '--continue tries to commit, even for "edit"' '
584 echo unrelated > file7 &&
587 git commit -m "unrelated change" &&
588 parent=$(git rev-parse HEAD^) &&
591 FAKE_LINES="edit 1" git rebase -i HEAD^ &&
592 echo edited > file7 &&
594 FAKE_COMMIT_MESSAGE="chouette!" git rebase --continue &&
595 test edited = $(git show HEAD:file7) &&
596 git show HEAD | grep chouette &&
597 test $parent = $(git rev-parse HEAD^)
600 test_expect_success 'aborted --continue does not squash commits after "edit"' '
601 old=$(git rev-parse HEAD) &&
604 FAKE_LINES="edit 1" git rebase -i HEAD^ &&
605 echo "edited again" > file7 &&
607 test_must_fail env FAKE_COMMIT_MESSAGE=" " git rebase --continue &&
608 test $old = $(git rev-parse HEAD) &&
612 test_expect_success 'auto-amend only edited commits after "edit"' '
615 FAKE_LINES="edit 1" git rebase -i HEAD^ &&
616 echo "edited again" > file7 &&
618 FAKE_COMMIT_MESSAGE="edited file7 again" git commit &&
619 echo "and again" > file7 &&
622 test_must_fail env FAKE_COMMIT_MESSAGE="and again" git rebase --continue &&
626 test_expect_success 'clean error after failed "exec"' '
628 test_when_finished "git rebase --abort || :" &&
630 test_must_fail env FAKE_LINES="1 exec_false" git rebase -i HEAD^ &&
631 echo "edited again" > file7 &&
633 test_must_fail git rebase --continue 2>error &&
634 test_i18ngrep "you have staged changes in your working tree" error
637 test_expect_success 'rebase a detached HEAD' '
638 grandparent=$(git rev-parse HEAD~2) &&
639 git checkout $(git rev-parse HEAD) &&
642 FAKE_LINES="2 1" git rebase -i HEAD~2 &&
643 test $grandparent = $(git rev-parse HEAD~2)
646 test_expect_success 'rebase a commit violating pre-commit' '
648 mkdir -p .git/hooks &&
649 write_script .git/hooks/pre-commit <<-\EOF &&
650 test -z "$(git diff --cached --check)"
652 echo "monde! " >> file1 &&
654 test_must_fail git commit -m doesnt-verify file1 &&
655 git commit -m doesnt-verify --no-verify file1 &&
658 FAKE_LINES=2 git rebase -i HEAD~2
662 test_expect_success 'rebase with a file named HEAD in worktree' '
666 git checkout -b branch3 A &&
669 GIT_AUTHOR_NAME="Squashed Away" &&
670 export GIT_AUTHOR_NAME &&
673 git commit -m "Add head" &&
676 git commit -m "Add body"
680 FAKE_LINES="1 squash 2" git rebase -i @{-1} &&
681 test "$(git show -s --pretty=format:%an)" = "Squashed Away"
685 test_expect_success 'do "noop" when there is nothing to cherry-pick' '
687 git checkout -b branch4 HEAD &&
688 GIT_EDITOR=: git commit --amend \
689 --author="Somebody else <somebody@else.com>" &&
690 test $(git rev-parse branch3) != $(git rev-parse branch4) &&
692 git rebase -i branch3 &&
693 test $(git rev-parse branch3) = $(git rev-parse branch4)
697 test_expect_success 'submodule rebase setup' '
701 cd sub && git init && >elif &&
702 git add elif && git commit -m "submodule initial"
707 git commit -m "One" &&
710 git commit -a -m "Two" &&
712 cd sub && echo 3 >elif &&
713 git commit -a -m "submodule second"
717 git commit -a -m "Three changes submodule"
720 test_expect_success 'submodule rebase -i' '
722 FAKE_LINES="1 squash 2 3" git rebase -i A
725 test_expect_success 'submodule conflict setup' '
726 git tag submodule-base &&
727 git checkout HEAD^ &&
729 cd sub && git checkout HEAD^ && echo 4 >elif &&
730 git add elif && git commit -m "submodule conflict"
734 git commit -m "Conflict in submodule" &&
735 git tag submodule-topic
738 test_expect_success 'rebase -i continue with only submodule staged' '
740 test_must_fail git rebase -i submodule-base &&
742 git rebase --continue &&
743 test $(git rev-parse submodule-base) != $(git rev-parse HEAD)
746 test_expect_success 'rebase -i continue with unstaged submodule' '
747 git checkout submodule-topic &&
750 test_must_fail git rebase -i submodule-base &&
752 git rebase --continue &&
753 test $(git rev-parse submodule-base) = $(git rev-parse HEAD)
756 test_expect_success 'avoid unnecessary reset' '
757 git checkout master &&
759 test-tool chmtime =123456789 file3 &&
760 git update-index --refresh &&
761 HEAD=$(git rev-parse HEAD) &&
763 git rebase -i HEAD~4 &&
764 test $HEAD = $(git rev-parse HEAD) &&
765 MTIME=$(test-tool chmtime --get file3) &&
766 test 123456789 = $MTIME
769 test_expect_success 'reword' '
770 git checkout -b reword-branch master &&
772 FAKE_LINES="1 2 3 reword 4" FAKE_COMMIT_MESSAGE="E changed" git rebase -i A &&
773 git show HEAD | grep "E changed" &&
774 test $(git rev-parse master) != $(git rev-parse HEAD) &&
775 test $(git rev-parse master^) = $(git rev-parse HEAD^) &&
776 FAKE_LINES="1 2 reword 3 4" FAKE_COMMIT_MESSAGE="D changed" git rebase -i A &&
777 git show HEAD^ | grep "D changed" &&
778 FAKE_LINES="reword 1 2 3 4" FAKE_COMMIT_MESSAGE="B changed" git rebase -i A &&
779 git show HEAD~3 | grep "B changed" &&
780 FAKE_LINES="1 r 2 pick 3 p 4" FAKE_COMMIT_MESSAGE="C changed" git rebase -i A &&
781 git show HEAD~2 | grep "C changed"
784 test_expect_success 'rebase -i can copy notes' '
785 git config notes.rewrite.rebase true &&
786 git config notes.rewriteRef "refs/notes/*" &&
790 git notes add -m"a note" n3 &&
792 git rebase -i --onto n1 n2 &&
793 test "a note" = "$(git notes show HEAD)"
796 test_expect_success 'rebase -i can copy notes over a fixup' '
797 cat >expect <<-\EOF &&
802 git reset --hard n3 &&
803 git notes add -m"an earlier note" n2 &&
805 GIT_NOTES_REWRITE_MODE=concatenate FAKE_LINES="1 f 2" git rebase -i n1 &&
806 git notes show > output &&
807 test_cmp expect output
810 test_expect_success 'rebase while detaching HEAD' '
811 git symbolic-ref HEAD &&
812 grandparent=$(git rev-parse HEAD~2) &&
815 FAKE_LINES="2 1" git rebase -i HEAD~2 HEAD^0 &&
816 test $grandparent = $(git rev-parse HEAD~2) &&
817 test_must_fail git symbolic-ref HEAD
820 test_tick # Ensure that the rebased commits get a different timestamp.
821 test_expect_success 'always cherry-pick with --no-ff' '
822 git checkout no-ff-branch &&
823 git tag original-no-ff-branch &&
825 git rebase -i --no-ff A &&
828 test ! $(git rev-parse HEAD~$p) = $(git rev-parse original-no-ff-branch~$p) &&
829 git diff HEAD~$p original-no-ff-branch~$p > out &&
830 test_must_be_empty out
832 test $(git rev-parse HEAD~3) = $(git rev-parse original-no-ff-branch~3) &&
833 git diff HEAD~3 original-no-ff-branch~3 > out &&
834 test_must_be_empty out
837 test_expect_success 'set up commits with funny messages' '
838 git checkout -b funny A &&
841 git commit -a -m "end with slash\\" &&
844 git commit -a -m "something (\000) that looks like octal" &&
847 git commit -a -m "something (\n) that looks like a newline" &&
850 git commit -a -m "another commit"
853 test_expect_success 'rebase-i history with funny messages' '
854 git rev-list A..funny >expect &&
857 FAKE_LINES="1 2 3 4" git rebase -i A &&
858 git rev-list A.. >actual &&
859 test_cmp expect actual
862 test_expect_success 'prepare for rebase -i --exec' '
863 git checkout master &&
864 git checkout -b execute &&
865 test_commit one_exec main.txt one_exec &&
866 test_commit two_exec main.txt two_exec &&
867 test_commit three_exec main.txt three_exec
870 test_expect_success 'running "git rebase -i --exec git show HEAD"' '
872 git rebase -i --exec "git show HEAD" HEAD~2 >actual &&
874 FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD" &&
876 git rebase -i HEAD~2 >expect
878 sed -e "1,9d" expect >expected &&
879 test_cmp expected actual
882 test_expect_success 'running "git rebase --exec git show HEAD -i"' '
883 git reset --hard execute &&
885 git rebase --exec "git show HEAD" -i HEAD~2 >actual &&
887 FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD" &&
889 git rebase -i HEAD~2 >expect
891 sed -e "1,9d" expect >expected &&
892 test_cmp expected actual
895 test_expect_success 'running "git rebase -ix git show HEAD"' '
896 git reset --hard execute &&
898 git rebase -ix "git show HEAD" HEAD~2 >actual &&
900 FAKE_LINES="1 exec_git_show_HEAD 2 exec_git_show_HEAD" &&
902 git rebase -i HEAD~2 >expect
904 sed -e "1,9d" expect >expected &&
905 test_cmp expected actual
909 test_expect_success 'rebase -ix with several <CMD>' '
910 git reset --hard execute &&
912 git rebase -ix "git show HEAD; pwd" HEAD~2 >actual &&
914 FAKE_LINES="1 exec_git_show_HEAD;_pwd 2 exec_git_show_HEAD;_pwd" &&
916 git rebase -i HEAD~2 >expect
918 sed -e "1,9d" expect >expected &&
919 test_cmp expected actual
922 test_expect_success 'rebase -ix with several instances of --exec' '
923 git reset --hard execute &&
925 git rebase -i --exec "git show HEAD" --exec "pwd" HEAD~2 >actual &&
927 FAKE_LINES="1 exec_git_show_HEAD exec_pwd 2
928 exec_git_show_HEAD exec_pwd" &&
930 git rebase -i HEAD~2 >expect
932 sed -e "1,11d" expect >expected &&
933 test_cmp expected actual
936 test_expect_success C_LOCALE_OUTPUT 'rebase -ix with --autosquash' '
937 git reset --hard execute &&
938 git checkout -b autosquash &&
939 echo second >second.txt &&
940 git add second.txt &&
941 git commit -m "fixup! two_exec" &&
944 git commit -m "fixup! two_exec" &&
947 git checkout -b autosquash_actual &&
948 git rebase -i --exec "git show HEAD" --autosquash HEAD~4 >actual
950 git checkout autosquash &&
952 git checkout -b autosquash_expected &&
953 FAKE_LINES="1 fixup 3 fixup 4 exec_git_show_HEAD 2 exec_git_show_HEAD" &&
955 git rebase -i HEAD~4 >expect
957 sed -e "1,13d" expect >expected &&
958 test_cmp expected actual
961 test_expect_success 'rebase --exec works without -i ' '
962 git reset --hard execute &&
963 rm -rf exec_output &&
964 EDITOR="echo >invoked_editor" git rebase --exec "echo a line >>exec_output" HEAD~2 2>actual &&
965 test_i18ngrep "Successfully rebased and updated" actual &&
966 test_line_count = 2 exec_output &&
967 test_path_is_missing invoked_editor
970 test_expect_success 'rebase -i --exec without <CMD>' '
971 git reset --hard execute &&
973 test_must_fail git rebase -i --exec 2>actual &&
974 test_i18ngrep "requires a value" actual &&
978 test_expect_success 'rebase -i --root re-order and drop commits' '
981 FAKE_LINES="3 1 2 5" git rebase -i --root &&
982 test E = $(git cat-file commit HEAD | sed -ne \$p) &&
983 test B = $(git cat-file commit HEAD^ | sed -ne \$p) &&
984 test A = $(git cat-file commit HEAD^^ | sed -ne \$p) &&
985 test C = $(git cat-file commit HEAD^^^ | sed -ne \$p) &&
986 test 0 = $(git cat-file commit HEAD^^^ | grep -c ^parent\ )
989 test_expect_success 'rebase -i --root retain root commit author and message' '
993 GIT_AUTHOR_NAME="Twerp Snog" git commit -m "different author" &&
995 FAKE_LINES="2" git rebase -i --root &&
996 git cat-file commit HEAD | grep -q "^author Twerp Snog" &&
997 git cat-file commit HEAD | grep -q "^different author$"
1000 test_expect_success 'rebase -i --root temporary sentinel commit' '
1003 test_must_fail env FAKE_LINES="2" git rebase -i --root &&
1004 git cat-file commit HEAD | grep "^tree $EMPTY_TREE" &&
1008 test_expect_success 'rebase -i --root fixup root commit' '
1011 FAKE_LINES="1 fixup 2" git rebase -i --root &&
1012 test A = $(git cat-file commit HEAD | sed -ne \$p) &&
1013 test B = $(git show HEAD:file1) &&
1014 test 0 = $(git cat-file commit HEAD | grep -c ^parent\ )
1017 test_expect_success 'rebase -i --root reword root commit' '
1018 test_when_finished "test_might_fail git rebase --abort" &&
1019 git checkout -b reword-root-branch master &&
1021 FAKE_LINES="reword 1 2" FAKE_COMMIT_MESSAGE="A changed" \
1022 git rebase -i --root &&
1023 git show HEAD^ | grep "A changed" &&
1024 test -z "$(git show -s --format=%p HEAD^)"
1027 test_expect_success 'rebase -i --root when root has untracked file conflict' '
1028 test_when_finished "reset_rebase" &&
1029 git checkout -b failing-root-pick A &&
1032 git commit -m "remove file 1 add file 2" &&
1035 test_must_fail env FAKE_LINES="1 2" git rebase -i --root &&
1037 git rebase --continue &&
1038 test "$(git log -1 --format=%B)" = "remove file 1 add file 2" &&
1039 test "$(git rev-list --count HEAD)" = 2
1042 test_expect_success 'rebase -i --root reword root when root has untracked file conflict' '
1043 test_when_finished "reset_rebase" &&
1046 test_must_fail env FAKE_LINES="reword 1 2" \
1047 FAKE_COMMIT_MESSAGE="Modified A" git rebase -i --root &&
1049 FAKE_COMMIT_MESSAGE="Reworded A" git rebase --continue &&
1050 test "$(git log -1 --format=%B HEAD^)" = "Reworded A" &&
1051 test "$(git rev-list --count HEAD)" = 2
1054 test_expect_success C_LOCALE_OUTPUT 'rebase --edit-todo does not work on non-interactive rebase' '
1055 git checkout reword-root-branch &&
1057 git checkout conflict-branch &&
1059 test_must_fail git rebase -f --onto HEAD~2 HEAD~ &&
1060 test_must_fail git rebase --edit-todo &&
1064 test_expect_success 'rebase --edit-todo can be used to modify todo' '
1066 git checkout no-conflict-branch^0 &&
1068 FAKE_LINES="edit 1 2 3" git rebase -i HEAD~3 &&
1069 FAKE_LINES="2 1" git rebase --edit-todo &&
1070 git rebase --continue &&
1071 test M = $(git cat-file commit HEAD^ | sed -ne \$p) &&
1072 test L = $(git cat-file commit HEAD | sed -ne \$p)
1075 test_expect_success 'rebase -i produces readable reflog' '
1077 git branch -f branch-reflog-test H &&
1079 git rebase -i --onto I F branch-reflog-test &&
1080 cat >expect <<-\EOF &&
1081 rebase -i (finish): returning to refs/heads/branch-reflog-test
1084 rebase -i (start): checkout I
1086 git reflog -n4 HEAD |
1087 sed "s/[^:]*: //" >actual &&
1088 test_cmp expect actual
1091 test_expect_success 'rebase -i respects core.commentchar' '
1094 test_config core.commentchar "\\" &&
1095 write_script remove-all-but-first.sh <<-\EOF &&
1096 sed -e "2,\$s/^/\\\\/" "$1" >"$1.tmp" &&
1099 test_set_editor "$(pwd)/remove-all-but-first.sh" &&
1101 test B = $(git cat-file commit HEAD^ | sed -ne \$p)
1104 test_expect_success 'rebase -i respects core.commentchar=auto' '
1105 test_config core.commentchar auto &&
1106 write_script copy-edit-script.sh <<-\EOF &&
1109 test_set_editor "$(pwd)/copy-edit-script.sh" &&
1110 test_when_finished "git rebase --abort || :" &&
1111 git rebase -i HEAD^ &&
1112 test -z "$(grep -ve "^#" -e "^\$" -e "^pick" edit-script)"
1115 test_expect_success 'rebase -i, with <onto> and <upstream> specified as :/quuxery' '
1116 test_when_finished "git branch -D torebase" &&
1117 git checkout -b torebase branch1 &&
1118 upstream=$(git rev-parse ":/J") &&
1119 onto=$(git rev-parse ":/A") &&
1120 git rebase --onto $onto $upstream &&
1121 git reset --hard branch1 &&
1122 git rebase --onto ":/A" ":/J" &&
1123 git checkout branch1
1126 test_expect_success 'rebase -i with --strategy and -X' '
1127 git checkout -b conflict-merge-use-theirs conflict-branch &&
1128 git reset --hard HEAD^ &&
1129 echo five >conflict &&
1131 git commit -a -m "one file conflict" &&
1132 EDITOR=true git rebase -i --strategy=recursive -Xours conflict-branch &&
1133 test $(git show conflict-branch:conflict) = $(cat conflict) &&
1134 test $(cat file1) = Z
1137 test_expect_success 'interrupted rebase -i with --strategy and -X' '
1138 git checkout -b conflict-merge-use-theirs-interrupted conflict-branch &&
1139 git reset --hard HEAD^ &&
1141 git add breakpoint &&
1142 git commit -m "breakpoint for interactive mode" &&
1143 echo five >conflict &&
1145 git commit -a -m "one file conflict" &&
1147 FAKE_LINES="edit 1 2" git rebase -i --strategy=recursive -Xours conflict-branch &&
1148 git rebase --continue &&
1149 test $(git show conflict-branch:conflict) = $(cat conflict) &&
1150 test $(cat file1) = Z
1153 test_expect_success 'rebase -i error on commits with \ in message' '
1154 current_head=$(git rev-parse HEAD) &&
1155 test_when_finished "git rebase --abort; git reset --hard $current_head; rm -f error" &&
1156 test_commit TO-REMOVE will-conflict old-content &&
1157 test_commit "\temp" will-conflict new-content dummy &&
1158 test_must_fail env EDITOR=true git rebase -i HEAD^ --onto HEAD^^ 2>error &&
1159 test_expect_code 1 grep " emp" error
1162 test_expect_success SHA1 'short SHA-1 setup' '
1163 test_when_finished "git checkout master" &&
1164 git checkout --orphan collide &&
1168 test_commit collide1 collide &&
1169 test_commit --notick collide2 collide &&
1170 test_commit --notick collide3 collide
1174 test_expect_success SHA1 'short SHA-1 collide' '
1175 test_when_finished "reset_rebase && git checkout master" &&
1176 git checkout collide &&
1181 FAKE_COMMIT_MESSAGE="collide2 ac4f2ee" \
1182 FAKE_LINES="reword 1 2" git rebase -i HEAD~2
1186 test_expect_success 'respect core.abbrev' '
1187 git config core.abbrev 12 &&
1188 set_cat_todo_editor &&
1189 test_must_fail git rebase -i HEAD~4 >todo-list &&
1190 test 4 = $(grep -c "pick [0-9a-f]\{12,\}" todo-list)
1193 test_expect_success 'todo count' '
1194 write_script dump-raw.sh <<-\EOF &&
1197 test_set_editor "$(pwd)/dump-raw.sh" &&
1198 git rebase -i HEAD~4 >actual &&
1199 test_i18ngrep "^# Rebase ..* onto ..* ([0-9]" actual
1202 test_expect_success 'rebase -i commits that overwrite untracked files (pick)' '
1203 git checkout --force branch2 &&
1206 FAKE_LINES="edit 1 2" git rebase -i A &&
1207 test_cmp_rev HEAD F &&
1208 test_path_is_missing file6 &&
1210 test_must_fail git rebase --continue &&
1211 test_cmp_rev HEAD F &&
1213 git rebase --continue &&
1217 test_expect_success 'rebase -i commits that overwrite untracked files (squash)' '
1218 git checkout --force branch2 &&
1220 git tag original-branch2 &&
1222 FAKE_LINES="edit 1 squash 2" git rebase -i A &&
1223 test_cmp_rev HEAD F &&
1224 test_path_is_missing file6 &&
1226 test_must_fail git rebase --continue &&
1227 test_cmp_rev HEAD F &&
1229 git rebase --continue &&
1230 test $(git cat-file commit HEAD | sed -ne \$p) = I &&
1231 git reset --hard original-branch2
1234 test_expect_success 'rebase -i commits that overwrite untracked files (no ff)' '
1235 git checkout --force branch2 &&
1238 FAKE_LINES="edit 1 2" git rebase -i --no-ff A &&
1239 test $(git cat-file commit HEAD | sed -ne \$p) = F &&
1240 test_path_is_missing file6 &&
1242 test_must_fail git rebase --continue &&
1243 test $(git cat-file commit HEAD | sed -ne \$p) = F &&
1245 git rebase --continue &&
1246 test $(git cat-file commit HEAD | sed -ne \$p) = I
1249 test_expect_success 'rebase --continue removes CHERRY_PICK_HEAD' '
1250 git checkout -b commit-to-skip &&
1253 test_seq 5 | sed "s/$double/&&/" >seq &&
1256 git commit -m seq-$double
1259 git reset --hard HEAD~2 &&
1260 git cherry-pick seq-onto &&
1262 test_must_fail env FAKE_LINES= git rebase -i seq-onto &&
1263 test -d .git/rebase-merge &&
1264 git rebase --continue &&
1265 git diff --exit-code seq-onto &&
1266 test ! -d .git/rebase-merge &&
1267 test ! -f .git/CHERRY_PICK_HEAD
1270 rebase_setup_and_clean () {
1271 test_when_finished "
1272 git checkout master &&
1273 test_might_fail git branch -D $1 &&
1274 test_might_fail git rebase --abort
1276 git checkout -b $1 ${2:-master}
1279 test_expect_success 'drop' '
1280 rebase_setup_and_clean drop-test &&
1282 FAKE_LINES="1 drop 2 3 d 4 5" git rebase -i --root &&
1283 test E = $(git cat-file commit HEAD | sed -ne \$p) &&
1284 test C = $(git cat-file commit HEAD^ | sed -ne \$p) &&
1285 test A = $(git cat-file commit HEAD^^ | sed -ne \$p)
1288 test_expect_success 'rebase -i respects rebase.missingCommitsCheck = ignore' '
1289 test_config rebase.missingCommitsCheck ignore &&
1290 rebase_setup_and_clean missing-commit &&
1292 FAKE_LINES="1 2 3 4" \
1293 git rebase -i --root 2>actual &&
1294 test D = $(git cat-file commit HEAD | sed -ne \$p) &&
1296 "Successfully rebased and updated refs/heads/missing-commit" \
1300 test_expect_success 'rebase -i respects rebase.missingCommitsCheck = warn' '
1301 cat >expect <<-EOF &&
1302 Warning: some commits may have been dropped accidentally.
1303 Dropped commits (newer to older):
1304 - $(git rev-list --pretty=oneline --abbrev-commit -1 master)
1305 To avoid this message, use "drop" to explicitly remove a commit.
1307 test_config rebase.missingCommitsCheck warn &&
1308 rebase_setup_and_clean missing-commit &&
1310 FAKE_LINES="1 2 3 4" \
1311 git rebase -i --root 2>actual.2 &&
1312 head -n4 actual.2 >actual &&
1313 test_i18ncmp expect actual &&
1314 test D = $(git cat-file commit HEAD | sed -ne \$p)
1317 test_expect_success 'rebase -i respects rebase.missingCommitsCheck = error' '
1318 cat >expect <<-EOF &&
1319 Warning: some commits may have been dropped accidentally.
1320 Dropped commits (newer to older):
1321 - $(git rev-list --pretty=oneline --abbrev-commit -1 master)
1322 - $(git rev-list --pretty=oneline --abbrev-commit -1 master~2)
1323 To avoid this message, use "drop" to explicitly remove a commit.
1325 Use '\''git config rebase.missingCommitsCheck'\'' to change the level of warnings.
1326 The possible behaviours are: ignore, warn, error.
1328 You can fix this with '\''git rebase --edit-todo'\'' and then run '\''git rebase --continue'\''.
1329 Or you can abort the rebase with '\''git rebase --abort'\''.
1331 test_config rebase.missingCommitsCheck error &&
1332 rebase_setup_and_clean missing-commit &&
1334 test_must_fail env FAKE_LINES="1 2 4" \
1335 git rebase -i --root 2>actual &&
1336 test_i18ncmp expect actual &&
1337 cp .git/rebase-merge/git-rebase-todo.backup \
1338 .git/rebase-merge/git-rebase-todo &&
1339 FAKE_LINES="1 2 drop 3 4 drop 5" \
1340 git rebase --edit-todo &&
1341 git rebase --continue &&
1342 test D = $(git cat-file commit HEAD | sed -ne \$p) &&
1343 test B = $(git cat-file commit HEAD^ | sed -ne \$p)
1346 test_expect_success 'respects rebase.abbreviateCommands with fixup, squash and exec' '
1347 rebase_setup_and_clean abbrevcmd &&
1348 test_commit "first" file1.txt "first line" first &&
1349 test_commit "second" file1.txt "another line" second &&
1350 test_commit "fixup! first" file2.txt "first line again" first_fixup &&
1351 test_commit "squash! second" file1.txt "another line here" second_squash &&
1352 cat >expected <<-EOF &&
1353 p $(git rev-list --abbrev-commit -1 first) first
1354 f $(git rev-list --abbrev-commit -1 first_fixup) fixup! first
1356 p $(git rev-list --abbrev-commit -1 second) second
1357 s $(git rev-list --abbrev-commit -1 second_squash) squash! second
1360 git checkout abbrevcmd &&
1361 set_cat_todo_editor &&
1362 test_config rebase.abbreviateCommands true &&
1363 test_must_fail git rebase -i --exec "git show HEAD" \
1364 --autosquash master >actual &&
1365 test_cmp expected actual
1368 test_expect_success 'static check of bad command' '
1369 rebase_setup_and_clean bad-cmd &&
1371 test_must_fail env FAKE_LINES="1 2 3 bad 4 5" \
1372 git rebase -i --root 2>actual &&
1373 test_i18ngrep "badcmd $(git rev-list --oneline -1 master~1)" actual &&
1374 test_i18ngrep "You can fix this with .git rebase --edit-todo.." actual &&
1375 FAKE_LINES="1 2 3 drop 4 5" git rebase --edit-todo &&
1376 git rebase --continue &&
1377 test E = $(git cat-file commit HEAD | sed -ne \$p) &&
1378 test C = $(git cat-file commit HEAD^ | sed -ne \$p)
1381 test_expect_success 'tabs and spaces are accepted in the todolist' '
1382 rebase_setup_and_clean indented-comment &&
1383 write_script add-indent.sh <<-\EOF &&
1385 # Turn single spaces into space/tab mix
1386 sed "1s/ / /g; 2s/ / /g; 3s/ / /g" "$1"
1387 printf "\n\t# comment\n #more\n\t # comment\n"
1391 test_set_editor "$(pwd)/add-indent.sh" &&
1392 git rebase -i HEAD^^^ &&
1393 test E = $(git cat-file commit HEAD | sed -ne \$p)
1396 test_expect_success 'static check of bad SHA-1' '
1397 rebase_setup_and_clean bad-sha &&
1399 test_must_fail env FAKE_LINES="1 2 edit fakesha 3 4 5 #" \
1400 git rebase -i --root 2>actual &&
1401 test_i18ngrep "edit XXXXXXX False commit" actual &&
1402 test_i18ngrep "You can fix this with .git rebase --edit-todo.." actual &&
1403 FAKE_LINES="1 2 4 5 6" git rebase --edit-todo &&
1404 git rebase --continue &&
1405 test E = $(git cat-file commit HEAD | sed -ne \$p)
1408 test_expect_success 'editor saves as CR/LF' '
1409 git checkout -b with-crlf &&
1410 write_script add-crs.sh <<-\EOF &&
1411 sed -e "s/\$/Q/" <"$1" | tr Q "\\015" >"$1".new &&
1415 test_set_editor "$(pwd)/add-crs.sh" &&
1420 test_expect_success 'rebase -i --gpg-sign=<key-id>' '
1421 test_when_finished "test_might_fail git rebase --abort" &&
1423 FAKE_LINES="edit 1" git rebase -i --gpg-sign="\"S I Gner\"" HEAD^ \
1425 test_i18ngrep "$SQ-S\"S I Gner\"$SQ" err
1428 test_expect_success 'rebase -i --gpg-sign=<key-id> overrides commit.gpgSign' '
1429 test_when_finished "test_might_fail git rebase --abort" &&
1430 test_config commit.gpgsign true &&
1432 FAKE_LINES="edit 1" git rebase -i --gpg-sign="\"S I Gner\"" HEAD^ \
1434 test_i18ngrep "$SQ-S\"S I Gner\"$SQ" err
1437 test_expect_success 'valid author header after --root swap' '
1438 rebase_setup_and_clean author-header no-conflict-branch &&
1440 git commit --amend --author="Au ${SQ}thor <author@example.com>" --no-edit &&
1441 git cat-file commit HEAD | grep ^author >expected &&
1442 FAKE_LINES="5 1" git rebase -i --root &&
1443 git cat-file commit HEAD^ | grep ^author >actual &&
1444 test_cmp expected actual
1447 test_expect_success 'valid author header when author contains single quote' '
1448 rebase_setup_and_clean author-header no-conflict-branch &&
1450 git commit --amend --author="Au ${SQ}thor <author@example.com>" --no-edit &&
1451 git cat-file commit HEAD | grep ^author >expected &&
1452 FAKE_LINES="2" git rebase -i HEAD~2 &&
1453 git cat-file commit HEAD | grep ^author >actual &&
1454 test_cmp expected actual