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 -i --continue handles merge strategy and options' '
78 rm -fr .git/rebase-* &&
79 git reset --hard commit-new-file-F2-on-topic-branch &&
80 test_commit "commit-new-file-F3-on-topic-branch-for-dash-i" F3 32 &&
81 test_when_finished "rm -fr test-bin funny.was.run funny.args" &&
83 cat >test-bin/git-merge-funny <<-EOF &&
85 echo "\$@" >>funny.args
86 case "\$1" in --opt) ;; *) exit 2 ;; esac
87 case "\$2" in --foo) ;; *) exit 2 ;; esac
88 case "\$4" in --) ;; *) exit 2 ;; esac
91 exec git merge-recursive "\$@"
93 chmod +x test-bin/git-merge-funny &&
95 PATH=./test-bin:$PATH &&
96 test_must_fail git rebase -i -s funny -Xopt -Xfoo master topic
98 test -f funny.was.run &&
100 echo "Resolved" >F2 &&
103 PATH=./test-bin:$PATH &&
104 git rebase --continue
106 test -f funny.was.run
109 test_expect_success
'rebase passes merge strategy options correctly' '
110 rm -fr .git/rebase-* &&
111 git reset --hard commit-new-file-F3-on-topic-branch &&
112 test_commit theirs-to-merge &&
113 git reset --hard HEAD^ &&
114 test_commit some-commit &&
116 git merge --no-ff theirs-to-merge &&
117 FAKE_LINES="1 edit 2 3" git rebase -i -f -p -m \
118 -s recursive --strategy-option=theirs HEAD~2 &&
119 test_commit force-change &&
120 git rebase --continue
123 test_expect_success
'--skip after failed fixup cleans commit message' '
124 test_when_finished "test_might_fail git rebase --abort" &&
125 git checkout -b with-conflicting-fixup &&
126 test_commit wants-fixup &&
127 test_commit "fixup! wants-fixup" wants-fixup.t 1 wants-fixup-1 &&
128 test_commit "fixup! wants-fixup" wants-fixup.t 2 wants-fixup-2 &&
129 test_commit "fixup! wants-fixup" wants-fixup.t 3 wants-fixup-3 &&
130 test_must_fail env FAKE_LINES="1 fixup 2 squash 4" \
131 git rebase -i HEAD~4 &&
133 : now there is a conflict, and comments in the commit message &&
134 git show HEAD >out &&
135 grep "fixup! wants-fixup" out &&
137 : skip and continue &&
138 echo "cp \"\$1\" .git/copy.txt" | write_script copy-editor.sh &&
139 (test_set_editor "$PWD/copy-editor.sh" && git rebase --skip) &&
141 : the user should not have had to edit the commit message &&
142 test_path_is_missing .git/copy.txt &&
144 : now the comments in the commit message should have been cleaned up &&
145 git show HEAD >out &&
146 ! grep "fixup! wants-fixup" out &&
148 : now, let us ensure that "squash" is handled correctly &&
149 git reset --hard wants-fixup-3 &&
150 test_must_fail env FAKE_LINES="1 squash 4 squash 2 squash 4" \
151 git rebase -i HEAD~4 &&
153 : the first squash failed, but there are two more in the chain &&
154 (test_set_editor "$PWD/copy-editor.sh" &&
155 test_must_fail git rebase --skip) &&
157 : not the final squash, no need to edit the commit message &&
158 test_path_is_missing .git/copy.txt &&
160 : The first squash was skipped, therefore: &&
161 git show HEAD >out &&
162 test_i18ngrep "# This is a combination of 2 commits" out &&
164 (test_set_editor "$PWD/copy-editor.sh" && git rebase --skip) &&
165 git show HEAD >out &&
166 test_i18ngrep ! "# This is a combination" out &&
168 : Final squash failed, but there was still a squash &&
169 test_i18ngrep "# This is a combination of 2 commits" .git/copy.txt
172 test_expect_success
'setup rerere database' '
173 rm -fr .git/rebase-* &&
174 git reset --hard commit-new-file-F3-on-topic-branch &&
175 git checkout master &&
176 test_commit "commit-new-file-F3" F3 3 &&
177 test_config rerere.enabled true &&
178 test_must_fail git rebase -m master topic &&
179 echo "Resolved" >F2 &&
182 test_must_fail git rebase --continue &&
183 echo "Resolved" >F3 &&
186 git rebase --continue &&
187 git reset --hard topic@{1}
191 rm -fr .git
/rebase-
* &&
192 git
reset --hard commit-new-file-F3-on-topic-branch
&&
193 git checkout master
&&
194 test_config rerere.enabled true
197 test_rerere_autoupdate
() {
199 test_expect_success
"rebase $action --continue remembers --rerere-autoupdate" '
201 test_must_fail git rebase $action --rerere-autoupdate master topic &&
202 test_cmp expected-F2 F2 &&
203 git diff-files --quiet &&
204 test_must_fail git rebase --continue &&
205 test_cmp expected-F3 F3 &&
206 git diff-files --quiet &&
207 git rebase --continue
210 test_expect_success
"rebase $action --continue honors rerere.autoUpdate" '
212 test_config rerere.autoupdate true &&
213 test_must_fail git rebase $action master topic &&
214 test_cmp expected-F2 F2 &&
215 git diff-files --quiet &&
216 test_must_fail git rebase --continue &&
217 test_cmp expected-F3 F3 &&
218 git diff-files --quiet &&
219 git rebase --continue
222 test_expect_success
"rebase $action --continue remembers --no-rerere-autoupdate" '
224 test_config rerere.autoupdate true &&
225 test_must_fail git rebase $action --no-rerere-autoupdate master topic &&
226 test_cmp expected-F2 F2 &&
227 test_must_fail git diff-files --quiet &&
229 test_must_fail git rebase --continue &&
230 test_cmp expected-F3 F3 &&
231 test_must_fail git diff-files --quiet &&
233 git rebase --continue
237 test_rerere_autoupdate
238 test_rerere_autoupdate
-m
239 GIT_SEQUENCE_EDITOR
=: && export GIT_SEQUENCE_EDITOR
240 test_rerere_autoupdate
-i
241 test_rerere_autoupdate
--preserve-merges