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
135 a615e0e7 2020-12-16 stsp test_done "$testroot" "$ret"
139 a615e0e7 2020-12-16 stsp (cd $testroot/wt && got update > $testroot/stdout)
141 a615e0e7 2020-12-16 stsp echo 'Already up-to-date' > $testroot/stdout.expected
142 a615e0e7 2020-12-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
144 a615e0e7 2020-12-16 stsp if [ "$ret" != "0" ]; then
145 a615e0e7 2020-12-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
147 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
150 f6cae3ed 2020-09-13 naddy test_rebase_ancestry_check() {
151 818c7501 2019-07-11 stsp local testroot=`test_init rebase_ancestry_check`
153 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
155 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
156 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
160 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
161 818c7501 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
162 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
164 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
165 818c7501 2019-07-11 stsp 2> $testroot/stderr)
167 818c7501 2019-07-11 stsp echo -n > $testroot/stdout.expected
168 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
170 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
171 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
172 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
176 df3ed485 2021-01-31 stsp echo "got: refs/heads/newbranch is already based on refs/heads/master" \
177 818c7501 2019-07-11 stsp > $testroot/stderr.expected
178 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
180 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
181 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
183 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
186 f6cae3ed 2020-09-13 naddy test_rebase_continue() {
187 818c7501 2019-07-11 stsp local testroot=`test_init rebase_continue`
188 f69721c3 2019-10-21 stsp local init_commit=`git_show_head $testroot/repo`
190 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
191 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
192 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
193 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
194 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
196 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
197 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
198 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
199 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
201 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
203 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
204 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
208 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
209 818c7501 2019-07-11 stsp 2> $testroot/stderr)
211 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
212 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
213 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
214 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
215 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
216 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
218 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
219 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
220 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
224 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
225 818c7501 2019-07-11 stsp > $testroot/stderr.expected
226 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
228 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
229 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
230 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
234 f69721c3 2019-10-21 stsp echo "<<<<<<< merged change: commit $orig_commit1" \
235 f69721c3 2019-10-21 stsp > $testroot/content.expected
236 818c7501 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
237 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
238 f69721c3 2019-10-21 stsp >> $testroot/content.expected
239 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
240 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
241 818c7501 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
242 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
243 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
244 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
246 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
247 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
248 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
252 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
254 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
255 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
257 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
258 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
259 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
263 818c7501 2019-07-11 stsp # resolve the conflict
264 818c7501 2019-07-11 stsp echo "modified alpha on branch and master" > $testroot/wt/alpha
266 f032f1f7 2019-08-04 stsp # test interaction of 'got stage' and rebase -c
267 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got stage alpha > /dev/null)
268 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout \
269 f032f1f7 2019-08-04 stsp 2> $testroot/stderr)
271 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
272 f032f1f7 2019-08-04 stsp echo "rebase succeeded unexpectedly" >&2
273 f032f1f7 2019-08-04 stsp test_done "$testroot" "1"
276 f032f1f7 2019-08-04 stsp echo -n "got: work tree contains files with staged changes; " \
277 f032f1f7 2019-08-04 stsp > $testroot/stderr.expected
278 f032f1f7 2019-08-04 stsp echo "these changes must be committed or unstaged first" \
279 f032f1f7 2019-08-04 stsp >> $testroot/stderr.expected
280 f032f1f7 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
282 f032f1f7 2019-08-04 stsp if [ "$ret" != "0" ]; then
283 f032f1f7 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
284 f032f1f7 2019-08-04 stsp test_done "$testroot" "$ret"
288 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got unstage alpha > /dev/null)
289 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
291 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
292 818c7501 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
293 818c7501 2019-07-11 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
295 818c7501 2019-07-11 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
296 818c7501 2019-07-11 stsp > $testroot/stdout.expected
297 818c7501 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
298 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
299 818c7501 2019-07-11 stsp >> $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
305 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
310 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
311 818c7501 2019-07-11 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
312 818c7501 2019-07-11 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
313 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
315 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
316 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
318 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
321 f6cae3ed 2020-09-13 naddy test_rebase_abort() {
322 818c7501 2019-07-11 stsp local testroot=`test_init rebase_abort`
324 818c7501 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
326 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
327 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
328 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
329 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
330 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
332 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
333 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
334 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
335 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
337 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
339 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
340 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
344 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
345 818c7501 2019-07-11 stsp 2> $testroot/stderr)
347 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
348 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
349 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
350 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
351 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
352 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
354 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
355 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
356 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
360 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
361 818c7501 2019-07-11 stsp > $testroot/stderr.expected
362 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
364 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
365 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
366 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
370 f69721c3 2019-10-21 stsp echo "<<<<<<< merged change: commit $orig_commit1" \
371 f69721c3 2019-10-21 stsp > $testroot/content.expected
372 818c7501 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
373 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
374 f69721c3 2019-10-21 stsp >> $testroot/content.expected
375 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
376 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
377 818c7501 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
378 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
379 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
380 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
382 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
383 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
384 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
388 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
390 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
391 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
393 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
394 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
395 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
399 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -a > $testroot/stdout)
401 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
403 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/master" \
404 818c7501 2019-07-11 stsp > $testroot/stdout.expected
405 818c7501 2019-07-11 stsp echo 'R alpha' >> $testroot/stdout.expected
406 818c7501 2019-07-11 stsp echo "Rebase of refs/heads/newbranch aborted" \
407 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
409 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
411 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
412 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
413 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
417 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/content.expected
418 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
419 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
421 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
422 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
423 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
427 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l3 -c newbranch \
428 818c7501 2019-07-11 stsp | grep ^commit > $testroot/stdout)
429 818c7501 2019-07-11 stsp echo "commit $orig_commit1 (newbranch)" > $testroot/stdout.expected
430 818c7501 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
431 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
433 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
434 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
436 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
439 f6cae3ed 2020-09-13 naddy test_rebase_no_op_change() {
440 ff0d2220 2019-07-11 stsp local testroot=`test_init rebase_no_op_change`
441 ff0d2220 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
443 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
444 ff0d2220 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
445 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
446 ff0d2220 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
447 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
449 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
450 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
451 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
452 ff0d2220 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
454 ff0d2220 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
456 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
457 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
461 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
462 ff0d2220 2019-07-11 stsp 2> $testroot/stderr)
464 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
465 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
466 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
467 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
468 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
469 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
471 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
472 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
473 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
477 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
478 ff0d2220 2019-07-11 stsp > $testroot/stderr.expected
479 ff0d2220 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
481 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
482 ff0d2220 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
483 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
487 f69721c3 2019-10-21 stsp echo "<<<<<<< merged change: commit $orig_commit1" \
488 f69721c3 2019-10-21 stsp > $testroot/content.expected
489 ff0d2220 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
490 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
491 f69721c3 2019-10-21 stsp >> $testroot/content.expected
492 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
493 ff0d2220 2019-07-11 stsp echo "=======" >> $testroot/content.expected
494 ff0d2220 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
495 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
496 ff0d2220 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
497 ff0d2220 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
499 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
500 ff0d2220 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
501 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
505 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
507 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
508 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
510 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
511 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
512 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
516 ff0d2220 2019-07-11 stsp # resolve the conflict
517 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/wt/alpha
519 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
521 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
522 ff0d2220 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
524 ff0d2220 2019-07-11 stsp echo -n "$short_orig_commit1 -> no-op change" \
525 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
526 ff0d2220 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
527 ff0d2220 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
528 ff0d2220 2019-07-11 stsp >> $testroot/stdout.expected
530 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
532 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
533 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
534 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
539 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
540 ff0d2220 2019-07-11 stsp echo "commit $master_commit (master, newbranch)" \
541 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
542 ff0d2220 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
543 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
545 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
546 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
548 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
551 f6cae3ed 2020-09-13 naddy test_rebase_in_progress() {
552 4ba9c4f6 2019-07-11 stsp local testroot=`test_init rebase_in_progress`
553 7d5807f4 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
555 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
556 7d5807f4 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
557 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
558 7d5807f4 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
559 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
561 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
562 7d5807f4 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
563 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
564 7d5807f4 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
566 7d5807f4 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
568 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
569 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
573 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
574 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
576 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
577 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
578 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
579 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
580 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
581 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
583 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
584 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
585 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
589 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
590 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
591 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
593 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
594 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
595 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
599 f69721c3 2019-10-21 stsp echo "<<<<<<< merged change: commit $orig_commit1" \
600 f69721c3 2019-10-21 stsp > $testroot/content.expected
601 7d5807f4 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
602 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
603 f69721c3 2019-10-21 stsp >> $testroot/content.expected
604 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
605 7d5807f4 2019-07-11 stsp echo "=======" >> $testroot/content.expected
606 7d5807f4 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
607 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
608 7d5807f4 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
609 7d5807f4 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
611 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
612 7d5807f4 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
613 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
617 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
619 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
620 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
622 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
623 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
624 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
628 7d5807f4 2019-07-11 stsp for cmd in update commit; do
629 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got $cmd > $testroot/stdout \
630 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
632 7d5807f4 2019-07-11 stsp echo -n > $testroot/stdout.expected
633 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
635 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
636 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
637 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
641 7d5807f4 2019-07-11 stsp echo -n "got: a rebase operation is in progress in this " \
642 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
643 7d5807f4 2019-07-11 stsp echo "work tree and must be continued or aborted first" \
644 7d5807f4 2019-07-11 stsp >> $testroot/stderr.expected
645 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
647 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
648 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
649 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
654 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
657 f6cae3ed 2020-09-13 naddy test_rebase_path_prefix() {
658 64c6d990 2019-07-11 stsp local testroot=`test_init rebase_path_prefix`
660 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
661 64c6d990 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
662 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
664 64c6d990 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
665 64c6d990 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
667 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
668 64c6d990 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
669 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
670 64c6d990 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
672 64c6d990 2019-07-11 stsp got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
674 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
675 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
679 64c6d990 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch \
680 64c6d990 2019-07-11 stsp > $testroot/stdout 2> $testroot/stderr)
682 64c6d990 2019-07-11 stsp echo -n > $testroot/stdout.expected
683 64c6d990 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
685 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
686 64c6d990 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
687 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
691 64c6d990 2019-07-11 stsp echo -n "got: cannot rebase branch which contains changes outside " \
692 64c6d990 2019-07-11 stsp > $testroot/stderr.expected
693 64c6d990 2019-07-11 stsp echo "of this work tree's path prefix" >> $testroot/stderr.expected
694 787c8eb6 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
696 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
697 787c8eb6 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
699 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
702 f6cae3ed 2020-09-13 naddy test_rebase_preserves_logmsg() {
703 787c8eb6 2019-07-11 stsp local testroot=`test_init rebase_preserves_logmsg`
705 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
706 787c8eb6 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
707 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified delta on newbranch"
709 787c8eb6 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
710 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified alpha on newbranch"
712 787c8eb6 2019-07-11 stsp (cd $testroot/repo && got log -c newbranch -l2 | grep -v ^date: \
713 787c8eb6 2019-07-11 stsp > $testroot/log.expected)
715 787c8eb6 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
716 787c8eb6 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
718 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
719 787c8eb6 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
720 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
721 787c8eb6 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
723 787c8eb6 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
725 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
726 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
730 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > /dev/null \
731 787c8eb6 2019-07-11 stsp 2> $testroot/stderr)
733 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
734 787c8eb6 2019-07-11 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
735 787c8eb6 2019-07-11 stsp local new_commit2=`git_show_head $testroot/repo`
737 787c8eb6 2019-07-11 stsp echo -n > $testroot/stderr.expected
738 64c6d990 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
740 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
741 64c6d990 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
742 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
746 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got log -c newbranch -l2 | grep -v ^date: \
747 787c8eb6 2019-07-11 stsp > $testroot/log)
748 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit1/$new_commit1/" $testroot/log.expected
749 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit2/$new_commit2/" $testroot/log.expected
750 787c8eb6 2019-07-11 stsp cmp -s $testroot/log.expected $testroot/log
752 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
753 787c8eb6 2019-07-11 stsp diff -u $testroot/log.expected $testroot/log
756 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
759 f6cae3ed 2020-09-13 naddy test_rebase_no_commits_to_rebase() {
760 fc66b545 2019-08-12 stsp local testroot=`test_init rebase_no_commits_to_rebase`
762 fc66b545 2019-08-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
764 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
765 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
769 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n newbranch)
771 fc66b545 2019-08-12 stsp echo "modified alpha on master" > $testroot/wt/alpha
772 fc66b545 2019-08-12 stsp (cd $testroot/wt && got commit -m 'test rebase_no_commits_to_rebase' \
773 fc66b545 2019-08-12 stsp > /dev/null)
774 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > /dev/null)
776 fc66b545 2019-08-12 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
777 fc66b545 2019-08-12 stsp 2> $testroot/stderr)
779 fc66b545 2019-08-12 stsp echo "got: no commits to rebase" > $testroot/stderr.expected
780 fc66b545 2019-08-12 stsp cmp -s $testroot/stderr.expected $testroot/stderr
782 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
783 fc66b545 2019-08-12 stsp diff -u $testroot/stderr.expected $testroot/stderr
784 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
788 fc66b545 2019-08-12 stsp echo "Rebase of refs/heads/newbranch aborted" \
789 fc66b545 2019-08-12 stsp > $testroot/stdout.expected
790 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
792 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
793 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
794 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
798 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
799 fc66b545 2019-08-12 stsp echo "Already up-to-date" > $testroot/stdout.expected
800 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
802 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
803 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
805 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
808 f6cae3ed 2020-09-13 naddy test_rebase_forward() {
809 38b0338b 2019-11-29 stsp local testroot=`test_init rebase_forward`
810 38b0338b 2019-11-29 stsp local commit0=`git_show_head $testroot/repo`
812 38b0338b 2019-11-29 stsp got checkout $testroot/repo $testroot/wt > /dev/null
814 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
815 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
819 38b0338b 2019-11-29 stsp echo "change alpha 1" > $testroot/wt/alpha
820 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
821 38b0338b 2019-11-29 stsp > /dev/null)
822 38b0338b 2019-11-29 stsp local commit1=`git_show_head $testroot/repo`
824 38b0338b 2019-11-29 stsp echo "change alpha 2" > $testroot/wt/alpha
825 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
826 38b0338b 2019-11-29 stsp > /dev/null)
827 38b0338b 2019-11-29 stsp local commit2=`git_show_head $testroot/repo`
829 38b0338b 2019-11-29 stsp # Simulate a situation where fast-forward is required.
830 38b0338b 2019-11-29 stsp # We want to fast-forward master to origin/master:
831 38b0338b 2019-11-29 stsp # commit 3907e11dceaae2ca7f8db79c2af31794673945ad (origin/master)
832 38b0338b 2019-11-29 stsp # commit ffcffcd102cf1af6572fbdbb4cf07a0f1fd2d840 (master)
833 38b0338b 2019-11-29 stsp # commit 87a6a8a2263a15b61c016ff1720b24741d455eb5
834 38b0338b 2019-11-29 stsp (cd $testroot/repo && got ref -d master)
835 e31abbf2 2020-03-22 stsp (cd $testroot/repo && got ref -c $commit1 refs/heads/master)
836 e31abbf2 2020-03-22 stsp (cd $testroot/repo && got ref -c $commit2 refs/remotes/origin/master)
838 38b0338b 2019-11-29 stsp (cd $testroot/wt && got up -b origin/master > /dev/null)
840 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase master \
841 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
843 38b0338b 2019-11-29 stsp echo "Forwarding refs/heads/master to commit $commit2" \
844 38b0338b 2019-11-29 stsp > $testroot/stdout.expected
845 38b0338b 2019-11-29 stsp echo "Switching work tree to refs/heads/master" \
846 38b0338b 2019-11-29 stsp >> $testroot/stdout.expected
847 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
849 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
850 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
851 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
855 38b0338b 2019-11-29 stsp # Ensure that rebase operation was completed correctly
856 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase -a \
857 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
858 38b0338b 2019-11-29 stsp echo -n "" > $testroot/stdout.expected
859 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
861 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
862 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
863 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
866 38b0338b 2019-11-29 stsp echo "got: rebase operation not in progress" > $testroot/stderr.expected
867 38b0338b 2019-11-29 stsp cmp -s $testroot/stderr.expected $testroot/stderr
869 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
870 38b0338b 2019-11-29 stsp diff -u $testroot/stderr.expected $testroot/stderr
871 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
875 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n > $testroot/stdout)
876 38b0338b 2019-11-29 stsp echo "master" > $testroot/stdout.expected
877 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
879 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
880 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
881 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
885 38b0338b 2019-11-29 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
886 38b0338b 2019-11-29 stsp echo "commit $commit2 (master, origin/master)" > $testroot/stdout.expected
887 38b0338b 2019-11-29 stsp echo "commit $commit1" >> $testroot/stdout.expected
888 38b0338b 2019-11-29 stsp echo "commit $commit0" >> $testroot/stdout.expected
889 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
891 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
892 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
894 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
897 f6cae3ed 2020-09-13 naddy test_rebase_out_of_date() {
898 e51d7b55 2020-01-04 stsp local testroot=`test_init rebase_out_of_date`
899 e51d7b55 2020-01-04 stsp local initial_commit=`git_show_head $testroot/repo`
901 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q -b newbranch)
902 e51d7b55 2020-01-04 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
903 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
905 e51d7b55 2020-01-04 stsp echo "modified alpha on branch" > $testroot/repo/alpha
906 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git rm -q beta)
907 e51d7b55 2020-01-04 stsp echo "new file on branch" > $testroot/repo/epsilon/new
908 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git add epsilon/new)
909 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
911 e51d7b55 2020-01-04 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
912 e51d7b55 2020-01-04 stsp local orig_commit2=`git_show_head $testroot/repo`
914 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
915 e51d7b55 2020-01-04 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
916 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to zeta on master"
917 e51d7b55 2020-01-04 stsp local master_commit1=`git_show_head $testroot/repo`
919 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
920 e51d7b55 2020-01-04 stsp echo "modified beta on master" > $testroot/repo/beta
921 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to beta on master"
922 e51d7b55 2020-01-04 stsp local master_commit2=`git_show_head $testroot/repo`
924 e51d7b55 2020-01-04 stsp got checkout -c $master_commit1 $testroot/repo $testroot/wt \
925 e51d7b55 2020-01-04 stsp > /dev/null
927 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
928 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
932 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
933 e51d7b55 2020-01-04 stsp 2> $testroot/stderr)
935 e51d7b55 2020-01-04 stsp echo -n > $testroot/stdout.expected
936 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
938 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
939 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
940 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
944 e51d7b55 2020-01-04 stsp echo -n "got: work tree must be updated before it can be " \
945 e51d7b55 2020-01-04 stsp > $testroot/stderr.expected
946 e51d7b55 2020-01-04 stsp echo "used to rebase a branch" >> $testroot/stderr.expected
947 e51d7b55 2020-01-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
949 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
950 e51d7b55 2020-01-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
951 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
955 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
956 e51d7b55 2020-01-04 stsp echo "commit $master_commit2 (master)" > $testroot/stdout.expected
957 e51d7b55 2020-01-04 stsp echo "commit $master_commit1" >> $testroot/stdout.expected
958 e51d7b55 2020-01-04 stsp echo "commit $initial_commit" >> $testroot/stdout.expected
959 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
961 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
962 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
964 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
967 f6cae3ed 2020-09-13 naddy test_rebase_trims_empty_dir() {
968 1ae0a341 2020-02-14 stsp local testroot=`test_init rebase_trims_empty_dir`
970 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
971 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
972 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
974 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git rm -q epsilon/zeta)
975 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "removing zeta on newbranch"
977 1ae0a341 2020-02-14 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
978 1ae0a341 2020-02-14 stsp local orig_commit2=`git_show_head $testroot/repo`
980 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q master)
981 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/repo/alpha
982 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to alpha on master"
983 1ae0a341 2020-02-14 stsp local master_commit=`git_show_head $testroot/repo`
985 1ae0a341 2020-02-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
987 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
988 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
992 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
994 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q newbranch)
995 1ae0a341 2020-02-14 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
996 1ae0a341 2020-02-14 stsp local new_commit2=`git_show_head $testroot/repo`
998 1ae0a341 2020-02-14 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
999 1ae0a341 2020-02-14 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1000 1ae0a341 2020-02-14 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1001 1ae0a341 2020-02-14 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1003 1ae0a341 2020-02-14 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1004 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1005 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1006 1ae0a341 2020-02-14 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1007 1ae0a341 2020-02-14 stsp echo "D epsilon/zeta" >> $testroot/stdout.expected
1008 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1009 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1010 1ae0a341 2020-02-14 stsp echo ": removing zeta on newbranch" \
1011 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1012 1ae0a341 2020-02-14 stsp echo "Switching work tree to refs/heads/newbranch" \
1013 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1015 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1017 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
1018 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
1019 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1023 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/content.expected
1024 1ae0a341 2020-02-14 stsp cat $testroot/wt/gamma/delta > $testroot/content
1025 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1027 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1028 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1029 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1033 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/content.expected
1034 1ae0a341 2020-02-14 stsp cat $testroot/wt/alpha > $testroot/content
1035 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1037 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1038 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1039 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1043 1ae0a341 2020-02-14 stsp if [ -e $testroot/wt/epsilon ]; then
1044 1ae0a341 2020-02-14 stsp echo "parent of removed zeta still exists on disk" >&2
1045 1ae0a341 2020-02-14 stsp test_done "$testroot" "1"
1049 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got status > $testroot/stdout)
1051 1ae0a341 2020-02-14 stsp echo -n > $testroot/stdout.expected
1052 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1054 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1055 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1056 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1060 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1061 1ae0a341 2020-02-14 stsp echo "commit $new_commit2 (newbranch)" > $testroot/stdout.expected
1062 1ae0a341 2020-02-14 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1063 1ae0a341 2020-02-14 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1064 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1066 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1067 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1069 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1072 f6cae3ed 2020-09-13 naddy test_rebase_delete_missing_file() {
1073 ca6da77d 2020-03-22 stsp local testroot=`test_init rebase_delete_missing_file`
1075 ca6da77d 2020-03-22 stsp mkdir -p $testroot/repo/d/f/g
1076 ca6da77d 2020-03-22 stsp echo "new file" > $testroot/repo/d/f/g/new
1077 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git add d/f/g/new)
1078 ca6da77d 2020-03-22 stsp git_commit $testroot/repo -m "adding a subdir"
1079 ca6da77d 2020-03-22 stsp local commit0=`git_show_head $testroot/repo`
1081 a740a1b3 2020-03-22 stsp got br -r $testroot/repo -c master newbranch
1083 a740a1b3 2020-03-22 stsp got checkout -b newbranch $testroot/repo $testroot/wt > /dev/null
1085 a740a1b3 2020-03-22 stsp echo "modified delta on branch" > $testroot/wt/gamma/delta
1086 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1087 a740a1b3 2020-03-22 stsp -m "committing to delta on newbranch" > /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 newbranch" > /dev/null)
1093 a740a1b3 2020-03-22 stsp (cd $testroot/repo && git checkout -q newbranch)
1094 ca6da77d 2020-03-22 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1095 ca6da77d 2020-03-22 stsp local orig_commit2=`git_show_head $testroot/repo`
1097 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got update -b master > /dev/null)
1098 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1099 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1100 a740a1b3 2020-03-22 stsp -m "removing beta and d/f/g/new on master" > /dev/null)
1102 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git checkout -q master)
1103 ca6da77d 2020-03-22 stsp local master_commit=`git_show_head $testroot/repo`
1105 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got update -b master > /dev/null)
1106 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1108 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git checkout -q newbranch)
1109 ca6da77d 2020-03-22 stsp local new_commit1=`git_show_head $testroot/repo`
1111 ca6da77d 2020-03-22 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1112 ca6da77d 2020-03-22 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1113 ca6da77d 2020-03-22 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1115 ca6da77d 2020-03-22 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1116 ca6da77d 2020-03-22 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1117 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1118 ca6da77d 2020-03-22 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1119 ca6da77d 2020-03-22 stsp echo "! beta" >> $testroot/stdout.expected
1120 ca6da77d 2020-03-22 stsp echo "! d/f/g/new" >> $testroot/stdout.expected
1121 ca6da77d 2020-03-22 stsp echo -n "$short_orig_commit2 -> no-op change" \
1122 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1123 a740a1b3 2020-03-22 stsp echo ": removing beta and d/f/g/new on newbranch" \
1124 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1125 ca6da77d 2020-03-22 stsp echo "Switching work tree to refs/heads/newbranch" \
1126 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1128 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1130 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1131 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1132 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1136 ca6da77d 2020-03-22 stsp echo "modified delta on branch" > $testroot/content.expected
1137 ca6da77d 2020-03-22 stsp cat $testroot/wt/gamma/delta > $testroot/content
1138 ca6da77d 2020-03-22 stsp cmp -s $testroot/content.expected $testroot/content
1140 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1141 ca6da77d 2020-03-22 stsp diff -u $testroot/content.expected $testroot/content
1142 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1146 ca6da77d 2020-03-22 stsp if [ -e $testroot/wt/beta ]; then
1147 ca6da77d 2020-03-22 stsp echo "removed file beta still exists on disk" >&2
1148 ca6da77d 2020-03-22 stsp test_done "$testroot" "1"
1152 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got status > $testroot/stdout)
1154 ca6da77d 2020-03-22 stsp echo -n > $testroot/stdout.expected
1155 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1157 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1158 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1159 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1163 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1164 ca6da77d 2020-03-22 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
1165 ca6da77d 2020-03-22 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1166 ca6da77d 2020-03-22 stsp echo "commit $commit0" >> $testroot/stdout.expected
1167 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1169 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1170 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1172 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1175 f6cae3ed 2020-09-13 naddy test_rebase_rm_add_rm_file() {
1176 70551d57 2020-04-24 stsp local testroot=`test_init rebase_rm_add_rm_file`
1178 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
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"
1181 70551d57 2020-04-24 stsp local orig_commit1=`git_show_head $testroot/repo`
1183 70551d57 2020-04-24 stsp echo 'restored beta' > $testroot/repo/beta
1184 70551d57 2020-04-24 stsp (cd $testroot/repo && git add beta)
1185 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "restoring beta on newbranch"
1186 70551d57 2020-04-24 stsp local orig_commit2=`git_show_head $testroot/repo`
1188 70551d57 2020-04-24 stsp (cd $testroot/repo && git rm -q beta)
1189 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "removing beta from newbranch again"
1190 70551d57 2020-04-24 stsp local orig_commit3=`git_show_head $testroot/repo`
1192 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q master)
1193 70551d57 2020-04-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1194 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
1195 70551d57 2020-04-24 stsp local master_commit=`git_show_head $testroot/repo`
1197 70551d57 2020-04-24 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1199 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1200 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1204 70551d57 2020-04-24 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1206 70551d57 2020-04-24 stsp # this would error out with 'got: file index is corrupt'
1207 70551d57 2020-04-24 stsp (cd $testroot/wt && got status > /dev/null)
1209 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1210 70551d57 2020-04-24 stsp echo "got status command failed unexpectedly" >&2
1211 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1215 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q newbranch)
1216 70551d57 2020-04-24 stsp local new_commit3=`git_show_head $testroot/repo`
1217 70551d57 2020-04-24 stsp local new_commit2=`git_show_parent_commit $testroot/repo`
1218 70551d57 2020-04-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo $new_commit2`
1220 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q newbranch)
1222 70551d57 2020-04-24 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1223 70551d57 2020-04-24 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1224 70551d57 2020-04-24 stsp local short_orig_commit3=`trim_obj_id 28 $orig_commit3`
1225 70551d57 2020-04-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1226 70551d57 2020-04-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1227 70551d57 2020-04-24 stsp local short_new_commit3=`trim_obj_id 28 $new_commit3`
1229 70551d57 2020-04-24 stsp echo "D beta" > $testroot/stdout.expected
1230 70551d57 2020-04-24 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1231 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1232 70551d57 2020-04-24 stsp echo ": removing beta from newbranch" >> $testroot/stdout.expected
1233 70551d57 2020-04-24 stsp echo "A beta" >> $testroot/stdout.expected
1234 70551d57 2020-04-24 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1235 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1236 70551d57 2020-04-24 stsp echo ": restoring beta on newbranch" >> $testroot/stdout.expected
1237 70551d57 2020-04-24 stsp echo "D beta" >> $testroot/stdout.expected
1238 70551d57 2020-04-24 stsp echo -n "$short_orig_commit3 -> $short_new_commit3" \
1239 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1240 70551d57 2020-04-24 stsp echo ": removing beta from newbranch again" >> $testroot/stdout.expected
1241 70551d57 2020-04-24 stsp echo "Switching work tree to refs/heads/newbranch" \
1242 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1244 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1246 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1247 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1248 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1252 70551d57 2020-04-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1254 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1255 70551d57 2020-04-24 stsp echo "got status command failed unexpectedly" >&2
1256 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1260 70551d57 2020-04-24 stsp echo -n > $testroot/stdout.expected
1261 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1263 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1264 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1265 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1269 70551d57 2020-04-24 stsp (cd $testroot/wt && got log -l4 | grep ^commit > $testroot/stdout)
1270 70551d57 2020-04-24 stsp echo "commit $new_commit3 (newbranch)" > $testroot/stdout.expected
1271 70551d57 2020-04-24 stsp echo "commit $new_commit2" >> $testroot/stdout.expected
1272 70551d57 2020-04-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1273 70551d57 2020-04-24 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1274 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1276 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1277 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1279 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1282 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1283 dcf44d04 2019-07-11 stsp run_test test_rebase_basic
1284 dcf44d04 2019-07-11 stsp run_test test_rebase_ancestry_check
1285 dcf44d04 2019-07-11 stsp run_test test_rebase_continue
1286 dcf44d04 2019-07-11 stsp run_test test_rebase_abort
1287 ff0d2220 2019-07-11 stsp run_test test_rebase_no_op_change
1288 7d5807f4 2019-07-11 stsp run_test test_rebase_in_progress
1289 64c6d990 2019-07-11 stsp run_test test_rebase_path_prefix
1290 787c8eb6 2019-07-11 stsp run_test test_rebase_preserves_logmsg
1291 fc66b545 2019-08-12 stsp run_test test_rebase_no_commits_to_rebase
1292 38b0338b 2019-11-29 stsp run_test test_rebase_forward
1293 e51d7b55 2020-01-04 stsp run_test test_rebase_out_of_date
1294 1ae0a341 2020-02-14 stsp run_test test_rebase_trims_empty_dir
1295 ca6da77d 2020-03-22 stsp run_test test_rebase_delete_missing_file
1296 70551d57 2020-04-24 stsp run_test test_rebase_rm_add_rm_file