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`
21 e600f124 2021-03-21 stsp local commit0=`git_show_head $testroot/repo`
22 e600f124 2021-03-21 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
24 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
25 818c7501 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
26 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
28 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
29 818c7501 2019-07-11 stsp (cd $testroot/repo && git rm -q beta)
30 818c7501 2019-07-11 stsp echo "new file on branch" > $testroot/repo/epsilon/new
31 818c7501 2019-07-11 stsp (cd $testroot/repo && git add epsilon/new)
32 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
34 818c7501 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
35 818c7501 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
36 e600f124 2021-03-21 stsp local orig_author_time2=`git_show_author_time $testroot/repo`
38 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
39 818c7501 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
40 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
41 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
43 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
45 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
46 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
50 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
52 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
53 818c7501 2019-07-11 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
54 818c7501 2019-07-11 stsp local new_commit2=`git_show_head $testroot/repo`
55 e600f124 2021-03-21 stsp local new_author_time2=`git_show_author_time $testroot/repo`
57 818c7501 2019-07-11 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
58 818c7501 2019-07-11 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
59 818c7501 2019-07-11 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
60 818c7501 2019-07-11 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
62 818c7501 2019-07-11 stsp echo "G gamma/delta" >> $testroot/stdout.expected
63 818c7501 2019-07-11 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
64 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
65 818c7501 2019-07-11 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
66 818c7501 2019-07-11 stsp echo "G alpha" >> $testroot/stdout.expected
67 818c7501 2019-07-11 stsp echo "D beta" >> $testroot/stdout.expected
68 818c7501 2019-07-11 stsp echo "A epsilon/new" >> $testroot/stdout.expected
69 818c7501 2019-07-11 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
70 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
71 818c7501 2019-07-11 stsp echo ": committing more changes on newbranch" \
72 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
73 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
74 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
76 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
78 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
79 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
80 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
84 818c7501 2019-07-11 stsp echo "modified delta on branch" > $testroot/content.expected
85 818c7501 2019-07-11 stsp cat $testroot/wt/gamma/delta > $testroot/content
86 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
88 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
89 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
90 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
94 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/content.expected
95 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
96 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
98 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
99 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
100 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
104 818c7501 2019-07-11 stsp if [ -e $testroot/wt/beta ]; then
105 818c7501 2019-07-11 stsp echo "removed file beta still exists on disk" >&2
106 818c7501 2019-07-11 stsp test_done "$testroot" "1"
110 818c7501 2019-07-11 stsp echo "new file on branch" > $testroot/content.expected
111 818c7501 2019-07-11 stsp cat $testroot/wt/epsilon/new > $testroot/content
112 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
114 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
115 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
116 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
120 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
122 818c7501 2019-07-11 stsp echo -n > $testroot/stdout.expected
123 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
125 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
126 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
127 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
131 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
132 818c7501 2019-07-11 stsp echo "commit $new_commit2 (newbranch)" > $testroot/stdout.expected
133 818c7501 2019-07-11 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
134 818c7501 2019-07-11 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
135 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
137 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
138 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
139 a615e0e7 2020-12-16 stsp test_done "$testroot" "$ret"
143 a615e0e7 2020-12-16 stsp (cd $testroot/wt && got update > $testroot/stdout)
145 a615e0e7 2020-12-16 stsp echo 'Already up-to-date' > $testroot/stdout.expected
146 a615e0e7 2020-12-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
148 a615e0e7 2020-12-16 stsp if [ "$ret" != "0" ]; then
149 a615e0e7 2020-12-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
150 e600f124 2021-03-21 stsp test_done "$testroot" "$ret"
154 e600f124 2021-03-21 stsp # We should have a backup of old commits
155 e600f124 2021-03-21 stsp (cd $testroot/repo && got rebase -l > $testroot/stdout)
156 3a6b8760 2021-08-31 naddy d_orig2=`date -u -r $orig_author_time2 +"%a %b %e %X %Y UTC"`
157 3a6b8760 2021-08-31 naddy d_new2=`date -u -r $new_author_time2 +"%G-%m-%d"`
158 3a6b8760 2021-08-31 naddy d_0=`date -u -r $commit0_author_time +"%G-%m-%d"`
159 e600f124 2021-03-21 stsp cat > $testroot/stdout.expected <<EOF
160 e600f124 2021-03-21 stsp -----------------------------------------------
161 e600f124 2021-03-21 stsp commit $orig_commit2 (formerly newbranch)
162 e600f124 2021-03-21 stsp from: $GOT_AUTHOR
163 e600f124 2021-03-21 stsp date: $d_orig2
165 e600f124 2021-03-21 stsp committing more changes on newbranch
167 e600f124 2021-03-21 stsp has become commit $new_commit2 (newbranch)
168 e600f124 2021-03-21 stsp $d_new2 $GOT_AUTHOR_11 committing more changes on newbranch
169 e600f124 2021-03-21 stsp history forked at $commit0
170 e600f124 2021-03-21 stsp $d_0 $GOT_AUTHOR_11 adding the test tree
172 e600f124 2021-03-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
174 e600f124 2021-03-21 stsp if [ "$ret" != "0" ]; then
175 e600f124 2021-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
176 9e822917 2021-03-23 stsp test_done "$testroot" "$ret"
180 9e822917 2021-03-23 stsp # Asking for backups of a branch which has none should yield an error
181 9e822917 2021-03-23 stsp (cd $testroot/repo && got rebase -l master \
182 9e822917 2021-03-23 stsp > $testroot/stdout 2> $testroot/stderr)
183 9e822917 2021-03-23 stsp echo -n > $testroot/stdout.expected
184 9e822917 2021-03-23 stsp echo "got: refs/got/backup/rebase/master/: no such reference found" \
185 9e822917 2021-03-23 stsp > $testroot/stderr.expected
186 9e822917 2021-03-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
188 9e822917 2021-03-23 stsp if [ "$ret" != "0" ]; then
189 9e822917 2021-03-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
190 9e822917 2021-03-23 stsp test_done "$testroot" "$ret"
193 9e822917 2021-03-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
195 9e822917 2021-03-23 stsp if [ "$ret" != "0" ]; then
196 9e822917 2021-03-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
197 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
201 643b85bc 2021-07-16 stsp # Delete all backup refs
202 643b85bc 2021-07-16 stsp (cd $testroot/repo && got rebase -X \
203 643b85bc 2021-07-16 stsp > $testroot/stdout 2> $testroot/stderr)
204 643b85bc 2021-07-16 stsp echo -n "Deleted refs/got/backup/rebase/newbranch/$new_commit2: " \
205 643b85bc 2021-07-16 stsp > $testroot/stdout.expected
206 643b85bc 2021-07-16 stsp echo "$orig_commit2" >> $testroot/stdout.expected
207 643b85bc 2021-07-16 stsp echo -n > $testroot/stderr.expected
208 643b85bc 2021-07-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
210 643b85bc 2021-07-16 stsp if [ "$ret" != "0" ]; then
211 643b85bc 2021-07-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
212 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
215 643b85bc 2021-07-16 stsp cmp -s $testroot/stderr.expected $testroot/stderr
217 643b85bc 2021-07-16 stsp if [ "$ret" != "0" ]; then
218 643b85bc 2021-07-16 stsp diff -u $testroot/stderr.expected $testroot/stderr
219 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
223 643b85bc 2021-07-16 stsp (cd $testroot/repo && got rebase -l > $testroot/stdout)
224 643b85bc 2021-07-16 stsp echo -n > $testroot/stdout.expected
225 643b85bc 2021-07-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
227 643b85bc 2021-07-16 stsp if [ "$ret" != "0" ]; then
228 643b85bc 2021-07-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
230 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
233 f6cae3ed 2020-09-13 naddy test_rebase_ancestry_check() {
234 818c7501 2019-07-11 stsp local testroot=`test_init rebase_ancestry_check`
236 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
238 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
239 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
243 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
244 818c7501 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
245 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
247 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
248 818c7501 2019-07-11 stsp 2> $testroot/stderr)
250 818c7501 2019-07-11 stsp echo -n > $testroot/stdout.expected
251 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
253 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
254 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
255 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
259 df3ed485 2021-01-31 stsp echo "got: refs/heads/newbranch is already based on refs/heads/master" \
260 818c7501 2019-07-11 stsp > $testroot/stderr.expected
261 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
263 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
264 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
266 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
269 f6cae3ed 2020-09-13 naddy test_rebase_continue() {
270 818c7501 2019-07-11 stsp local testroot=`test_init rebase_continue`
271 f69721c3 2019-10-21 stsp local init_commit=`git_show_head $testroot/repo`
273 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
274 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
275 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
276 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
277 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
279 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
280 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
281 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
282 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
284 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
286 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
287 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
291 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
292 818c7501 2019-07-11 stsp 2> $testroot/stderr)
294 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
295 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
296 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
297 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
298 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
299 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
301 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
302 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
303 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
307 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
308 818c7501 2019-07-11 stsp > $testroot/stderr.expected
309 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
311 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
312 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
313 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
317 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
318 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
319 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
320 f69721c3 2019-10-21 stsp >> $testroot/content.expected
321 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
322 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
323 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
324 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
325 54d5be07 2021-06-03 stsp >> $testroot/content.expected
326 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
327 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
329 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
330 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
331 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
335 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
337 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
338 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
340 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
341 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
342 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
346 818c7501 2019-07-11 stsp # resolve the conflict
347 818c7501 2019-07-11 stsp echo "modified alpha on branch and master" > $testroot/wt/alpha
349 f032f1f7 2019-08-04 stsp # test interaction of 'got stage' and rebase -c
350 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got stage alpha > /dev/null)
351 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout \
352 f032f1f7 2019-08-04 stsp 2> $testroot/stderr)
354 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
355 f032f1f7 2019-08-04 stsp echo "rebase succeeded unexpectedly" >&2
356 f032f1f7 2019-08-04 stsp test_done "$testroot" "1"
359 f032f1f7 2019-08-04 stsp echo -n "got: work tree contains files with staged changes; " \
360 f032f1f7 2019-08-04 stsp > $testroot/stderr.expected
361 f032f1f7 2019-08-04 stsp echo "these changes must be committed or unstaged first" \
362 f032f1f7 2019-08-04 stsp >> $testroot/stderr.expected
363 f032f1f7 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
365 f032f1f7 2019-08-04 stsp if [ "$ret" != "0" ]; then
366 f032f1f7 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
367 f032f1f7 2019-08-04 stsp test_done "$testroot" "$ret"
371 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got unstage alpha > /dev/null)
372 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
374 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
375 818c7501 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
376 818c7501 2019-07-11 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
378 818c7501 2019-07-11 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
379 818c7501 2019-07-11 stsp > $testroot/stdout.expected
380 818c7501 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
381 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
382 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
384 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
386 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
387 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
388 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
393 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
394 818c7501 2019-07-11 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
395 818c7501 2019-07-11 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
396 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
398 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
399 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
401 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
404 f6cae3ed 2020-09-13 naddy test_rebase_abort() {
405 818c7501 2019-07-11 stsp local testroot=`test_init rebase_abort`
407 818c7501 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
409 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
410 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
411 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
412 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
413 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
415 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
416 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
417 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
418 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
420 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
422 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
423 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
427 41f061b2 2021-10-05 stsp # unrelated unversioned file in work tree
428 41f061b2 2021-10-05 stsp touch $testroot/wt/unversioned-file
430 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
431 818c7501 2019-07-11 stsp 2> $testroot/stderr)
433 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
434 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
435 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
436 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
437 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
438 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
440 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
441 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
442 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
446 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
447 818c7501 2019-07-11 stsp > $testroot/stderr.expected
448 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
450 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
451 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
452 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
456 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
457 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
458 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
459 f69721c3 2019-10-21 stsp >> $testroot/content.expected
460 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
461 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
462 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
463 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
464 54d5be07 2021-06-03 stsp >> $testroot/content.expected
465 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
466 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
468 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
469 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
470 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
474 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
476 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
477 41f061b2 2021-10-05 stsp echo "? unversioned-file" >> $testroot/stdout.expected
478 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
480 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
481 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
482 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
486 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -a > $testroot/stdout)
488 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
490 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/master" \
491 818c7501 2019-07-11 stsp > $testroot/stdout.expected
492 818c7501 2019-07-11 stsp echo 'R alpha' >> $testroot/stdout.expected
493 818c7501 2019-07-11 stsp echo "Rebase of refs/heads/newbranch aborted" \
494 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
496 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
498 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
499 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
500 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
504 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/content.expected
505 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
506 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
508 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
509 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
510 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
514 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l3 -c newbranch \
515 818c7501 2019-07-11 stsp | grep ^commit > $testroot/stdout)
516 818c7501 2019-07-11 stsp echo "commit $orig_commit1 (newbranch)" > $testroot/stdout.expected
517 818c7501 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
518 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
520 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
521 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
523 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
526 f6cae3ed 2020-09-13 naddy test_rebase_no_op_change() {
527 ff0d2220 2019-07-11 stsp local testroot=`test_init rebase_no_op_change`
528 ff0d2220 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
530 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
531 ff0d2220 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
532 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
533 ff0d2220 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
534 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
536 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
537 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
538 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
539 ff0d2220 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
541 ff0d2220 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
543 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
544 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
548 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
549 ff0d2220 2019-07-11 stsp 2> $testroot/stderr)
551 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
552 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
553 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
554 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
555 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
556 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
558 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
559 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
560 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
564 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
565 ff0d2220 2019-07-11 stsp > $testroot/stderr.expected
566 ff0d2220 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
568 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
569 ff0d2220 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
570 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
574 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
575 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
576 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
577 f69721c3 2019-10-21 stsp >> $testroot/content.expected
578 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
579 ff0d2220 2019-07-11 stsp echo "=======" >> $testroot/content.expected
580 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
581 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
582 54d5be07 2021-06-03 stsp >> $testroot/content.expected
583 ff0d2220 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
584 ff0d2220 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
586 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
587 ff0d2220 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
588 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
592 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
594 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
595 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
597 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
598 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
599 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
603 ff0d2220 2019-07-11 stsp # resolve the conflict
604 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/wt/alpha
606 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
608 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
609 ff0d2220 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
611 ff0d2220 2019-07-11 stsp echo -n "$short_orig_commit1 -> no-op change" \
612 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
613 ff0d2220 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
614 ff0d2220 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
615 ff0d2220 2019-07-11 stsp >> $testroot/stdout.expected
617 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
619 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
620 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
621 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
626 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
627 ff0d2220 2019-07-11 stsp echo "commit $master_commit (master, newbranch)" \
628 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
629 ff0d2220 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
630 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
632 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
633 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
635 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
638 f6cae3ed 2020-09-13 naddy test_rebase_in_progress() {
639 4ba9c4f6 2019-07-11 stsp local testroot=`test_init rebase_in_progress`
640 7d5807f4 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
642 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
643 7d5807f4 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
644 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
645 7d5807f4 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
646 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
648 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
649 7d5807f4 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
650 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
651 7d5807f4 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
653 7d5807f4 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
655 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
656 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
660 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
661 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
663 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
664 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
665 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
666 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
667 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
668 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
670 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
671 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
672 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
676 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
677 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
678 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
680 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
681 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
682 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
686 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
687 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
688 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
689 f69721c3 2019-10-21 stsp >> $testroot/content.expected
690 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
691 7d5807f4 2019-07-11 stsp echo "=======" >> $testroot/content.expected
692 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
693 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
694 54d5be07 2021-06-03 stsp >> $testroot/content.expected
695 7d5807f4 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
696 7d5807f4 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
698 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
699 7d5807f4 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
700 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
704 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
706 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
707 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
709 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
710 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
711 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
715 7d5807f4 2019-07-11 stsp for cmd in update commit; do
716 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got $cmd > $testroot/stdout \
717 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
719 7d5807f4 2019-07-11 stsp echo -n > $testroot/stdout.expected
720 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
722 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
723 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
724 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
728 7d5807f4 2019-07-11 stsp echo -n "got: a rebase operation is in progress in this " \
729 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
730 7d5807f4 2019-07-11 stsp echo "work tree and must be continued or aborted first" \
731 7d5807f4 2019-07-11 stsp >> $testroot/stderr.expected
732 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
734 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
735 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
736 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
741 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
744 f6cae3ed 2020-09-13 naddy test_rebase_path_prefix() {
745 64c6d990 2019-07-11 stsp local testroot=`test_init rebase_path_prefix`
747 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
748 64c6d990 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
749 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
751 64c6d990 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
752 64c6d990 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
754 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
755 64c6d990 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
756 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
757 64c6d990 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
759 64c6d990 2019-07-11 stsp got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
761 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
762 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
766 64c6d990 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch \
767 64c6d990 2019-07-11 stsp > $testroot/stdout 2> $testroot/stderr)
769 64c6d990 2019-07-11 stsp echo -n > $testroot/stdout.expected
770 64c6d990 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
772 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
773 64c6d990 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
774 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
778 64c6d990 2019-07-11 stsp echo -n "got: cannot rebase branch which contains changes outside " \
779 64c6d990 2019-07-11 stsp > $testroot/stderr.expected
780 64c6d990 2019-07-11 stsp echo "of this work tree's path prefix" >> $testroot/stderr.expected
781 787c8eb6 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
783 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
784 787c8eb6 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
786 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
789 f6cae3ed 2020-09-13 naddy test_rebase_preserves_logmsg() {
790 787c8eb6 2019-07-11 stsp local testroot=`test_init rebase_preserves_logmsg`
792 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
793 787c8eb6 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
794 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified delta on newbranch"
796 787c8eb6 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
797 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified alpha on newbranch"
799 787c8eb6 2019-07-11 stsp (cd $testroot/repo && got log -c newbranch -l2 | grep -v ^date: \
800 787c8eb6 2019-07-11 stsp > $testroot/log.expected)
802 787c8eb6 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
803 787c8eb6 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
805 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
806 787c8eb6 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
807 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
808 787c8eb6 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
810 787c8eb6 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
812 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
813 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
817 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > /dev/null \
818 787c8eb6 2019-07-11 stsp 2> $testroot/stderr)
820 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
821 787c8eb6 2019-07-11 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
822 787c8eb6 2019-07-11 stsp local new_commit2=`git_show_head $testroot/repo`
824 787c8eb6 2019-07-11 stsp echo -n > $testroot/stderr.expected
825 64c6d990 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
827 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
828 64c6d990 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
829 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
833 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got log -c newbranch -l2 | grep -v ^date: \
834 787c8eb6 2019-07-11 stsp > $testroot/log)
835 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit1/$new_commit1/" $testroot/log.expected
836 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit2/$new_commit2/" $testroot/log.expected
837 787c8eb6 2019-07-11 stsp cmp -s $testroot/log.expected $testroot/log
839 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
840 787c8eb6 2019-07-11 stsp diff -u $testroot/log.expected $testroot/log
843 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
846 f6cae3ed 2020-09-13 naddy test_rebase_no_commits_to_rebase() {
847 fc66b545 2019-08-12 stsp local testroot=`test_init rebase_no_commits_to_rebase`
849 fc66b545 2019-08-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
851 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
852 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
856 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n newbranch)
858 fc66b545 2019-08-12 stsp echo "modified alpha on master" > $testroot/wt/alpha
859 fc66b545 2019-08-12 stsp (cd $testroot/wt && got commit -m 'test rebase_no_commits_to_rebase' \
860 fc66b545 2019-08-12 stsp > /dev/null)
861 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > /dev/null)
863 fc66b545 2019-08-12 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
864 fc66b545 2019-08-12 stsp 2> $testroot/stderr)
866 fc66b545 2019-08-12 stsp echo "got: no commits to rebase" > $testroot/stderr.expected
867 fc66b545 2019-08-12 stsp cmp -s $testroot/stderr.expected $testroot/stderr
869 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
870 fc66b545 2019-08-12 stsp diff -u $testroot/stderr.expected $testroot/stderr
871 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
875 fc66b545 2019-08-12 stsp echo "Rebase of refs/heads/newbranch aborted" \
876 fc66b545 2019-08-12 stsp > $testroot/stdout.expected
877 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
879 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
880 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
881 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
885 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
886 fc66b545 2019-08-12 stsp echo "Already up-to-date" > $testroot/stdout.expected
887 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
889 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
890 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
892 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
895 f6cae3ed 2020-09-13 naddy test_rebase_forward() {
896 38b0338b 2019-11-29 stsp local testroot=`test_init rebase_forward`
897 38b0338b 2019-11-29 stsp local commit0=`git_show_head $testroot/repo`
899 38b0338b 2019-11-29 stsp got checkout $testroot/repo $testroot/wt > /dev/null
901 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
902 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
906 38b0338b 2019-11-29 stsp echo "change alpha 1" > $testroot/wt/alpha
907 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
908 38b0338b 2019-11-29 stsp > /dev/null)
909 38b0338b 2019-11-29 stsp local commit1=`git_show_head $testroot/repo`
911 38b0338b 2019-11-29 stsp echo "change alpha 2" > $testroot/wt/alpha
912 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
913 38b0338b 2019-11-29 stsp > /dev/null)
914 38b0338b 2019-11-29 stsp local commit2=`git_show_head $testroot/repo`
916 38b0338b 2019-11-29 stsp # Simulate a situation where fast-forward is required.
917 38b0338b 2019-11-29 stsp # We want to fast-forward master to origin/master:
918 38b0338b 2019-11-29 stsp # commit 3907e11dceaae2ca7f8db79c2af31794673945ad (origin/master)
919 38b0338b 2019-11-29 stsp # commit ffcffcd102cf1af6572fbdbb4cf07a0f1fd2d840 (master)
920 38b0338b 2019-11-29 stsp # commit 87a6a8a2263a15b61c016ff1720b24741d455eb5
921 993f033b 2021-07-16 stsp (cd $testroot/repo && got ref -d master >/dev/null)
922 e31abbf2 2020-03-22 stsp (cd $testroot/repo && got ref -c $commit1 refs/heads/master)
923 e31abbf2 2020-03-22 stsp (cd $testroot/repo && got ref -c $commit2 refs/remotes/origin/master)
925 38b0338b 2019-11-29 stsp (cd $testroot/wt && got up -b origin/master > /dev/null)
927 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase master \
928 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
930 38b0338b 2019-11-29 stsp echo "Forwarding refs/heads/master to commit $commit2" \
931 38b0338b 2019-11-29 stsp > $testroot/stdout.expected
932 38b0338b 2019-11-29 stsp echo "Switching work tree to refs/heads/master" \
933 38b0338b 2019-11-29 stsp >> $testroot/stdout.expected
934 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
936 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
937 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
938 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
942 38b0338b 2019-11-29 stsp # Ensure that rebase operation was completed correctly
943 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase -a \
944 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
945 38b0338b 2019-11-29 stsp echo -n "" > $testroot/stdout.expected
946 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
948 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
949 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
950 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
953 38b0338b 2019-11-29 stsp echo "got: rebase operation not in progress" > $testroot/stderr.expected
954 38b0338b 2019-11-29 stsp cmp -s $testroot/stderr.expected $testroot/stderr
956 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
957 38b0338b 2019-11-29 stsp diff -u $testroot/stderr.expected $testroot/stderr
958 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
962 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n > $testroot/stdout)
963 38b0338b 2019-11-29 stsp echo "master" > $testroot/stdout.expected
964 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
966 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
967 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
968 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
972 38b0338b 2019-11-29 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
973 38b0338b 2019-11-29 stsp echo "commit $commit2 (master, origin/master)" > $testroot/stdout.expected
974 38b0338b 2019-11-29 stsp echo "commit $commit1" >> $testroot/stdout.expected
975 38b0338b 2019-11-29 stsp echo "commit $commit0" >> $testroot/stdout.expected
976 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
978 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
979 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
980 e600f124 2021-03-21 stsp test_done "$testroot" "$ret"
984 e600f124 2021-03-21 stsp # Forward-only rebase operations should not be backed up
985 e600f124 2021-03-21 stsp (cd $testroot/repo && got rebase -l > $testroot/stdout)
986 e600f124 2021-03-21 stsp echo -n > $testroot/stdout.expected
987 e600f124 2021-03-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
989 e600f124 2021-03-21 stsp if [ "$ret" != "0" ]; then
990 e600f124 2021-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
992 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
995 f6cae3ed 2020-09-13 naddy test_rebase_out_of_date() {
996 e51d7b55 2020-01-04 stsp local testroot=`test_init rebase_out_of_date`
997 e51d7b55 2020-01-04 stsp local initial_commit=`git_show_head $testroot/repo`
999 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1000 e51d7b55 2020-01-04 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1001 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1003 e51d7b55 2020-01-04 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1004 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git rm -q beta)
1005 e51d7b55 2020-01-04 stsp echo "new file on branch" > $testroot/repo/epsilon/new
1006 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git add epsilon/new)
1007 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
1009 e51d7b55 2020-01-04 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1010 e51d7b55 2020-01-04 stsp local orig_commit2=`git_show_head $testroot/repo`
1012 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
1013 e51d7b55 2020-01-04 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1014 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to zeta on master"
1015 e51d7b55 2020-01-04 stsp local master_commit1=`git_show_head $testroot/repo`
1017 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
1018 e51d7b55 2020-01-04 stsp echo "modified beta on master" > $testroot/repo/beta
1019 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to beta on master"
1020 e51d7b55 2020-01-04 stsp local master_commit2=`git_show_head $testroot/repo`
1022 e51d7b55 2020-01-04 stsp got checkout -c $master_commit1 $testroot/repo $testroot/wt \
1023 e51d7b55 2020-01-04 stsp > /dev/null
1025 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
1026 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1030 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
1031 e51d7b55 2020-01-04 stsp 2> $testroot/stderr)
1033 e51d7b55 2020-01-04 stsp echo -n > $testroot/stdout.expected
1034 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1036 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
1037 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
1038 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1042 e51d7b55 2020-01-04 stsp echo -n "got: work tree must be updated before it can be " \
1043 e51d7b55 2020-01-04 stsp > $testroot/stderr.expected
1044 e51d7b55 2020-01-04 stsp echo "used to rebase a branch" >> $testroot/stderr.expected
1045 e51d7b55 2020-01-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1047 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
1048 e51d7b55 2020-01-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
1049 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1053 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1054 e51d7b55 2020-01-04 stsp echo "commit $master_commit2 (master)" > $testroot/stdout.expected
1055 e51d7b55 2020-01-04 stsp echo "commit $master_commit1" >> $testroot/stdout.expected
1056 e51d7b55 2020-01-04 stsp echo "commit $initial_commit" >> $testroot/stdout.expected
1057 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1059 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1060 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1062 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1065 f6cae3ed 2020-09-13 naddy test_rebase_trims_empty_dir() {
1066 1ae0a341 2020-02-14 stsp local testroot=`test_init rebase_trims_empty_dir`
1068 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1069 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1070 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1072 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git rm -q epsilon/zeta)
1073 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "removing zeta on newbranch"
1075 1ae0a341 2020-02-14 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1076 1ae0a341 2020-02-14 stsp local orig_commit2=`git_show_head $testroot/repo`
1078 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q master)
1079 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/repo/alpha
1080 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to alpha on master"
1081 1ae0a341 2020-02-14 stsp local master_commit=`git_show_head $testroot/repo`
1083 1ae0a341 2020-02-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1085 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1086 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1090 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1092 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q newbranch)
1093 1ae0a341 2020-02-14 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
1094 1ae0a341 2020-02-14 stsp local new_commit2=`git_show_head $testroot/repo`
1096 1ae0a341 2020-02-14 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1097 1ae0a341 2020-02-14 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1098 1ae0a341 2020-02-14 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1099 1ae0a341 2020-02-14 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1101 1ae0a341 2020-02-14 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1102 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1103 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1104 1ae0a341 2020-02-14 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1105 1ae0a341 2020-02-14 stsp echo "D epsilon/zeta" >> $testroot/stdout.expected
1106 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1107 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1108 1ae0a341 2020-02-14 stsp echo ": removing zeta on newbranch" \
1109 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1110 1ae0a341 2020-02-14 stsp echo "Switching work tree to refs/heads/newbranch" \
1111 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1113 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1115 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
1116 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
1117 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1121 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/content.expected
1122 1ae0a341 2020-02-14 stsp cat $testroot/wt/gamma/delta > $testroot/content
1123 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1125 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1126 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1127 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1131 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/content.expected
1132 1ae0a341 2020-02-14 stsp cat $testroot/wt/alpha > $testroot/content
1133 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1135 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1136 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1137 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1141 1ae0a341 2020-02-14 stsp if [ -e $testroot/wt/epsilon ]; then
1142 1ae0a341 2020-02-14 stsp echo "parent of removed zeta still exists on disk" >&2
1143 1ae0a341 2020-02-14 stsp test_done "$testroot" "1"
1147 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got status > $testroot/stdout)
1149 1ae0a341 2020-02-14 stsp echo -n > $testroot/stdout.expected
1150 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1152 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1153 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1154 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1158 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1159 1ae0a341 2020-02-14 stsp echo "commit $new_commit2 (newbranch)" > $testroot/stdout.expected
1160 1ae0a341 2020-02-14 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1161 1ae0a341 2020-02-14 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1162 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1164 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1165 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1167 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1170 f6cae3ed 2020-09-13 naddy test_rebase_delete_missing_file() {
1171 ca6da77d 2020-03-22 stsp local testroot=`test_init rebase_delete_missing_file`
1173 ca6da77d 2020-03-22 stsp mkdir -p $testroot/repo/d/f/g
1174 ca6da77d 2020-03-22 stsp echo "new file" > $testroot/repo/d/f/g/new
1175 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git add d/f/g/new)
1176 ca6da77d 2020-03-22 stsp git_commit $testroot/repo -m "adding a subdir"
1177 ca6da77d 2020-03-22 stsp local commit0=`git_show_head $testroot/repo`
1179 a740a1b3 2020-03-22 stsp got br -r $testroot/repo -c master newbranch
1181 a740a1b3 2020-03-22 stsp got checkout -b newbranch $testroot/repo $testroot/wt > /dev/null
1183 a740a1b3 2020-03-22 stsp echo "modified delta on branch" > $testroot/wt/gamma/delta
1184 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1185 a740a1b3 2020-03-22 stsp -m "committing to delta on newbranch" > /dev/null)
1187 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1188 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1189 a740a1b3 2020-03-22 stsp -m "removing beta and d/f/g/new on newbranch" > /dev/null)
1191 a740a1b3 2020-03-22 stsp (cd $testroot/repo && git checkout -q newbranch)
1192 ca6da77d 2020-03-22 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1193 ca6da77d 2020-03-22 stsp local orig_commit2=`git_show_head $testroot/repo`
1195 1fa49072 2021-09-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1196 1fa49072 2021-09-28 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1198 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got update -b master > /dev/null)
1199 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1200 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1201 a740a1b3 2020-03-22 stsp -m "removing beta and d/f/g/new on master" > /dev/null)
1203 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git checkout -q master)
1204 ca6da77d 2020-03-22 stsp local master_commit=`git_show_head $testroot/repo`
1206 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got update -b master > /dev/null)
1207 1fa49072 2021-09-28 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
1208 1fa49072 2021-09-28 stsp 2> $testroot/stderr)
1210 1fa49072 2021-09-28 stsp if [ "$ret" = "0" ]; then
1211 1fa49072 2021-09-28 stsp echo "rebase succeeded unexpectedly" >&2
1212 1fa49072 2021-09-28 stsp test_done "$testroot" "1"
1216 1fa49072 2021-09-28 stsp local new_commit1=$(cd $testroot/wt && got info | \
1217 1fa49072 2021-09-28 stsp grep '^work tree base commit: ' | cut -d: -f2 | tr -d ' ')
1219 ca6da77d 2020-03-22 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1220 ca6da77d 2020-03-22 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1222 ca6da77d 2020-03-22 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1223 ca6da77d 2020-03-22 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1224 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1225 ca6da77d 2020-03-22 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1226 ca6da77d 2020-03-22 stsp echo "! beta" >> $testroot/stdout.expected
1227 ca6da77d 2020-03-22 stsp echo "! d/f/g/new" >> $testroot/stdout.expected
1228 35ca1db7 2021-09-28 stsp echo -n "Files which had incoming changes but could not be found " \
1229 35ca1db7 2021-09-28 stsp >> $testroot/stdout.expected
1230 35ca1db7 2021-09-28 stsp echo "in the work tree: 2" >> $testroot/stdout.expected
1231 1fa49072 2021-09-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1233 1fa49072 2021-09-28 stsp if [ "$ret" != "0" ]; then
1234 1fa49072 2021-09-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1235 1fa49072 2021-09-28 stsp test_done "$testroot" "$ret"
1239 1fa49072 2021-09-28 stsp echo -n "got: changes destined for some files were not yet merged " \
1240 1fa49072 2021-09-28 stsp > $testroot/stderr.expected
1241 1fa49072 2021-09-28 stsp echo -n "and should be merged manually if required before the " \
1242 1fa49072 2021-09-28 stsp >> $testroot/stderr.expected
1243 1fa49072 2021-09-28 stsp echo "rebase operation is continued" >> $testroot/stderr.expected
1244 1fa49072 2021-09-28 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1246 1fa49072 2021-09-28 stsp if [ "$ret" != "0" ]; then
1247 1fa49072 2021-09-28 stsp diff -u $testroot/stderr.expected $testroot/stderr
1248 1fa49072 2021-09-28 stsp test_done "$testroot" "$ret"
1252 1fa49072 2021-09-28 stsp # ignore the missing changes and continue
1253 1fa49072 2021-09-28 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
1255 1fa49072 2021-09-28 stsp if [ "$ret" != "0" ]; then
1256 1fa49072 2021-09-28 stsp echo "rebase failed unexpectedly" >&2
1257 1fa49072 2021-09-28 stsp test_done "$testroot" "1"
1260 ca6da77d 2020-03-22 stsp echo -n "$short_orig_commit2 -> no-op change" \
1261 1fa49072 2021-09-28 stsp > $testroot/stdout.expected
1262 a740a1b3 2020-03-22 stsp echo ": removing beta and d/f/g/new on newbranch" \
1263 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1264 ca6da77d 2020-03-22 stsp echo "Switching work tree to refs/heads/newbranch" \
1265 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1267 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1269 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1270 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1271 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1275 ca6da77d 2020-03-22 stsp echo "modified delta on branch" > $testroot/content.expected
1276 ca6da77d 2020-03-22 stsp cat $testroot/wt/gamma/delta > $testroot/content
1277 ca6da77d 2020-03-22 stsp cmp -s $testroot/content.expected $testroot/content
1279 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1280 ca6da77d 2020-03-22 stsp diff -u $testroot/content.expected $testroot/content
1281 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1285 ca6da77d 2020-03-22 stsp if [ -e $testroot/wt/beta ]; then
1286 ca6da77d 2020-03-22 stsp echo "removed file beta still exists on disk" >&2
1287 ca6da77d 2020-03-22 stsp test_done "$testroot" "1"
1291 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got status > $testroot/stdout)
1293 ca6da77d 2020-03-22 stsp echo -n > $testroot/stdout.expected
1294 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1296 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1297 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1298 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1302 1fa49072 2021-09-28 stsp (cd $testroot/repo && git checkout -q newbranch)
1303 1fa49072 2021-09-28 stsp local new_commit1=`git_show_head $testroot/repo`
1304 1fa49072 2021-09-28 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1306 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1307 ca6da77d 2020-03-22 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
1308 ca6da77d 2020-03-22 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1309 ca6da77d 2020-03-22 stsp echo "commit $commit0" >> $testroot/stdout.expected
1310 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1312 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1313 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1315 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1318 f6cae3ed 2020-09-13 naddy test_rebase_rm_add_rm_file() {
1319 70551d57 2020-04-24 stsp local testroot=`test_init rebase_rm_add_rm_file`
1321 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1322 70551d57 2020-04-24 stsp (cd $testroot/repo && git rm -q beta)
1323 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "removing beta from newbranch"
1324 70551d57 2020-04-24 stsp local orig_commit1=`git_show_head $testroot/repo`
1326 70551d57 2020-04-24 stsp echo 'restored beta' > $testroot/repo/beta
1327 70551d57 2020-04-24 stsp (cd $testroot/repo && git add beta)
1328 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "restoring beta on newbranch"
1329 70551d57 2020-04-24 stsp local orig_commit2=`git_show_head $testroot/repo`
1331 70551d57 2020-04-24 stsp (cd $testroot/repo && git rm -q beta)
1332 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "removing beta from newbranch again"
1333 70551d57 2020-04-24 stsp local orig_commit3=`git_show_head $testroot/repo`
1335 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q master)
1336 70551d57 2020-04-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1337 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
1338 70551d57 2020-04-24 stsp local master_commit=`git_show_head $testroot/repo`
1340 70551d57 2020-04-24 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1342 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1343 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1347 70551d57 2020-04-24 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1349 70551d57 2020-04-24 stsp # this would error out with 'got: file index is corrupt'
1350 70551d57 2020-04-24 stsp (cd $testroot/wt && got status > /dev/null)
1352 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1353 70551d57 2020-04-24 stsp echo "got status command failed unexpectedly" >&2
1354 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1358 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q newbranch)
1359 70551d57 2020-04-24 stsp local new_commit3=`git_show_head $testroot/repo`
1360 70551d57 2020-04-24 stsp local new_commit2=`git_show_parent_commit $testroot/repo`
1361 70551d57 2020-04-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo $new_commit2`
1363 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q newbranch)
1365 70551d57 2020-04-24 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1366 70551d57 2020-04-24 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1367 70551d57 2020-04-24 stsp local short_orig_commit3=`trim_obj_id 28 $orig_commit3`
1368 70551d57 2020-04-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1369 70551d57 2020-04-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1370 70551d57 2020-04-24 stsp local short_new_commit3=`trim_obj_id 28 $new_commit3`
1372 70551d57 2020-04-24 stsp echo "D beta" > $testroot/stdout.expected
1373 70551d57 2020-04-24 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1374 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1375 70551d57 2020-04-24 stsp echo ": removing beta from newbranch" >> $testroot/stdout.expected
1376 70551d57 2020-04-24 stsp echo "A beta" >> $testroot/stdout.expected
1377 70551d57 2020-04-24 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1378 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1379 70551d57 2020-04-24 stsp echo ": restoring beta on newbranch" >> $testroot/stdout.expected
1380 70551d57 2020-04-24 stsp echo "D beta" >> $testroot/stdout.expected
1381 70551d57 2020-04-24 stsp echo -n "$short_orig_commit3 -> $short_new_commit3" \
1382 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1383 70551d57 2020-04-24 stsp echo ": removing beta from newbranch again" >> $testroot/stdout.expected
1384 70551d57 2020-04-24 stsp echo "Switching work tree to refs/heads/newbranch" \
1385 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1387 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1389 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1390 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1391 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1395 70551d57 2020-04-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1397 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1398 70551d57 2020-04-24 stsp echo "got status command failed unexpectedly" >&2
1399 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1403 70551d57 2020-04-24 stsp echo -n > $testroot/stdout.expected
1404 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1406 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1407 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1408 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1412 70551d57 2020-04-24 stsp (cd $testroot/wt && got log -l4 | grep ^commit > $testroot/stdout)
1413 70551d57 2020-04-24 stsp echo "commit $new_commit3 (newbranch)" > $testroot/stdout.expected
1414 70551d57 2020-04-24 stsp echo "commit $new_commit2" >> $testroot/stdout.expected
1415 70551d57 2020-04-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1416 70551d57 2020-04-24 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1417 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1419 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1420 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1422 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1425 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1426 dcf44d04 2019-07-11 stsp run_test test_rebase_basic
1427 dcf44d04 2019-07-11 stsp run_test test_rebase_ancestry_check
1428 dcf44d04 2019-07-11 stsp run_test test_rebase_continue
1429 dcf44d04 2019-07-11 stsp run_test test_rebase_abort
1430 ff0d2220 2019-07-11 stsp run_test test_rebase_no_op_change
1431 7d5807f4 2019-07-11 stsp run_test test_rebase_in_progress
1432 64c6d990 2019-07-11 stsp run_test test_rebase_path_prefix
1433 787c8eb6 2019-07-11 stsp run_test test_rebase_preserves_logmsg
1434 fc66b545 2019-08-12 stsp run_test test_rebase_no_commits_to_rebase
1435 38b0338b 2019-11-29 stsp run_test test_rebase_forward
1436 e51d7b55 2020-01-04 stsp run_test test_rebase_out_of_date
1437 1ae0a341 2020-02-14 stsp run_test test_rebase_trims_empty_dir
1438 ca6da77d 2020-03-22 stsp run_test test_rebase_delete_missing_file
1439 70551d57 2020-04-24 stsp run_test test_rebase_rm_add_rm_file