3 5aa81393 2020-01-06 stsp # Copyright (c) 2019, 2020 Stefan Sperling <stsp@openbsd.org>
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.
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.
17 818c7501 2019-07-11 stsp . ./common.sh
19 818c7501 2019-07-11 stsp function test_rebase_basic {
20 818c7501 2019-07-11 stsp local testroot=`test_init rebase_basic`
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"
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"
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`
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`
40 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
42 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
43 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
47 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
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`
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`
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
72 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
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"
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
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"
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
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"
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"
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
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"
116 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
118 818c7501 2019-07-11 stsp echo -n > $testroot/stdout.expected
119 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
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"
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
133 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
134 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
136 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
139 818c7501 2019-07-11 stsp function test_rebase_ancestry_check {
140 818c7501 2019-07-11 stsp local testroot=`test_init rebase_ancestry_check`
142 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
144 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
145 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
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"
153 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
154 818c7501 2019-07-11 stsp 2> $testroot/stderr)
156 818c7501 2019-07-11 stsp echo -n > $testroot/stdout.expected
157 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
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"
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
171 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
172 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
174 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
177 818c7501 2019-07-11 stsp function test_rebase_continue {
178 818c7501 2019-07-11 stsp local testroot=`test_init rebase_continue`
179 f69721c3 2019-10-21 stsp local init_commit=`git_show_head $testroot/repo`
181 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
182 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
183 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
184 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
186 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
187 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
188 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
189 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
191 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
193 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
194 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
198 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
199 818c7501 2019-07-11 stsp 2> $testroot/stderr)
201 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
202 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
204 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
205 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
206 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
210 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
211 818c7501 2019-07-11 stsp > $testroot/stderr.expected
212 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
214 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
215 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
216 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
220 f69721c3 2019-10-21 stsp echo "<<<<<<< merged change: commit $orig_commit1" \
221 f69721c3 2019-10-21 stsp > $testroot/content.expected
222 818c7501 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
223 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
224 f69721c3 2019-10-21 stsp >> $testroot/content.expected
225 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
226 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
227 818c7501 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
228 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
229 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
230 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
232 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
233 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
234 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
238 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
240 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
241 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
243 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
244 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
245 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
249 818c7501 2019-07-11 stsp # resolve the conflict
250 818c7501 2019-07-11 stsp echo "modified alpha on branch and master" > $testroot/wt/alpha
252 f032f1f7 2019-08-04 stsp # test interaction of 'got stage' and rebase -c
253 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got stage alpha > /dev/null)
254 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout \
255 f032f1f7 2019-08-04 stsp 2> $testroot/stderr)
257 f032f1f7 2019-08-04 stsp if [ "$ret" == "0" ]; then
258 f032f1f7 2019-08-04 stsp echo "rebase succeeded unexpectedly" >&2
259 f032f1f7 2019-08-04 stsp test_done "$testroot" "1"
262 f032f1f7 2019-08-04 stsp echo -n "got: work tree contains files with staged changes; " \
263 f032f1f7 2019-08-04 stsp > $testroot/stderr.expected
264 f032f1f7 2019-08-04 stsp echo "these changes must be committed or unstaged first" \
265 f032f1f7 2019-08-04 stsp >> $testroot/stderr.expected
266 f032f1f7 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
268 f032f1f7 2019-08-04 stsp if [ "$ret" != "0" ]; then
269 f032f1f7 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
270 f032f1f7 2019-08-04 stsp test_done "$testroot" "$ret"
274 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got unstage alpha > /dev/null)
275 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
277 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
278 818c7501 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
280 818c7501 2019-07-11 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
281 818c7501 2019-07-11 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
283 818c7501 2019-07-11 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
284 818c7501 2019-07-11 stsp > $testroot/stdout.expected
285 818c7501 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
286 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
287 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
289 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
291 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
292 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
293 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
298 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
299 818c7501 2019-07-11 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
300 818c7501 2019-07-11 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
301 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
303 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
304 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
306 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
309 818c7501 2019-07-11 stsp function test_rebase_abort {
310 818c7501 2019-07-11 stsp local testroot=`test_init rebase_abort`
312 818c7501 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
314 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
315 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
316 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
317 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
319 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
320 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
321 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
322 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
324 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
326 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
327 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
331 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
332 818c7501 2019-07-11 stsp 2> $testroot/stderr)
334 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
335 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
337 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
338 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
339 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
343 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
344 818c7501 2019-07-11 stsp > $testroot/stderr.expected
345 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
347 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
348 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
349 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
353 f69721c3 2019-10-21 stsp echo "<<<<<<< merged change: commit $orig_commit1" \
354 f69721c3 2019-10-21 stsp > $testroot/content.expected
355 818c7501 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
356 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
357 f69721c3 2019-10-21 stsp >> $testroot/content.expected
358 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
359 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
360 818c7501 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
361 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
362 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
363 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
365 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
366 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
367 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
371 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
373 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
374 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
376 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
377 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
378 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
382 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -a > $testroot/stdout)
384 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
386 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/master" \
387 818c7501 2019-07-11 stsp > $testroot/stdout.expected
388 818c7501 2019-07-11 stsp echo 'R alpha' >> $testroot/stdout.expected
389 818c7501 2019-07-11 stsp echo "Rebase of refs/heads/newbranch aborted" \
390 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
392 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
394 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
395 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
396 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
400 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/content.expected
401 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
402 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
404 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
405 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
406 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
410 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l3 -c newbranch \
411 818c7501 2019-07-11 stsp | grep ^commit > $testroot/stdout)
412 818c7501 2019-07-11 stsp echo "commit $orig_commit1 (newbranch)" > $testroot/stdout.expected
413 818c7501 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
414 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
416 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
417 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
419 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
422 ff0d2220 2019-07-11 stsp function test_rebase_no_op_change {
423 ff0d2220 2019-07-11 stsp local testroot=`test_init rebase_no_op_change`
424 ff0d2220 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
426 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
427 ff0d2220 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
428 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
429 ff0d2220 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
431 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
432 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
433 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
434 ff0d2220 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
436 ff0d2220 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
438 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
439 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
443 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
444 ff0d2220 2019-07-11 stsp 2> $testroot/stderr)
446 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
447 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
449 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
450 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
451 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
455 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
456 ff0d2220 2019-07-11 stsp > $testroot/stderr.expected
457 ff0d2220 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
459 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
460 ff0d2220 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
461 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
465 f69721c3 2019-10-21 stsp echo "<<<<<<< merged change: commit $orig_commit1" \
466 f69721c3 2019-10-21 stsp > $testroot/content.expected
467 ff0d2220 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
468 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
469 f69721c3 2019-10-21 stsp >> $testroot/content.expected
470 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
471 ff0d2220 2019-07-11 stsp echo "=======" >> $testroot/content.expected
472 ff0d2220 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
473 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
474 ff0d2220 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
475 ff0d2220 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
477 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
478 ff0d2220 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
479 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
483 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
485 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
486 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
488 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
489 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
490 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
494 ff0d2220 2019-07-11 stsp # resolve the conflict
495 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/wt/alpha
497 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
499 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
500 ff0d2220 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
502 ff0d2220 2019-07-11 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
504 ff0d2220 2019-07-11 stsp echo -n "$short_orig_commit1 -> no-op change" \
505 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
506 ff0d2220 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
507 ff0d2220 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
508 ff0d2220 2019-07-11 stsp >> $testroot/stdout.expected
510 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
512 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
513 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
514 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
519 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
520 ff0d2220 2019-07-11 stsp echo "commit $master_commit (master, newbranch)" \
521 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
522 ff0d2220 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
523 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
525 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
526 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
528 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
531 7d5807f4 2019-07-11 stsp function test_rebase_in_progress {
532 4ba9c4f6 2019-07-11 stsp local testroot=`test_init rebase_in_progress`
533 7d5807f4 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
535 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
536 7d5807f4 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
537 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
538 7d5807f4 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
540 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
541 7d5807f4 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
542 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
543 7d5807f4 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
545 7d5807f4 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
547 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
548 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
552 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
553 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
555 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
556 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
558 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
559 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
560 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
564 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
565 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
566 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
568 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
569 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
570 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
574 f69721c3 2019-10-21 stsp echo "<<<<<<< merged change: commit $orig_commit1" \
575 f69721c3 2019-10-21 stsp > $testroot/content.expected
576 7d5807f4 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
577 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
578 f69721c3 2019-10-21 stsp >> $testroot/content.expected
579 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
580 7d5807f4 2019-07-11 stsp echo "=======" >> $testroot/content.expected
581 7d5807f4 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
582 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
583 7d5807f4 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
584 7d5807f4 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
586 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
587 7d5807f4 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
588 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
592 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
594 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
595 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
597 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
598 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
599 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
603 7d5807f4 2019-07-11 stsp for cmd in update commit; do
604 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got $cmd > $testroot/stdout \
605 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
607 7d5807f4 2019-07-11 stsp echo -n > $testroot/stdout.expected
608 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
610 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
611 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
612 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
616 7d5807f4 2019-07-11 stsp echo -n "got: a rebase operation is in progress in this " \
617 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
618 7d5807f4 2019-07-11 stsp echo "work tree and must be continued or aborted first" \
619 7d5807f4 2019-07-11 stsp >> $testroot/stderr.expected
620 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
622 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
623 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
624 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
629 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
632 64c6d990 2019-07-11 stsp function test_rebase_path_prefix {
633 64c6d990 2019-07-11 stsp local testroot=`test_init rebase_path_prefix`
635 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
636 64c6d990 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
637 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
639 64c6d990 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
640 64c6d990 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
642 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
643 64c6d990 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
644 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
645 64c6d990 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
647 64c6d990 2019-07-11 stsp got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
649 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
650 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
654 64c6d990 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch \
655 64c6d990 2019-07-11 stsp > $testroot/stdout 2> $testroot/stderr)
657 64c6d990 2019-07-11 stsp echo -n > $testroot/stdout.expected
658 64c6d990 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
660 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
661 64c6d990 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
662 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
666 64c6d990 2019-07-11 stsp echo -n "got: cannot rebase branch which contains changes outside " \
667 64c6d990 2019-07-11 stsp > $testroot/stderr.expected
668 64c6d990 2019-07-11 stsp echo "of this work tree's path prefix" >> $testroot/stderr.expected
669 787c8eb6 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
671 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
672 787c8eb6 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
674 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
677 787c8eb6 2019-07-11 stsp function test_rebase_preserves_logmsg {
678 787c8eb6 2019-07-11 stsp local testroot=`test_init rebase_preserves_logmsg`
680 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
681 787c8eb6 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
682 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified delta on newbranch"
684 787c8eb6 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
685 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified alpha on newbranch"
687 787c8eb6 2019-07-11 stsp (cd $testroot/repo && got log -c newbranch -l2 | grep -v ^date: \
688 787c8eb6 2019-07-11 stsp > $testroot/log.expected)
690 787c8eb6 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
691 787c8eb6 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
693 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
694 787c8eb6 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
695 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
696 787c8eb6 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
698 787c8eb6 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
700 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
701 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
705 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > /dev/null \
706 787c8eb6 2019-07-11 stsp 2> $testroot/stderr)
708 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
709 787c8eb6 2019-07-11 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
710 787c8eb6 2019-07-11 stsp local new_commit2=`git_show_head $testroot/repo`
712 787c8eb6 2019-07-11 stsp echo -n > $testroot/stderr.expected
713 64c6d990 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
715 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
716 64c6d990 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
717 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
721 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got log -c newbranch -l2 | grep -v ^date: \
722 787c8eb6 2019-07-11 stsp > $testroot/log)
723 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit1/$new_commit1/" $testroot/log.expected
724 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit2/$new_commit2/" $testroot/log.expected
725 787c8eb6 2019-07-11 stsp cmp -s $testroot/log.expected $testroot/log
727 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
728 787c8eb6 2019-07-11 stsp diff -u $testroot/log.expected $testroot/log
731 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
734 fc66b545 2019-08-12 stsp function test_rebase_no_commits_to_rebase {
735 fc66b545 2019-08-12 stsp local testroot=`test_init rebase_no_commits_to_rebase`
737 fc66b545 2019-08-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
739 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
740 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
744 fc66b545 2019-08-12 stsp (cd $testroot/wt && got branch newbranch)
746 fc66b545 2019-08-12 stsp echo "modified alpha on master" > $testroot/wt/alpha
747 fc66b545 2019-08-12 stsp (cd $testroot/wt && got commit -m 'test rebase_no_commits_to_rebase' \
748 fc66b545 2019-08-12 stsp > /dev/null)
749 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > /dev/null)
751 fc66b545 2019-08-12 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
752 fc66b545 2019-08-12 stsp 2> $testroot/stderr)
754 fc66b545 2019-08-12 stsp echo "got: no commits to rebase" > $testroot/stderr.expected
755 fc66b545 2019-08-12 stsp cmp -s $testroot/stderr.expected $testroot/stderr
757 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
758 fc66b545 2019-08-12 stsp diff -u $testroot/stderr.expected $testroot/stderr
759 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
763 fc66b545 2019-08-12 stsp echo "Rebase of refs/heads/newbranch aborted" \
764 fc66b545 2019-08-12 stsp > $testroot/stdout.expected
765 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
767 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
768 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
769 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
773 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
774 fc66b545 2019-08-12 stsp echo "Already up-to-date" > $testroot/stdout.expected
775 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
777 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
778 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
780 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
783 38b0338b 2019-11-29 stsp function test_rebase_forward {
784 38b0338b 2019-11-29 stsp local testroot=`test_init rebase_forward`
785 38b0338b 2019-11-29 stsp local commit0=`git_show_head $testroot/repo`
787 38b0338b 2019-11-29 stsp got checkout $testroot/repo $testroot/wt > /dev/null
789 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
790 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
794 38b0338b 2019-11-29 stsp echo "change alpha 1" > $testroot/wt/alpha
795 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
796 38b0338b 2019-11-29 stsp > /dev/null)
797 38b0338b 2019-11-29 stsp local commit1=`git_show_head $testroot/repo`
799 38b0338b 2019-11-29 stsp echo "change alpha 2" > $testroot/wt/alpha
800 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
801 38b0338b 2019-11-29 stsp > /dev/null)
802 38b0338b 2019-11-29 stsp local commit2=`git_show_head $testroot/repo`
804 38b0338b 2019-11-29 stsp # Simulate a situation where fast-forward is required.
805 38b0338b 2019-11-29 stsp # We want to fast-forward master to origin/master:
806 38b0338b 2019-11-29 stsp # commit 3907e11dceaae2ca7f8db79c2af31794673945ad (origin/master)
807 38b0338b 2019-11-29 stsp # commit ffcffcd102cf1af6572fbdbb4cf07a0f1fd2d840 (master)
808 38b0338b 2019-11-29 stsp # commit 87a6a8a2263a15b61c016ff1720b24741d455eb5
809 38b0338b 2019-11-29 stsp (cd $testroot/repo && got ref -d master)
810 38b0338b 2019-11-29 stsp (cd $testroot/repo && got ref refs/heads/master $commit1)
811 38b0338b 2019-11-29 stsp (cd $testroot/repo && got ref refs/remotes/origin/master $commit2)
814 38b0338b 2019-11-29 stsp (cd $testroot/wt && got up -b origin/master > /dev/null)
816 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase master \
817 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
819 38b0338b 2019-11-29 stsp echo "Forwarding refs/heads/master to commit $commit2" \
820 38b0338b 2019-11-29 stsp > $testroot/stdout.expected
821 38b0338b 2019-11-29 stsp echo "Switching work tree to refs/heads/master" \
822 38b0338b 2019-11-29 stsp >> $testroot/stdout.expected
823 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
825 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
826 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
827 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
831 38b0338b 2019-11-29 stsp # Ensure that rebase operation was completed correctly
832 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase -a \
833 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
834 38b0338b 2019-11-29 stsp echo -n "" > $testroot/stdout.expected
835 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
837 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
838 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
839 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
842 38b0338b 2019-11-29 stsp echo "got: rebase operation not in progress" > $testroot/stderr.expected
843 38b0338b 2019-11-29 stsp cmp -s $testroot/stderr.expected $testroot/stderr
845 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
846 38b0338b 2019-11-29 stsp diff -u $testroot/stderr.expected $testroot/stderr
847 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
851 38b0338b 2019-11-29 stsp (cd $testroot/wt && got branch > $testroot/stdout)
852 38b0338b 2019-11-29 stsp echo "master" > $testroot/stdout.expected
853 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
855 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
856 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
857 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
861 38b0338b 2019-11-29 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
862 38b0338b 2019-11-29 stsp echo "commit $commit2 (master, origin/master)" > $testroot/stdout.expected
863 38b0338b 2019-11-29 stsp echo "commit $commit1" >> $testroot/stdout.expected
864 38b0338b 2019-11-29 stsp echo "commit $commit0" >> $testroot/stdout.expected
865 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
867 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
868 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
870 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
873 e51d7b55 2020-01-04 stsp function test_rebase_out_of_date {
874 e51d7b55 2020-01-04 stsp local testroot=`test_init rebase_out_of_date`
875 e51d7b55 2020-01-04 stsp local initial_commit=`git_show_head $testroot/repo`
877 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q -b newbranch)
878 e51d7b55 2020-01-04 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
879 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
881 e51d7b55 2020-01-04 stsp echo "modified alpha on branch" > $testroot/repo/alpha
882 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git rm -q beta)
883 e51d7b55 2020-01-04 stsp echo "new file on branch" > $testroot/repo/epsilon/new
884 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git add epsilon/new)
885 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
887 e51d7b55 2020-01-04 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
888 e51d7b55 2020-01-04 stsp local orig_commit2=`git_show_head $testroot/repo`
890 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
891 e51d7b55 2020-01-04 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
892 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to zeta on master"
893 e51d7b55 2020-01-04 stsp local master_commit1=`git_show_head $testroot/repo`
895 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
896 e51d7b55 2020-01-04 stsp echo "modified beta on master" > $testroot/repo/beta
897 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to beta on master"
898 e51d7b55 2020-01-04 stsp local master_commit2=`git_show_head $testroot/repo`
900 e51d7b55 2020-01-04 stsp got checkout -c $master_commit1 $testroot/repo $testroot/wt \
901 e51d7b55 2020-01-04 stsp > /dev/null
903 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
904 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
908 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
909 e51d7b55 2020-01-04 stsp 2> $testroot/stderr)
911 e51d7b55 2020-01-04 stsp echo -n > $testroot/stdout.expected
912 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
914 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
915 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
916 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
920 e51d7b55 2020-01-04 stsp echo -n "got: work tree must be updated before it can be " \
921 e51d7b55 2020-01-04 stsp > $testroot/stderr.expected
922 e51d7b55 2020-01-04 stsp echo "used to rebase a branch" >> $testroot/stderr.expected
923 e51d7b55 2020-01-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
925 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
926 e51d7b55 2020-01-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
927 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
931 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
932 e51d7b55 2020-01-04 stsp echo "commit $master_commit2 (master)" > $testroot/stdout.expected
933 e51d7b55 2020-01-04 stsp echo "commit $master_commit1" >> $testroot/stdout.expected
934 e51d7b55 2020-01-04 stsp echo "commit $initial_commit" >> $testroot/stdout.expected
935 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
937 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
938 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
940 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
943 dcf44d04 2019-07-11 stsp run_test test_rebase_basic
944 dcf44d04 2019-07-11 stsp run_test test_rebase_ancestry_check
945 dcf44d04 2019-07-11 stsp run_test test_rebase_continue
946 dcf44d04 2019-07-11 stsp run_test test_rebase_abort
947 ff0d2220 2019-07-11 stsp run_test test_rebase_no_op_change
948 7d5807f4 2019-07-11 stsp run_test test_rebase_in_progress
949 64c6d990 2019-07-11 stsp run_test test_rebase_path_prefix
950 787c8eb6 2019-07-11 stsp run_test test_rebase_preserves_logmsg
951 fc66b545 2019-08-12 stsp run_test test_rebase_no_commits_to_rebase
952 38b0338b 2019-11-29 stsp run_test test_rebase_forward
953 e51d7b55 2020-01-04 stsp run_test test_rebase_out_of_date