3 test_description
='git rebase --continue tests'
7 .
"$TEST_DIRECTORY"/lib-rebase.sh
11 test_expect_success
'setup' '
12 test_commit "commit-new-file-F1" F1 1 &&
13 test_commit "commit-new-file-F2" F2 2 &&
15 git checkout -b topic HEAD^ &&
16 test_commit "commit-new-file-F2-on-topic-branch" F2 22 &&
21 test_expect_success
'interactive rebase --continue works with touched file' '
22 rm -fr .git/rebase-* &&
24 git checkout master &&
26 FAKE_LINES="edit 1" git rebase -i HEAD^ &&
27 test-tool chmtime =-60 F1 &&
31 test_expect_success
'non-interactive rebase --continue works with touched file' '
32 rm -fr .git/rebase-* &&
34 git checkout master &&
36 test_must_fail git rebase --onto master master topic &&
37 echo "Resolved" >F2 &&
39 test-tool chmtime =-60 F1 &&
43 test_expect_success
'rebase --continue can not be used with other options' '
44 test_must_fail git rebase -v --continue &&
45 test_must_fail git rebase --continue -v
48 test_expect_success
'rebase --continue remembers merge strategy and options' '
49 rm -fr .git/rebase-* &&
50 git reset --hard commit-new-file-F2-on-topic-branch &&
51 test_commit "commit-new-file-F3-on-topic-branch" F3 32 &&
52 test_when_finished "rm -fr test-bin funny.was.run" &&
54 cat >test-bin/git-merge-funny <<-EOF &&
56 case "\$1" in --opt) ;; *) exit 2 ;; esac
59 exec git merge-recursive "\$@"
61 chmod +x test-bin/git-merge-funny &&
64 test_must_fail git rebase -s funny -Xopt master topic
66 test -f funny.was.run &&
68 echo "Resolved" >F2 &&
77 test_expect_success
'rebase passes merge strategy options correctly' '
78 rm -fr .git/rebase-* &&
79 git reset --hard commit-new-file-F3-on-topic-branch &&
80 test_commit theirs-to-merge &&
81 git reset --hard HEAD^ &&
82 test_commit some-commit &&
84 git merge --no-ff theirs-to-merge &&
85 FAKE_LINES="1 edit 2 3" git rebase -i -f -p -m \
86 -s recursive --strategy-option=theirs HEAD~2 &&
87 test_commit force-change &&
91 test_expect_success
'--skip after failed fixup cleans commit message' '
92 test_when_finished "test_might_fail git rebase --abort" &&
93 git checkout -b with-conflicting-fixup &&
94 test_commit wants-fixup &&
95 test_commit "fixup! wants-fixup" wants-fixup.t 1 wants-fixup-1 &&
96 test_commit "fixup! wants-fixup" wants-fixup.t 2 wants-fixup-2 &&
97 test_commit "fixup! wants-fixup" wants-fixup.t 3 wants-fixup-3 &&
98 test_must_fail env FAKE_LINES="1 fixup 2 squash 4" \
99 git rebase -i HEAD~4 &&
101 : now there is a conflict, and comments in the commit message &&
102 git show HEAD >out &&
103 grep "fixup! wants-fixup" out &&
105 : skip and continue &&
106 echo "cp \"\$1\" .git/copy.txt" | write_script copy-editor.sh &&
107 (test_set_editor "$PWD/copy-editor.sh" && git rebase --skip) &&
109 : the user should not have had to edit the commit message &&
110 test_path_is_missing .git/copy.txt &&
112 : now the comments in the commit message should have been cleaned up &&
113 git show HEAD >out &&
114 ! grep "fixup! wants-fixup" out &&
116 : now, let us ensure that "squash" is handled correctly &&
117 git reset --hard wants-fixup-3 &&
118 test_must_fail env FAKE_LINES="1 squash 4 squash 2 squash 4" \
119 git rebase -i HEAD~4 &&
121 : the first squash failed, but there are two more in the chain &&
122 (test_set_editor "$PWD/copy-editor.sh" &&
123 test_must_fail git rebase --skip) &&
125 : not the final squash, no need to edit the commit message &&
126 test_path_is_missing .git/copy.txt &&
128 : The first squash was skipped, therefore: &&
129 git show HEAD >out &&
130 test_i18ngrep "# This is a combination of 2 commits" out &&
132 (test_set_editor "$PWD/copy-editor.sh" && git rebase --skip) &&
133 git show HEAD >out &&
134 test_i18ngrep ! "# This is a combination" out &&
136 : Final squash failed, but there was still a squash &&
137 test_i18ngrep "# This is a combination of 2 commits" .git/copy.txt
140 test_expect_success
'setup rerere database' '
141 rm -fr .git/rebase-* &&
142 git reset --hard commit-new-file-F3-on-topic-branch &&
143 git checkout master &&
144 test_commit "commit-new-file-F3" F3 3 &&
145 test_config rerere.enabled true &&
146 test_must_fail git rebase -m master topic &&
147 echo "Resolved" >F2 &&
150 test_must_fail git rebase --continue &&
151 echo "Resolved" >F3 &&
154 git rebase --continue &&
155 git reset --hard topic@{1}
159 rm -fr .git
/rebase-
* &&
160 git
reset --hard commit-new-file-F3-on-topic-branch
&&
161 git checkout master
&&
162 test_config rerere.enabled true
165 test_rerere_autoupdate
() {
167 test_expect_success
"rebase $action --continue remembers --rerere-autoupdate" '
169 test_must_fail git rebase $action --rerere-autoupdate master topic &&
170 test_cmp expected-F2 F2 &&
171 git diff-files --quiet &&
172 test_must_fail git rebase --continue &&
173 test_cmp expected-F3 F3 &&
174 git diff-files --quiet &&
175 git rebase --continue
178 test_expect_success
"rebase $action --continue honors rerere.autoUpdate" '
180 test_config rerere.autoupdate true &&
181 test_must_fail git rebase $action master topic &&
182 test_cmp expected-F2 F2 &&
183 git diff-files --quiet &&
184 test_must_fail git rebase --continue &&
185 test_cmp expected-F3 F3 &&
186 git diff-files --quiet &&
187 git rebase --continue
190 test_expect_success
"rebase $action --continue remembers --no-rerere-autoupdate" '
192 test_config rerere.autoupdate true &&
193 test_must_fail git rebase $action --no-rerere-autoupdate master topic &&
194 test_cmp expected-F2 F2 &&
195 test_must_fail git diff-files --quiet &&
197 test_must_fail git rebase --continue &&
198 test_cmp expected-F3 F3 &&
199 test_must_fail git diff-files --quiet &&
201 git rebase --continue
205 test_rerere_autoupdate
206 test_rerere_autoupdate
-m
207 GIT_SEQUENCE_EDITOR
=: && export GIT_SEQUENCE_EDITOR
208 test_rerere_autoupdate
-i
209 test_rerere_autoupdate
--preserve-merges