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 f6cae3ed 2020-09-13 naddy 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 f6cae3ed 2020-09-13 naddy 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 f6cae3ed 2020-09-13 naddy 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`
185 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
187 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
188 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
189 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
190 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
192 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
194 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
195 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
199 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
200 818c7501 2019-07-11 stsp 2> $testroot/stderr)
202 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
203 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
204 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
205 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
206 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
207 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
209 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
210 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
211 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
215 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
216 818c7501 2019-07-11 stsp > $testroot/stderr.expected
217 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
219 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
220 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
221 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
225 f69721c3 2019-10-21 stsp echo "<<<<<<< merged change: commit $orig_commit1" \
226 f69721c3 2019-10-21 stsp > $testroot/content.expected
227 818c7501 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
228 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
229 f69721c3 2019-10-21 stsp >> $testroot/content.expected
230 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
231 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
232 818c7501 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
233 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
234 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
235 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
237 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
238 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
239 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
243 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
245 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
246 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
248 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
249 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
250 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
254 818c7501 2019-07-11 stsp # resolve the conflict
255 818c7501 2019-07-11 stsp echo "modified alpha on branch and master" > $testroot/wt/alpha
257 f032f1f7 2019-08-04 stsp # test interaction of 'got stage' and rebase -c
258 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got stage alpha > /dev/null)
259 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout \
260 f032f1f7 2019-08-04 stsp 2> $testroot/stderr)
262 f032f1f7 2019-08-04 stsp if [ "$ret" == "0" ]; then
263 f032f1f7 2019-08-04 stsp echo "rebase succeeded unexpectedly" >&2
264 f032f1f7 2019-08-04 stsp test_done "$testroot" "1"
267 f032f1f7 2019-08-04 stsp echo -n "got: work tree contains files with staged changes; " \
268 f032f1f7 2019-08-04 stsp > $testroot/stderr.expected
269 f032f1f7 2019-08-04 stsp echo "these changes must be committed or unstaged first" \
270 f032f1f7 2019-08-04 stsp >> $testroot/stderr.expected
271 f032f1f7 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
273 f032f1f7 2019-08-04 stsp if [ "$ret" != "0" ]; then
274 f032f1f7 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
275 f032f1f7 2019-08-04 stsp test_done "$testroot" "$ret"
279 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got unstage alpha > /dev/null)
280 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
282 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
283 818c7501 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
284 818c7501 2019-07-11 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
286 818c7501 2019-07-11 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
287 818c7501 2019-07-11 stsp > $testroot/stdout.expected
288 818c7501 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
289 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
290 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
292 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
294 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
295 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
296 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
301 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
302 818c7501 2019-07-11 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
303 818c7501 2019-07-11 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
304 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
306 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
307 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
309 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
312 f6cae3ed 2020-09-13 naddy test_rebase_abort() {
313 818c7501 2019-07-11 stsp local testroot=`test_init rebase_abort`
315 818c7501 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
317 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
318 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
319 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
320 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
321 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
323 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
324 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
325 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
326 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
328 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
330 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
331 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
335 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
336 818c7501 2019-07-11 stsp 2> $testroot/stderr)
338 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
339 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
340 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
341 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
342 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
343 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
345 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
346 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
347 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
351 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
352 818c7501 2019-07-11 stsp > $testroot/stderr.expected
353 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
355 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
356 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
357 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
361 f69721c3 2019-10-21 stsp echo "<<<<<<< merged change: commit $orig_commit1" \
362 f69721c3 2019-10-21 stsp > $testroot/content.expected
363 818c7501 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
364 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
365 f69721c3 2019-10-21 stsp >> $testroot/content.expected
366 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
367 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
368 818c7501 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
369 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
370 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
371 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
373 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
374 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
375 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
379 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
381 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
382 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
384 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
385 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
386 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
390 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -a > $testroot/stdout)
392 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
394 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/master" \
395 818c7501 2019-07-11 stsp > $testroot/stdout.expected
396 818c7501 2019-07-11 stsp echo 'R alpha' >> $testroot/stdout.expected
397 818c7501 2019-07-11 stsp echo "Rebase of refs/heads/newbranch aborted" \
398 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
400 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
402 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
403 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
404 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
408 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/content.expected
409 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
410 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
412 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
413 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
414 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
418 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l3 -c newbranch \
419 818c7501 2019-07-11 stsp | grep ^commit > $testroot/stdout)
420 818c7501 2019-07-11 stsp echo "commit $orig_commit1 (newbranch)" > $testroot/stdout.expected
421 818c7501 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
422 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
424 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
425 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
427 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
430 f6cae3ed 2020-09-13 naddy test_rebase_no_op_change() {
431 ff0d2220 2019-07-11 stsp local testroot=`test_init rebase_no_op_change`
432 ff0d2220 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
434 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
435 ff0d2220 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
436 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
437 ff0d2220 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
438 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
440 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
441 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
442 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
443 ff0d2220 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
445 ff0d2220 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
447 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
448 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
452 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
453 ff0d2220 2019-07-11 stsp 2> $testroot/stderr)
455 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
456 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
457 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
458 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
459 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
460 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
462 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
463 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
464 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
468 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
469 ff0d2220 2019-07-11 stsp > $testroot/stderr.expected
470 ff0d2220 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
472 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
473 ff0d2220 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
474 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
478 f69721c3 2019-10-21 stsp echo "<<<<<<< merged change: commit $orig_commit1" \
479 f69721c3 2019-10-21 stsp > $testroot/content.expected
480 ff0d2220 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
481 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
482 f69721c3 2019-10-21 stsp >> $testroot/content.expected
483 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
484 ff0d2220 2019-07-11 stsp echo "=======" >> $testroot/content.expected
485 ff0d2220 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
486 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
487 ff0d2220 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
488 ff0d2220 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
490 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
491 ff0d2220 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
492 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
496 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
498 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
499 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
501 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
502 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
503 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
507 ff0d2220 2019-07-11 stsp # resolve the conflict
508 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/wt/alpha
510 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
512 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
513 ff0d2220 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
515 ff0d2220 2019-07-11 stsp echo -n "$short_orig_commit1 -> no-op change" \
516 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
517 ff0d2220 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
518 ff0d2220 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
519 ff0d2220 2019-07-11 stsp >> $testroot/stdout.expected
521 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
523 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
524 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
525 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
530 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
531 ff0d2220 2019-07-11 stsp echo "commit $master_commit (master, newbranch)" \
532 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
533 ff0d2220 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
534 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
536 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
537 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
539 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
542 f6cae3ed 2020-09-13 naddy test_rebase_in_progress() {
543 4ba9c4f6 2019-07-11 stsp local testroot=`test_init rebase_in_progress`
544 7d5807f4 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
546 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
547 7d5807f4 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
548 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
549 7d5807f4 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
550 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
552 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
553 7d5807f4 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
554 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
555 7d5807f4 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
557 7d5807f4 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
559 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
560 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
564 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
565 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
567 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
568 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
569 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
570 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
571 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
572 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
574 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
575 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
576 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
580 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
581 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
582 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
584 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
585 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
586 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
590 f69721c3 2019-10-21 stsp echo "<<<<<<< merged change: commit $orig_commit1" \
591 f69721c3 2019-10-21 stsp > $testroot/content.expected
592 7d5807f4 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
593 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
594 f69721c3 2019-10-21 stsp >> $testroot/content.expected
595 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
596 7d5807f4 2019-07-11 stsp echo "=======" >> $testroot/content.expected
597 7d5807f4 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
598 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
599 7d5807f4 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
600 7d5807f4 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
602 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
603 7d5807f4 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
604 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
608 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
610 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
611 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
613 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
614 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
615 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
619 7d5807f4 2019-07-11 stsp for cmd in update commit; do
620 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got $cmd > $testroot/stdout \
621 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
623 7d5807f4 2019-07-11 stsp echo -n > $testroot/stdout.expected
624 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
626 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
627 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
628 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
632 7d5807f4 2019-07-11 stsp echo -n "got: a rebase operation is in progress in this " \
633 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
634 7d5807f4 2019-07-11 stsp echo "work tree and must be continued or aborted first" \
635 7d5807f4 2019-07-11 stsp >> $testroot/stderr.expected
636 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
638 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
639 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
640 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
645 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
648 f6cae3ed 2020-09-13 naddy test_rebase_path_prefix() {
649 64c6d990 2019-07-11 stsp local testroot=`test_init rebase_path_prefix`
651 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
652 64c6d990 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
653 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
655 64c6d990 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
656 64c6d990 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
658 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
659 64c6d990 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
660 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
661 64c6d990 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
663 64c6d990 2019-07-11 stsp got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
665 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
666 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
670 64c6d990 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch \
671 64c6d990 2019-07-11 stsp > $testroot/stdout 2> $testroot/stderr)
673 64c6d990 2019-07-11 stsp echo -n > $testroot/stdout.expected
674 64c6d990 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
676 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
677 64c6d990 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
678 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
682 64c6d990 2019-07-11 stsp echo -n "got: cannot rebase branch which contains changes outside " \
683 64c6d990 2019-07-11 stsp > $testroot/stderr.expected
684 64c6d990 2019-07-11 stsp echo "of this work tree's path prefix" >> $testroot/stderr.expected
685 787c8eb6 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
687 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
688 787c8eb6 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
690 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
693 f6cae3ed 2020-09-13 naddy test_rebase_preserves_logmsg() {
694 787c8eb6 2019-07-11 stsp local testroot=`test_init rebase_preserves_logmsg`
696 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
697 787c8eb6 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
698 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified delta on newbranch"
700 787c8eb6 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
701 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified alpha on newbranch"
703 787c8eb6 2019-07-11 stsp (cd $testroot/repo && got log -c newbranch -l2 | grep -v ^date: \
704 787c8eb6 2019-07-11 stsp > $testroot/log.expected)
706 787c8eb6 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
707 787c8eb6 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
709 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
710 787c8eb6 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
711 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
712 787c8eb6 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
714 787c8eb6 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
716 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
717 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
721 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > /dev/null \
722 787c8eb6 2019-07-11 stsp 2> $testroot/stderr)
724 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
725 787c8eb6 2019-07-11 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
726 787c8eb6 2019-07-11 stsp local new_commit2=`git_show_head $testroot/repo`
728 787c8eb6 2019-07-11 stsp echo -n > $testroot/stderr.expected
729 64c6d990 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
731 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
732 64c6d990 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
733 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
737 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got log -c newbranch -l2 | grep -v ^date: \
738 787c8eb6 2019-07-11 stsp > $testroot/log)
739 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit1/$new_commit1/" $testroot/log.expected
740 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit2/$new_commit2/" $testroot/log.expected
741 787c8eb6 2019-07-11 stsp cmp -s $testroot/log.expected $testroot/log
743 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
744 787c8eb6 2019-07-11 stsp diff -u $testroot/log.expected $testroot/log
747 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
750 f6cae3ed 2020-09-13 naddy test_rebase_no_commits_to_rebase() {
751 fc66b545 2019-08-12 stsp local testroot=`test_init rebase_no_commits_to_rebase`
753 fc66b545 2019-08-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
755 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
756 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
760 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n newbranch)
762 fc66b545 2019-08-12 stsp echo "modified alpha on master" > $testroot/wt/alpha
763 fc66b545 2019-08-12 stsp (cd $testroot/wt && got commit -m 'test rebase_no_commits_to_rebase' \
764 fc66b545 2019-08-12 stsp > /dev/null)
765 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > /dev/null)
767 fc66b545 2019-08-12 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
768 fc66b545 2019-08-12 stsp 2> $testroot/stderr)
770 fc66b545 2019-08-12 stsp echo "got: no commits to rebase" > $testroot/stderr.expected
771 fc66b545 2019-08-12 stsp cmp -s $testroot/stderr.expected $testroot/stderr
773 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
774 fc66b545 2019-08-12 stsp diff -u $testroot/stderr.expected $testroot/stderr
775 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
779 fc66b545 2019-08-12 stsp echo "Rebase of refs/heads/newbranch aborted" \
780 fc66b545 2019-08-12 stsp > $testroot/stdout.expected
781 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
783 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
784 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
785 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
789 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
790 fc66b545 2019-08-12 stsp echo "Already up-to-date" > $testroot/stdout.expected
791 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
793 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
794 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
796 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
799 f6cae3ed 2020-09-13 naddy test_rebase_forward() {
800 38b0338b 2019-11-29 stsp local testroot=`test_init rebase_forward`
801 38b0338b 2019-11-29 stsp local commit0=`git_show_head $testroot/repo`
803 38b0338b 2019-11-29 stsp got checkout $testroot/repo $testroot/wt > /dev/null
805 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
806 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
810 38b0338b 2019-11-29 stsp echo "change alpha 1" > $testroot/wt/alpha
811 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
812 38b0338b 2019-11-29 stsp > /dev/null)
813 38b0338b 2019-11-29 stsp local commit1=`git_show_head $testroot/repo`
815 38b0338b 2019-11-29 stsp echo "change alpha 2" > $testroot/wt/alpha
816 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
817 38b0338b 2019-11-29 stsp > /dev/null)
818 38b0338b 2019-11-29 stsp local commit2=`git_show_head $testroot/repo`
820 38b0338b 2019-11-29 stsp # Simulate a situation where fast-forward is required.
821 38b0338b 2019-11-29 stsp # We want to fast-forward master to origin/master:
822 38b0338b 2019-11-29 stsp # commit 3907e11dceaae2ca7f8db79c2af31794673945ad (origin/master)
823 38b0338b 2019-11-29 stsp # commit ffcffcd102cf1af6572fbdbb4cf07a0f1fd2d840 (master)
824 38b0338b 2019-11-29 stsp # commit 87a6a8a2263a15b61c016ff1720b24741d455eb5
825 38b0338b 2019-11-29 stsp (cd $testroot/repo && got ref -d master)
826 e31abbf2 2020-03-22 stsp (cd $testroot/repo && got ref -c $commit1 refs/heads/master)
827 e31abbf2 2020-03-22 stsp (cd $testroot/repo && got ref -c $commit2 refs/remotes/origin/master)
829 38b0338b 2019-11-29 stsp (cd $testroot/wt && got up -b origin/master > /dev/null)
831 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase master \
832 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
834 38b0338b 2019-11-29 stsp echo "Forwarding refs/heads/master to commit $commit2" \
835 38b0338b 2019-11-29 stsp > $testroot/stdout.expected
836 38b0338b 2019-11-29 stsp echo "Switching work tree to refs/heads/master" \
837 38b0338b 2019-11-29 stsp >> $testroot/stdout.expected
838 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
840 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
841 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
842 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
846 38b0338b 2019-11-29 stsp # Ensure that rebase operation was completed correctly
847 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase -a \
848 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
849 38b0338b 2019-11-29 stsp echo -n "" > $testroot/stdout.expected
850 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
852 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
853 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
854 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
857 38b0338b 2019-11-29 stsp echo "got: rebase operation not in progress" > $testroot/stderr.expected
858 38b0338b 2019-11-29 stsp cmp -s $testroot/stderr.expected $testroot/stderr
860 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
861 38b0338b 2019-11-29 stsp diff -u $testroot/stderr.expected $testroot/stderr
862 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
866 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n > $testroot/stdout)
867 38b0338b 2019-11-29 stsp echo "master" > $testroot/stdout.expected
868 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
870 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
871 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
872 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
876 38b0338b 2019-11-29 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
877 38b0338b 2019-11-29 stsp echo "commit $commit2 (master, origin/master)" > $testroot/stdout.expected
878 38b0338b 2019-11-29 stsp echo "commit $commit1" >> $testroot/stdout.expected
879 38b0338b 2019-11-29 stsp echo "commit $commit0" >> $testroot/stdout.expected
880 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
882 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
883 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
885 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
888 f6cae3ed 2020-09-13 naddy test_rebase_out_of_date() {
889 e51d7b55 2020-01-04 stsp local testroot=`test_init rebase_out_of_date`
890 e51d7b55 2020-01-04 stsp local initial_commit=`git_show_head $testroot/repo`
892 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q -b newbranch)
893 e51d7b55 2020-01-04 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
894 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
896 e51d7b55 2020-01-04 stsp echo "modified alpha on branch" > $testroot/repo/alpha
897 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git rm -q beta)
898 e51d7b55 2020-01-04 stsp echo "new file on branch" > $testroot/repo/epsilon/new
899 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git add epsilon/new)
900 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
902 e51d7b55 2020-01-04 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
903 e51d7b55 2020-01-04 stsp local orig_commit2=`git_show_head $testroot/repo`
905 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
906 e51d7b55 2020-01-04 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
907 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to zeta on master"
908 e51d7b55 2020-01-04 stsp local master_commit1=`git_show_head $testroot/repo`
910 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
911 e51d7b55 2020-01-04 stsp echo "modified beta on master" > $testroot/repo/beta
912 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to beta on master"
913 e51d7b55 2020-01-04 stsp local master_commit2=`git_show_head $testroot/repo`
915 e51d7b55 2020-01-04 stsp got checkout -c $master_commit1 $testroot/repo $testroot/wt \
916 e51d7b55 2020-01-04 stsp > /dev/null
918 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
919 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
923 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
924 e51d7b55 2020-01-04 stsp 2> $testroot/stderr)
926 e51d7b55 2020-01-04 stsp echo -n > $testroot/stdout.expected
927 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
929 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
930 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
931 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
935 e51d7b55 2020-01-04 stsp echo -n "got: work tree must be updated before it can be " \
936 e51d7b55 2020-01-04 stsp > $testroot/stderr.expected
937 e51d7b55 2020-01-04 stsp echo "used to rebase a branch" >> $testroot/stderr.expected
938 e51d7b55 2020-01-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
940 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
941 e51d7b55 2020-01-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
942 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
946 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
947 e51d7b55 2020-01-04 stsp echo "commit $master_commit2 (master)" > $testroot/stdout.expected
948 e51d7b55 2020-01-04 stsp echo "commit $master_commit1" >> $testroot/stdout.expected
949 e51d7b55 2020-01-04 stsp echo "commit $initial_commit" >> $testroot/stdout.expected
950 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
952 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
953 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
955 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
958 f6cae3ed 2020-09-13 naddy test_rebase_trims_empty_dir() {
959 1ae0a341 2020-02-14 stsp local testroot=`test_init rebase_trims_empty_dir`
961 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
962 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
963 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
965 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git rm -q epsilon/zeta)
966 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "removing zeta on newbranch"
968 1ae0a341 2020-02-14 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
969 1ae0a341 2020-02-14 stsp local orig_commit2=`git_show_head $testroot/repo`
971 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q master)
972 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/repo/alpha
973 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to alpha on master"
974 1ae0a341 2020-02-14 stsp local master_commit=`git_show_head $testroot/repo`
976 1ae0a341 2020-02-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
978 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
979 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
983 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
985 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q newbranch)
986 1ae0a341 2020-02-14 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
987 1ae0a341 2020-02-14 stsp local new_commit2=`git_show_head $testroot/repo`
989 1ae0a341 2020-02-14 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
990 1ae0a341 2020-02-14 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
991 1ae0a341 2020-02-14 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
992 1ae0a341 2020-02-14 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
994 1ae0a341 2020-02-14 stsp echo "G gamma/delta" >> $testroot/stdout.expected
995 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
996 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
997 1ae0a341 2020-02-14 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
998 1ae0a341 2020-02-14 stsp echo "D epsilon/zeta" >> $testroot/stdout.expected
999 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1000 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1001 1ae0a341 2020-02-14 stsp echo ": removing zeta on newbranch" \
1002 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1003 1ae0a341 2020-02-14 stsp echo "Switching work tree to refs/heads/newbranch" \
1004 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1006 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1008 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
1009 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
1010 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1014 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/content.expected
1015 1ae0a341 2020-02-14 stsp cat $testroot/wt/gamma/delta > $testroot/content
1016 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1018 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1019 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1020 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1024 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/content.expected
1025 1ae0a341 2020-02-14 stsp cat $testroot/wt/alpha > $testroot/content
1026 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1028 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1029 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1030 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1034 1ae0a341 2020-02-14 stsp if [ -e $testroot/wt/epsilon ]; then
1035 1ae0a341 2020-02-14 stsp echo "parent of removed zeta still exists on disk" >&2
1036 1ae0a341 2020-02-14 stsp test_done "$testroot" "1"
1040 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got status > $testroot/stdout)
1042 1ae0a341 2020-02-14 stsp echo -n > $testroot/stdout.expected
1043 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1045 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1046 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1047 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1051 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1052 1ae0a341 2020-02-14 stsp echo "commit $new_commit2 (newbranch)" > $testroot/stdout.expected
1053 1ae0a341 2020-02-14 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1054 1ae0a341 2020-02-14 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1055 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1057 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1058 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1060 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1063 f6cae3ed 2020-09-13 naddy test_rebase_delete_missing_file() {
1064 ca6da77d 2020-03-22 stsp local testroot=`test_init rebase_delete_missing_file`
1066 ca6da77d 2020-03-22 stsp mkdir -p $testroot/repo/d/f/g
1067 ca6da77d 2020-03-22 stsp echo "new file" > $testroot/repo/d/f/g/new
1068 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git add d/f/g/new)
1069 ca6da77d 2020-03-22 stsp git_commit $testroot/repo -m "adding a subdir"
1070 ca6da77d 2020-03-22 stsp local commit0=`git_show_head $testroot/repo`
1072 a740a1b3 2020-03-22 stsp got br -r $testroot/repo -c master newbranch
1074 a740a1b3 2020-03-22 stsp got checkout -b newbranch $testroot/repo $testroot/wt > /dev/null
1076 a740a1b3 2020-03-22 stsp echo "modified delta on branch" > $testroot/wt/gamma/delta
1077 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1078 a740a1b3 2020-03-22 stsp -m "committing to delta on newbranch" > /dev/null)
1080 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1081 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1082 a740a1b3 2020-03-22 stsp -m "removing beta and d/f/g/new on newbranch" > /dev/null)
1084 a740a1b3 2020-03-22 stsp (cd $testroot/repo && git checkout -q newbranch)
1085 ca6da77d 2020-03-22 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1086 ca6da77d 2020-03-22 stsp local orig_commit2=`git_show_head $testroot/repo`
1088 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got update -b master > /dev/null)
1089 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1090 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1091 a740a1b3 2020-03-22 stsp -m "removing beta and d/f/g/new on master" > /dev/null)
1093 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git checkout -q master)
1094 ca6da77d 2020-03-22 stsp local master_commit=`git_show_head $testroot/repo`
1096 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got update -b master > /dev/null)
1097 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1099 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git checkout -q newbranch)
1100 ca6da77d 2020-03-22 stsp local new_commit1=`git_show_head $testroot/repo`
1102 ca6da77d 2020-03-22 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1103 ca6da77d 2020-03-22 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1104 ca6da77d 2020-03-22 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1106 ca6da77d 2020-03-22 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1107 ca6da77d 2020-03-22 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1108 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1109 ca6da77d 2020-03-22 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1110 ca6da77d 2020-03-22 stsp echo "! beta" >> $testroot/stdout.expected
1111 ca6da77d 2020-03-22 stsp echo "! d/f/g/new" >> $testroot/stdout.expected
1112 ca6da77d 2020-03-22 stsp echo -n "$short_orig_commit2 -> no-op change" \
1113 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1114 a740a1b3 2020-03-22 stsp echo ": removing beta and d/f/g/new on newbranch" \
1115 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1116 ca6da77d 2020-03-22 stsp echo "Switching work tree to refs/heads/newbranch" \
1117 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1119 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1121 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1122 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1123 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1127 ca6da77d 2020-03-22 stsp echo "modified delta on branch" > $testroot/content.expected
1128 ca6da77d 2020-03-22 stsp cat $testroot/wt/gamma/delta > $testroot/content
1129 ca6da77d 2020-03-22 stsp cmp -s $testroot/content.expected $testroot/content
1131 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1132 ca6da77d 2020-03-22 stsp diff -u $testroot/content.expected $testroot/content
1133 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1137 ca6da77d 2020-03-22 stsp if [ -e $testroot/wt/beta ]; then
1138 ca6da77d 2020-03-22 stsp echo "removed file beta still exists on disk" >&2
1139 ca6da77d 2020-03-22 stsp test_done "$testroot" "1"
1143 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got status > $testroot/stdout)
1145 ca6da77d 2020-03-22 stsp echo -n > $testroot/stdout.expected
1146 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1148 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1149 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1150 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1154 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1155 ca6da77d 2020-03-22 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
1156 ca6da77d 2020-03-22 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1157 ca6da77d 2020-03-22 stsp echo "commit $commit0" >> $testroot/stdout.expected
1158 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1160 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1161 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1163 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1166 f6cae3ed 2020-09-13 naddy test_rebase_rm_add_rm_file() {
1167 70551d57 2020-04-24 stsp local testroot=`test_init rebase_rm_add_rm_file`
1169 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1170 70551d57 2020-04-24 stsp (cd $testroot/repo && git rm -q beta)
1171 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "removing beta from newbranch"
1172 70551d57 2020-04-24 stsp local orig_commit1=`git_show_head $testroot/repo`
1174 70551d57 2020-04-24 stsp echo 'restored beta' > $testroot/repo/beta
1175 70551d57 2020-04-24 stsp (cd $testroot/repo && git add beta)
1176 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "restoring beta on newbranch"
1177 70551d57 2020-04-24 stsp local orig_commit2=`git_show_head $testroot/repo`
1179 70551d57 2020-04-24 stsp (cd $testroot/repo && git rm -q beta)
1180 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "removing beta from newbranch again"
1181 70551d57 2020-04-24 stsp local orig_commit3=`git_show_head $testroot/repo`
1183 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q master)
1184 70551d57 2020-04-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1185 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
1186 70551d57 2020-04-24 stsp local master_commit=`git_show_head $testroot/repo`
1188 70551d57 2020-04-24 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1190 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1191 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1195 70551d57 2020-04-24 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1197 70551d57 2020-04-24 stsp # this would error out with 'got: file index is corrupt'
1198 70551d57 2020-04-24 stsp (cd $testroot/wt && got status > /dev/null)
1200 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1201 70551d57 2020-04-24 stsp echo "got status command failed unexpectedly" >&2
1202 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1206 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q newbranch)
1207 70551d57 2020-04-24 stsp local new_commit3=`git_show_head $testroot/repo`
1208 70551d57 2020-04-24 stsp local new_commit2=`git_show_parent_commit $testroot/repo`
1209 70551d57 2020-04-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo $new_commit2`
1211 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q newbranch)
1213 70551d57 2020-04-24 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1214 70551d57 2020-04-24 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1215 70551d57 2020-04-24 stsp local short_orig_commit3=`trim_obj_id 28 $orig_commit3`
1216 70551d57 2020-04-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1217 70551d57 2020-04-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1218 70551d57 2020-04-24 stsp local short_new_commit3=`trim_obj_id 28 $new_commit3`
1220 70551d57 2020-04-24 stsp echo "D beta" > $testroot/stdout.expected
1221 70551d57 2020-04-24 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1222 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1223 70551d57 2020-04-24 stsp echo ": removing beta from newbranch" >> $testroot/stdout.expected
1224 70551d57 2020-04-24 stsp echo "A beta" >> $testroot/stdout.expected
1225 70551d57 2020-04-24 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1226 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1227 70551d57 2020-04-24 stsp echo ": restoring beta on newbranch" >> $testroot/stdout.expected
1228 70551d57 2020-04-24 stsp echo "D beta" >> $testroot/stdout.expected
1229 70551d57 2020-04-24 stsp echo -n "$short_orig_commit3 -> $short_new_commit3" \
1230 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1231 70551d57 2020-04-24 stsp echo ": removing beta from newbranch again" >> $testroot/stdout.expected
1232 70551d57 2020-04-24 stsp echo "Switching work tree to refs/heads/newbranch" \
1233 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1235 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1237 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1238 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1239 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1243 70551d57 2020-04-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1245 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1246 70551d57 2020-04-24 stsp echo "got status command failed unexpectedly" >&2
1247 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1251 70551d57 2020-04-24 stsp echo -n > $testroot/stdout.expected
1252 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1254 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1255 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1256 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1260 70551d57 2020-04-24 stsp (cd $testroot/wt && got log -l4 | grep ^commit > $testroot/stdout)
1261 70551d57 2020-04-24 stsp echo "commit $new_commit3 (newbranch)" > $testroot/stdout.expected
1262 70551d57 2020-04-24 stsp echo "commit $new_commit2" >> $testroot/stdout.expected
1263 70551d57 2020-04-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1264 70551d57 2020-04-24 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1265 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1267 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1268 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1270 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1273 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1274 dcf44d04 2019-07-11 stsp run_test test_rebase_basic
1275 dcf44d04 2019-07-11 stsp run_test test_rebase_ancestry_check
1276 dcf44d04 2019-07-11 stsp run_test test_rebase_continue
1277 dcf44d04 2019-07-11 stsp run_test test_rebase_abort
1278 ff0d2220 2019-07-11 stsp run_test test_rebase_no_op_change
1279 7d5807f4 2019-07-11 stsp run_test test_rebase_in_progress
1280 64c6d990 2019-07-11 stsp run_test test_rebase_path_prefix
1281 787c8eb6 2019-07-11 stsp run_test test_rebase_preserves_logmsg
1282 fc66b545 2019-08-12 stsp run_test test_rebase_no_commits_to_rebase
1283 38b0338b 2019-11-29 stsp run_test test_rebase_forward
1284 e51d7b55 2020-01-04 stsp run_test test_rebase_out_of_date
1285 1ae0a341 2020-02-14 stsp run_test test_rebase_trims_empty_dir
1286 ca6da77d 2020-03-22 stsp run_test test_rebase_delete_missing_file
1287 70551d57 2020-04-24 stsp run_test test_rebase_rm_add_rm_file