Blame


1 818c7501 2019-07-11 stsp #!/bin/sh
2 818c7501 2019-07-11 stsp #
3 818c7501 2019-07-11 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 818c7501 2019-07-11 stsp #
5 818c7501 2019-07-11 stsp # Permission to use, copy, modify, and distribute this software for any
6 818c7501 2019-07-11 stsp # purpose with or without fee is hereby granted, provided that the above
7 818c7501 2019-07-11 stsp # copyright notice and this permission notice appear in all copies.
8 818c7501 2019-07-11 stsp #
9 818c7501 2019-07-11 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 818c7501 2019-07-11 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 818c7501 2019-07-11 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 818c7501 2019-07-11 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 818c7501 2019-07-11 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 818c7501 2019-07-11 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 818c7501 2019-07-11 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 818c7501 2019-07-11 stsp
17 818c7501 2019-07-11 stsp . ./common.sh
18 818c7501 2019-07-11 stsp
19 818c7501 2019-07-11 stsp function test_rebase_basic {
20 818c7501 2019-07-11 stsp local testroot=`test_init rebase_basic`
21 818c7501 2019-07-11 stsp
22 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
23 818c7501 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
24 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
25 818c7501 2019-07-11 stsp
26 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
27 818c7501 2019-07-11 stsp (cd $testroot/repo && git rm -q beta)
28 818c7501 2019-07-11 stsp echo "new file on branch" > $testroot/repo/epsilon/new
29 818c7501 2019-07-11 stsp (cd $testroot/repo && git add epsilon/new)
30 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
31 818c7501 2019-07-11 stsp
32 818c7501 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
33 818c7501 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
34 818c7501 2019-07-11 stsp
35 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
36 818c7501 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
37 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
38 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
39 818c7501 2019-07-11 stsp
40 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
41 818c7501 2019-07-11 stsp ret="$?"
42 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
43 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
44 818c7501 2019-07-11 stsp return 1
45 818c7501 2019-07-11 stsp fi
46 818c7501 2019-07-11 stsp
47 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
48 818c7501 2019-07-11 stsp
49 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
50 818c7501 2019-07-11 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
51 818c7501 2019-07-11 stsp local new_commit2=`git_show_head $testroot/repo`
52 818c7501 2019-07-11 stsp
53 818c7501 2019-07-11 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
54 818c7501 2019-07-11 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
55 818c7501 2019-07-11 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
56 818c7501 2019-07-11 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
57 818c7501 2019-07-11 stsp
58 818c7501 2019-07-11 stsp echo "G gamma/delta" >> $testroot/stdout.expected
59 818c7501 2019-07-11 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
60 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
61 818c7501 2019-07-11 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
62 818c7501 2019-07-11 stsp echo "G alpha" >> $testroot/stdout.expected
63 818c7501 2019-07-11 stsp echo "D beta" >> $testroot/stdout.expected
64 818c7501 2019-07-11 stsp echo "A epsilon/new" >> $testroot/stdout.expected
65 818c7501 2019-07-11 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
66 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
67 818c7501 2019-07-11 stsp echo ": committing more changes on newbranch" \
68 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
69 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
70 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
71 818c7501 2019-07-11 stsp
72 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
73 818c7501 2019-07-11 stsp ret="$?"
74 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
75 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
76 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
77 818c7501 2019-07-11 stsp return 1
78 818c7501 2019-07-11 stsp fi
79 818c7501 2019-07-11 stsp
80 818c7501 2019-07-11 stsp echo "modified delta on branch" > $testroot/content.expected
81 818c7501 2019-07-11 stsp cat $testroot/wt/gamma/delta > $testroot/content
82 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
83 818c7501 2019-07-11 stsp ret="$?"
84 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
85 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
86 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
87 818c7501 2019-07-11 stsp return 1
88 818c7501 2019-07-11 stsp fi
89 818c7501 2019-07-11 stsp
90 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/content.expected
91 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
92 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
93 818c7501 2019-07-11 stsp ret="$?"
94 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
95 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
96 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
97 818c7501 2019-07-11 stsp return 1
98 818c7501 2019-07-11 stsp fi
99 818c7501 2019-07-11 stsp
100 818c7501 2019-07-11 stsp if [ -e $testroot/wt/beta ]; then
101 818c7501 2019-07-11 stsp echo "removed file beta still exists on disk" >&2
102 818c7501 2019-07-11 stsp test_done "$testroot" "1"
103 818c7501 2019-07-11 stsp return 1
104 818c7501 2019-07-11 stsp fi
105 818c7501 2019-07-11 stsp
106 818c7501 2019-07-11 stsp echo "new file on branch" > $testroot/content.expected
107 818c7501 2019-07-11 stsp cat $testroot/wt/epsilon/new > $testroot/content
108 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
109 818c7501 2019-07-11 stsp ret="$?"
110 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
111 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
112 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
113 818c7501 2019-07-11 stsp return 1
114 818c7501 2019-07-11 stsp fi
115 818c7501 2019-07-11 stsp
116 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
117 818c7501 2019-07-11 stsp
118 818c7501 2019-07-11 stsp echo -n > $testroot/stdout.expected
119 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
120 818c7501 2019-07-11 stsp ret="$?"
121 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
122 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
123 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
124 818c7501 2019-07-11 stsp return 1
125 818c7501 2019-07-11 stsp fi
126 818c7501 2019-07-11 stsp
127 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
128 818c7501 2019-07-11 stsp echo "commit $new_commit2 (newbranch)" > $testroot/stdout.expected
129 818c7501 2019-07-11 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
130 818c7501 2019-07-11 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
131 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
132 818c7501 2019-07-11 stsp ret="$?"
133 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
134 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
135 818c7501 2019-07-11 stsp fi
136 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
137 818c7501 2019-07-11 stsp }
138 818c7501 2019-07-11 stsp
139 818c7501 2019-07-11 stsp function test_rebase_ancestry_check {
140 818c7501 2019-07-11 stsp local testroot=`test_init rebase_ancestry_check`
141 818c7501 2019-07-11 stsp
142 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
143 818c7501 2019-07-11 stsp ret="$?"
144 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
145 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
146 818c7501 2019-07-11 stsp return 1
147 818c7501 2019-07-11 stsp fi
148 818c7501 2019-07-11 stsp
149 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
150 818c7501 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
151 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
152 818c7501 2019-07-11 stsp
153 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
154 818c7501 2019-07-11 stsp 2> $testroot/stderr)
155 818c7501 2019-07-11 stsp
156 818c7501 2019-07-11 stsp echo -n > $testroot/stdout.expected
157 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
158 818c7501 2019-07-11 stsp ret="$?"
159 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
160 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
161 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
162 818c7501 2019-07-11 stsp return 1
163 818c7501 2019-07-11 stsp fi
164 818c7501 2019-07-11 stsp
165 818c7501 2019-07-11 stsp echo -n "got: specified branch resolves to a commit " \
166 818c7501 2019-07-11 stsp > $testroot/stderr.expected
167 818c7501 2019-07-11 stsp echo "which is already contained in work tree's branch" \
168 818c7501 2019-07-11 stsp >> $testroot/stderr.expected
169 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
170 818c7501 2019-07-11 stsp ret="$?"
171 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
172 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
173 818c7501 2019-07-11 stsp fi
174 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
175 818c7501 2019-07-11 stsp }
176 818c7501 2019-07-11 stsp
177 818c7501 2019-07-11 stsp function test_rebase_continue {
178 818c7501 2019-07-11 stsp local testroot=`test_init rebase_continue`
179 818c7501 2019-07-11 stsp
180 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
181 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
182 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
183 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
184 818c7501 2019-07-11 stsp
185 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
186 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
187 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
188 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
189 818c7501 2019-07-11 stsp
190 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
191 818c7501 2019-07-11 stsp ret="$?"
192 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
193 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
194 818c7501 2019-07-11 stsp return 1
195 818c7501 2019-07-11 stsp fi
196 818c7501 2019-07-11 stsp
197 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
198 818c7501 2019-07-11 stsp 2> $testroot/stderr)
199 818c7501 2019-07-11 stsp
200 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
201 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
202 818c7501 2019-07-11 stsp ret="$?"
203 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
204 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
205 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
206 818c7501 2019-07-11 stsp return 1
207 818c7501 2019-07-11 stsp fi
208 818c7501 2019-07-11 stsp
209 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
210 818c7501 2019-07-11 stsp > $testroot/stderr.expected
211 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
212 818c7501 2019-07-11 stsp ret="$?"
213 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
214 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
215 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
216 818c7501 2019-07-11 stsp return 1
217 818c7501 2019-07-11 stsp fi
218 818c7501 2019-07-11 stsp
219 818c7501 2019-07-11 stsp echo "<<<<<<< commit $orig_commit1" > $testroot/content.expected
220 818c7501 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
221 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
222 818c7501 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
223 818c7501 2019-07-11 stsp echo '>>>>>>> alpha' >> $testroot/content.expected
224 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
225 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
226 818c7501 2019-07-11 stsp ret="$?"
227 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
228 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
229 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
230 818c7501 2019-07-11 stsp return 1
231 818c7501 2019-07-11 stsp fi
232 818c7501 2019-07-11 stsp
233 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
234 818c7501 2019-07-11 stsp
235 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
236 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
237 818c7501 2019-07-11 stsp ret="$?"
238 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
239 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
240 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
241 818c7501 2019-07-11 stsp return 1
242 818c7501 2019-07-11 stsp fi
243 818c7501 2019-07-11 stsp
244 818c7501 2019-07-11 stsp # resolve the conflict
245 818c7501 2019-07-11 stsp echo "modified alpha on branch and master" > $testroot/wt/alpha
246 818c7501 2019-07-11 stsp
247 f032f1f7 2019-08-04 stsp # test interaction of 'got stage' and rebase -c
248 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got stage alpha > /dev/null)
249 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout \
250 f032f1f7 2019-08-04 stsp 2> $testroot/stderr)
251 f032f1f7 2019-08-04 stsp ret="$?"
252 f032f1f7 2019-08-04 stsp if [ "$ret" == "0" ]; then
253 f032f1f7 2019-08-04 stsp echo "rebase succeeded unexpectedly" >&2
254 f032f1f7 2019-08-04 stsp test_done "$testroot" "1"
255 f032f1f7 2019-08-04 stsp return 1
256 f032f1f7 2019-08-04 stsp fi
257 f032f1f7 2019-08-04 stsp echo -n "got: work tree contains files with staged changes; " \
258 f032f1f7 2019-08-04 stsp > $testroot/stderr.expected
259 f032f1f7 2019-08-04 stsp echo "these changes must be committed or unstaged first" \
260 f032f1f7 2019-08-04 stsp >> $testroot/stderr.expected
261 f032f1f7 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
262 f032f1f7 2019-08-04 stsp ret="$?"
263 f032f1f7 2019-08-04 stsp if [ "$ret" != "0" ]; then
264 f032f1f7 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
265 f032f1f7 2019-08-04 stsp test_done "$testroot" "$ret"
266 f032f1f7 2019-08-04 stsp return 1
267 f032f1f7 2019-08-04 stsp fi
268 f032f1f7 2019-08-04 stsp
269 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got unstage alpha > /dev/null)
270 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
271 818c7501 2019-07-11 stsp
272 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
273 818c7501 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
274 818c7501 2019-07-11 stsp
275 818c7501 2019-07-11 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
276 818c7501 2019-07-11 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
277 818c7501 2019-07-11 stsp
278 818c7501 2019-07-11 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
279 818c7501 2019-07-11 stsp > $testroot/stdout.expected
280 818c7501 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
281 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
282 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
283 818c7501 2019-07-11 stsp
284 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
285 818c7501 2019-07-11 stsp ret="$?"
286 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
287 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
288 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
289 818c7501 2019-07-11 stsp return 1
290 818c7501 2019-07-11 stsp fi
291 818c7501 2019-07-11 stsp
292 818c7501 2019-07-11 stsp
293 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
294 818c7501 2019-07-11 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
295 818c7501 2019-07-11 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
296 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
297 818c7501 2019-07-11 stsp ret="$?"
298 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
299 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
300 818c7501 2019-07-11 stsp fi
301 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
302 818c7501 2019-07-11 stsp }
303 818c7501 2019-07-11 stsp
304 818c7501 2019-07-11 stsp function test_rebase_abort {
305 818c7501 2019-07-11 stsp local testroot=`test_init rebase_abort`
306 818c7501 2019-07-11 stsp
307 818c7501 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
308 818c7501 2019-07-11 stsp
309 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
310 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
311 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
312 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
313 818c7501 2019-07-11 stsp
314 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
315 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
316 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
317 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
318 818c7501 2019-07-11 stsp
319 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
320 818c7501 2019-07-11 stsp ret="$?"
321 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
322 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
323 818c7501 2019-07-11 stsp return 1
324 818c7501 2019-07-11 stsp fi
325 818c7501 2019-07-11 stsp
326 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
327 818c7501 2019-07-11 stsp 2> $testroot/stderr)
328 818c7501 2019-07-11 stsp
329 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
330 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
331 818c7501 2019-07-11 stsp ret="$?"
332 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
333 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
334 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
335 818c7501 2019-07-11 stsp return 1
336 818c7501 2019-07-11 stsp fi
337 818c7501 2019-07-11 stsp
338 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
339 818c7501 2019-07-11 stsp > $testroot/stderr.expected
340 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
341 818c7501 2019-07-11 stsp ret="$?"
342 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
343 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
344 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
345 818c7501 2019-07-11 stsp return 1
346 818c7501 2019-07-11 stsp fi
347 818c7501 2019-07-11 stsp
348 818c7501 2019-07-11 stsp echo "<<<<<<< commit $orig_commit1" > $testroot/content.expected
349 818c7501 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
350 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
351 818c7501 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
352 818c7501 2019-07-11 stsp echo '>>>>>>> alpha' >> $testroot/content.expected
353 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
354 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
355 818c7501 2019-07-11 stsp ret="$?"
356 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
357 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
358 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
359 818c7501 2019-07-11 stsp return 1
360 818c7501 2019-07-11 stsp fi
361 818c7501 2019-07-11 stsp
362 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
363 818c7501 2019-07-11 stsp
364 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
365 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
366 818c7501 2019-07-11 stsp ret="$?"
367 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
368 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
369 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
370 818c7501 2019-07-11 stsp return 1
371 818c7501 2019-07-11 stsp fi
372 818c7501 2019-07-11 stsp
373 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -a > $testroot/stdout)
374 818c7501 2019-07-11 stsp
375 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
376 818c7501 2019-07-11 stsp
377 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/master" \
378 818c7501 2019-07-11 stsp > $testroot/stdout.expected
379 818c7501 2019-07-11 stsp echo 'R alpha' >> $testroot/stdout.expected
380 818c7501 2019-07-11 stsp echo "Rebase of refs/heads/newbranch aborted" \
381 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
382 818c7501 2019-07-11 stsp
383 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
384 818c7501 2019-07-11 stsp ret="$?"
385 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
386 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
387 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
388 818c7501 2019-07-11 stsp return 1
389 818c7501 2019-07-11 stsp fi
390 818c7501 2019-07-11 stsp
391 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/content.expected
392 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
393 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
394 818c7501 2019-07-11 stsp ret="$?"
395 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
396 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
397 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
398 818c7501 2019-07-11 stsp return 1
399 818c7501 2019-07-11 stsp fi
400 818c7501 2019-07-11 stsp
401 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l3 -c newbranch \
402 818c7501 2019-07-11 stsp | grep ^commit > $testroot/stdout)
403 818c7501 2019-07-11 stsp echo "commit $orig_commit1 (newbranch)" > $testroot/stdout.expected
404 818c7501 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
405 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
406 818c7501 2019-07-11 stsp ret="$?"
407 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
408 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
409 818c7501 2019-07-11 stsp fi
410 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
411 818c7501 2019-07-11 stsp }
412 818c7501 2019-07-11 stsp
413 ff0d2220 2019-07-11 stsp function test_rebase_no_op_change {
414 ff0d2220 2019-07-11 stsp local testroot=`test_init rebase_no_op_change`
415 ff0d2220 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
416 ff0d2220 2019-07-11 stsp
417 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
418 ff0d2220 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
419 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
420 ff0d2220 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
421 ff0d2220 2019-07-11 stsp
422 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
423 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
424 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
425 ff0d2220 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
426 ff0d2220 2019-07-11 stsp
427 ff0d2220 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
428 ff0d2220 2019-07-11 stsp ret="$?"
429 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
430 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
431 ff0d2220 2019-07-11 stsp return 1
432 ff0d2220 2019-07-11 stsp fi
433 ff0d2220 2019-07-11 stsp
434 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
435 ff0d2220 2019-07-11 stsp 2> $testroot/stderr)
436 ff0d2220 2019-07-11 stsp
437 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
438 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
439 ff0d2220 2019-07-11 stsp ret="$?"
440 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
441 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
442 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
443 ff0d2220 2019-07-11 stsp return 1
444 ff0d2220 2019-07-11 stsp fi
445 ff0d2220 2019-07-11 stsp
446 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
447 ff0d2220 2019-07-11 stsp > $testroot/stderr.expected
448 ff0d2220 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
449 ff0d2220 2019-07-11 stsp ret="$?"
450 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
451 ff0d2220 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
452 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
453 ff0d2220 2019-07-11 stsp return 1
454 ff0d2220 2019-07-11 stsp fi
455 ff0d2220 2019-07-11 stsp
456 ff0d2220 2019-07-11 stsp echo "<<<<<<< commit $orig_commit1" > $testroot/content.expected
457 ff0d2220 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
458 ff0d2220 2019-07-11 stsp echo "=======" >> $testroot/content.expected
459 ff0d2220 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
460 ff0d2220 2019-07-11 stsp echo '>>>>>>> alpha' >> $testroot/content.expected
461 ff0d2220 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
462 ff0d2220 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
463 ff0d2220 2019-07-11 stsp ret="$?"
464 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
465 ff0d2220 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
466 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
467 ff0d2220 2019-07-11 stsp return 1
468 ff0d2220 2019-07-11 stsp fi
469 ff0d2220 2019-07-11 stsp
470 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
471 ff0d2220 2019-07-11 stsp
472 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
473 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
474 ff0d2220 2019-07-11 stsp ret="$?"
475 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
476 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
477 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
478 ff0d2220 2019-07-11 stsp return 1
479 ff0d2220 2019-07-11 stsp fi
480 ff0d2220 2019-07-11 stsp
481 ff0d2220 2019-07-11 stsp # resolve the conflict
482 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/wt/alpha
483 ff0d2220 2019-07-11 stsp
484 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
485 ff0d2220 2019-07-11 stsp
486 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
487 ff0d2220 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
488 ff0d2220 2019-07-11 stsp
489 ff0d2220 2019-07-11 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
490 ff0d2220 2019-07-11 stsp
491 ff0d2220 2019-07-11 stsp echo -n "$short_orig_commit1 -> no-op change" \
492 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
493 ff0d2220 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
494 ff0d2220 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
495 ff0d2220 2019-07-11 stsp >> $testroot/stdout.expected
496 ff0d2220 2019-07-11 stsp
497 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
498 ff0d2220 2019-07-11 stsp ret="$?"
499 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
500 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
501 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
502 ff0d2220 2019-07-11 stsp return 1
503 ff0d2220 2019-07-11 stsp fi
504 ff0d2220 2019-07-11 stsp
505 ff0d2220 2019-07-11 stsp
506 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
507 ff0d2220 2019-07-11 stsp echo "commit $master_commit (master, newbranch)" \
508 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
509 ff0d2220 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
510 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
511 7d5807f4 2019-07-11 stsp ret="$?"
512 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
513 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
514 7d5807f4 2019-07-11 stsp fi
515 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
516 7d5807f4 2019-07-11 stsp }
517 7d5807f4 2019-07-11 stsp
518 7d5807f4 2019-07-11 stsp function test_rebase_in_progress {
519 4ba9c4f6 2019-07-11 stsp local testroot=`test_init rebase_in_progress`
520 7d5807f4 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
521 7d5807f4 2019-07-11 stsp
522 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
523 7d5807f4 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
524 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
525 7d5807f4 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
526 7d5807f4 2019-07-11 stsp
527 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
528 7d5807f4 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
529 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
530 7d5807f4 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
531 7d5807f4 2019-07-11 stsp
532 7d5807f4 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
533 7d5807f4 2019-07-11 stsp ret="$?"
534 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
535 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
536 7d5807f4 2019-07-11 stsp return 1
537 7d5807f4 2019-07-11 stsp fi
538 7d5807f4 2019-07-11 stsp
539 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
540 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
541 7d5807f4 2019-07-11 stsp
542 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
543 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
544 7d5807f4 2019-07-11 stsp ret="$?"
545 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
546 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
547 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
548 7d5807f4 2019-07-11 stsp return 1
549 7d5807f4 2019-07-11 stsp fi
550 7d5807f4 2019-07-11 stsp
551 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
552 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
553 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
554 7d5807f4 2019-07-11 stsp ret="$?"
555 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
556 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
557 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
558 7d5807f4 2019-07-11 stsp return 1
559 7d5807f4 2019-07-11 stsp fi
560 7d5807f4 2019-07-11 stsp
561 7d5807f4 2019-07-11 stsp echo "<<<<<<< commit $orig_commit1" > $testroot/content.expected
562 7d5807f4 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
563 7d5807f4 2019-07-11 stsp echo "=======" >> $testroot/content.expected
564 7d5807f4 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
565 7d5807f4 2019-07-11 stsp echo '>>>>>>> alpha' >> $testroot/content.expected
566 7d5807f4 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
567 7d5807f4 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
568 7d5807f4 2019-07-11 stsp ret="$?"
569 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
570 7d5807f4 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
571 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
572 7d5807f4 2019-07-11 stsp return 1
573 7d5807f4 2019-07-11 stsp fi
574 7d5807f4 2019-07-11 stsp
575 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
576 7d5807f4 2019-07-11 stsp
577 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
578 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
579 ff0d2220 2019-07-11 stsp ret="$?"
580 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
581 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
582 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
583 7d5807f4 2019-07-11 stsp return 1
584 ff0d2220 2019-07-11 stsp fi
585 7d5807f4 2019-07-11 stsp
586 7d5807f4 2019-07-11 stsp for cmd in update commit; do
587 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got $cmd > $testroot/stdout \
588 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
589 7d5807f4 2019-07-11 stsp
590 7d5807f4 2019-07-11 stsp echo -n > $testroot/stdout.expected
591 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
592 7d5807f4 2019-07-11 stsp ret="$?"
593 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
594 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
595 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
596 7d5807f4 2019-07-11 stsp return 1
597 7d5807f4 2019-07-11 stsp fi
598 7d5807f4 2019-07-11 stsp
599 7d5807f4 2019-07-11 stsp echo -n "got: a rebase operation is in progress in this " \
600 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
601 7d5807f4 2019-07-11 stsp echo "work tree and must be continued or aborted first" \
602 7d5807f4 2019-07-11 stsp >> $testroot/stderr.expected
603 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
604 7d5807f4 2019-07-11 stsp ret="$?"
605 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
606 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
607 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
608 7d5807f4 2019-07-11 stsp return 1
609 7d5807f4 2019-07-11 stsp fi
610 7d5807f4 2019-07-11 stsp done
611 64c6d990 2019-07-11 stsp
612 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
613 64c6d990 2019-07-11 stsp }
614 64c6d990 2019-07-11 stsp
615 64c6d990 2019-07-11 stsp function test_rebase_path_prefix {
616 64c6d990 2019-07-11 stsp local testroot=`test_init rebase_path_prefix`
617 64c6d990 2019-07-11 stsp
618 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
619 64c6d990 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
620 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
621 64c6d990 2019-07-11 stsp
622 64c6d990 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
623 64c6d990 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
624 64c6d990 2019-07-11 stsp
625 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
626 64c6d990 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
627 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
628 64c6d990 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
629 64c6d990 2019-07-11 stsp
630 64c6d990 2019-07-11 stsp got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
631 64c6d990 2019-07-11 stsp ret="$?"
632 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
633 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
634 64c6d990 2019-07-11 stsp return 1
635 64c6d990 2019-07-11 stsp fi
636 7d5807f4 2019-07-11 stsp
637 64c6d990 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch \
638 64c6d990 2019-07-11 stsp > $testroot/stdout 2> $testroot/stderr)
639 64c6d990 2019-07-11 stsp
640 64c6d990 2019-07-11 stsp echo -n > $testroot/stdout.expected
641 64c6d990 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
642 64c6d990 2019-07-11 stsp ret="$?"
643 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
644 64c6d990 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
645 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
646 64c6d990 2019-07-11 stsp return 1
647 64c6d990 2019-07-11 stsp fi
648 64c6d990 2019-07-11 stsp
649 64c6d990 2019-07-11 stsp echo -n "got: cannot rebase branch which contains changes outside " \
650 64c6d990 2019-07-11 stsp > $testroot/stderr.expected
651 64c6d990 2019-07-11 stsp echo "of this work tree's path prefix" >> $testroot/stderr.expected
652 787c8eb6 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
653 787c8eb6 2019-07-11 stsp ret="$?"
654 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
655 787c8eb6 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
656 787c8eb6 2019-07-11 stsp fi
657 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
658 787c8eb6 2019-07-11 stsp }
659 787c8eb6 2019-07-11 stsp
660 787c8eb6 2019-07-11 stsp function test_rebase_preserves_logmsg {
661 787c8eb6 2019-07-11 stsp local testroot=`test_init rebase_preserves_logmsg`
662 787c8eb6 2019-07-11 stsp
663 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
664 787c8eb6 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
665 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified delta on newbranch"
666 787c8eb6 2019-07-11 stsp
667 787c8eb6 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
668 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified alpha on newbranch"
669 787c8eb6 2019-07-11 stsp
670 787c8eb6 2019-07-11 stsp (cd $testroot/repo && got log -c newbranch -l2 | grep -v ^date: \
671 787c8eb6 2019-07-11 stsp > $testroot/log.expected)
672 787c8eb6 2019-07-11 stsp
673 787c8eb6 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
674 787c8eb6 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
675 787c8eb6 2019-07-11 stsp
676 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
677 787c8eb6 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
678 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
679 787c8eb6 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
680 787c8eb6 2019-07-11 stsp
681 787c8eb6 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
682 787c8eb6 2019-07-11 stsp ret="$?"
683 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
684 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
685 787c8eb6 2019-07-11 stsp return 1
686 787c8eb6 2019-07-11 stsp fi
687 787c8eb6 2019-07-11 stsp
688 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > /dev/null \
689 787c8eb6 2019-07-11 stsp 2> $testroot/stderr)
690 787c8eb6 2019-07-11 stsp
691 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
692 787c8eb6 2019-07-11 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
693 787c8eb6 2019-07-11 stsp local new_commit2=`git_show_head $testroot/repo`
694 787c8eb6 2019-07-11 stsp
695 787c8eb6 2019-07-11 stsp echo -n > $testroot/stderr.expected
696 64c6d990 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
697 64c6d990 2019-07-11 stsp ret="$?"
698 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
699 64c6d990 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
700 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
701 787c8eb6 2019-07-11 stsp return 1
702 64c6d990 2019-07-11 stsp fi
703 787c8eb6 2019-07-11 stsp
704 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got log -c newbranch -l2 | grep -v ^date: \
705 787c8eb6 2019-07-11 stsp > $testroot/log)
706 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit1/$new_commit1/" $testroot/log.expected
707 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit2/$new_commit2/" $testroot/log.expected
708 787c8eb6 2019-07-11 stsp cmp -s $testroot/log.expected $testroot/log
709 787c8eb6 2019-07-11 stsp ret="$?"
710 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
711 787c8eb6 2019-07-11 stsp diff -u $testroot/log.expected $testroot/log
712 787c8eb6 2019-07-11 stsp fi
713 787c8eb6 2019-07-11 stsp
714 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
715 ff0d2220 2019-07-11 stsp }
716 ff0d2220 2019-07-11 stsp
717 dcf44d04 2019-07-11 stsp run_test test_rebase_basic
718 dcf44d04 2019-07-11 stsp run_test test_rebase_ancestry_check
719 dcf44d04 2019-07-11 stsp run_test test_rebase_continue
720 dcf44d04 2019-07-11 stsp run_test test_rebase_abort
721 ff0d2220 2019-07-11 stsp run_test test_rebase_no_op_change
722 7d5807f4 2019-07-11 stsp run_test test_rebase_in_progress
723 64c6d990 2019-07-11 stsp run_test test_rebase_path_prefix
724 787c8eb6 2019-07-11 stsp run_test test_rebase_preserves_logmsg