commit-graph: update design document
[git.git] / t / t3418-rebase-continue.sh
blob03bf1b8a3b3df2e44ed0f70dc176c25af9ac244a
1 #!/bin/sh
3 test_description='git rebase --continue tests'
5 . ./test-lib.sh
7 . "$TEST_DIRECTORY"/lib-rebase.sh
9 set_fake_editor
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 &&
18 git checkout master
21 test_expect_success 'interactive rebase --continue works with touched file' '
22 rm -fr .git/rebase-* &&
23 git reset --hard &&
24 git checkout master &&
26 FAKE_LINES="edit 1" git rebase -i HEAD^ &&
27 test-tool chmtime =-60 F1 &&
28 git rebase --continue
31 test_expect_success 'non-interactive rebase --continue works with touched file' '
32 rm -fr .git/rebase-* &&
33 git reset --hard &&
34 git checkout master &&
36 test_must_fail git rebase --onto master master topic &&
37 echo "Resolved" >F2 &&
38 git add F2 &&
39 test-tool chmtime =-60 F1 &&
40 git rebase --continue
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" &&
53 mkdir test-bin &&
54 cat >test-bin/git-merge-funny <<-EOF &&
55 #!$SHELL_PATH
56 case "\$1" in --opt) ;; *) exit 2 ;; esac
57 shift &&
58 >funny.was.run &&
59 exec git merge-recursive "\$@"
60 EOF
61 chmod +x test-bin/git-merge-funny &&
63 PATH=./test-bin:$PATH
64 test_must_fail git rebase -s funny -Xopt master topic
65 ) &&
66 test -f funny.was.run &&
67 rm funny.was.run &&
68 echo "Resolved" >F2 &&
69 git add F2 &&
71 PATH=./test-bin:$PATH
72 git rebase --continue
73 ) &&
74 test -f funny.was.run
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 &&
83 test_tick &&
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 &&
88 git rebase --continue
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 &&
148 cp F2 expected-F2 &&
149 git add F2 &&
150 test_must_fail git rebase --continue &&
151 echo "Resolved" >F3 &&
152 cp F3 expected-F3 &&
153 git add F3 &&
154 git rebase --continue &&
155 git reset --hard topic@{1}
158 prepare () {
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 () {
166 action=$1 &&
167 test_expect_success "rebase $action --continue remembers --rerere-autoupdate" '
168 prepare &&
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" '
179 prepare &&
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" '
191 prepare &&
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 &&
196 git add F2 &&
197 test_must_fail git rebase --continue &&
198 test_cmp expected-F3 F3 &&
199 test_must_fail git diff-files --quiet &&
200 git add F3 &&
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
211 test_done