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"
153 e600f124 2021-03-21 stsp # We should have a backup of old commits
154 e600f124 2021-03-21 stsp (cd $testroot/repo && got rebase -l > $testroot/stdout)
155 e600f124 2021-03-21 stsp d_orig2=`env TZ=UTC date -r $orig_author_time2 +"%a %b %e %X %Y UTC"`
156 e600f124 2021-03-21 stsp d_new2=`env TZ=UTC date -r $new_author_time2 +"%G-%m-%d"`
157 e600f124 2021-03-21 stsp d_0=`env TZ=UTC date -r $commit0_author_time +"%G-%m-%d"`
158 e600f124 2021-03-21 stsp cat > $testroot/stdout.expected <<EOF
159 e600f124 2021-03-21 stsp -----------------------------------------------
160 e600f124 2021-03-21 stsp commit $orig_commit2 (formerly newbranch)
161 e600f124 2021-03-21 stsp from: $GOT_AUTHOR
162 e600f124 2021-03-21 stsp date: $d_orig2
164 e600f124 2021-03-21 stsp committing more changes on newbranch
166 e600f124 2021-03-21 stsp has become commit $new_commit2 (newbranch)
167 e600f124 2021-03-21 stsp $d_new2 $GOT_AUTHOR_11 committing more changes on newbranch
168 e600f124 2021-03-21 stsp history forked at $commit0
169 e600f124 2021-03-21 stsp $d_0 $GOT_AUTHOR_11 adding the test tree
171 e600f124 2021-03-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
173 e600f124 2021-03-21 stsp if [ "$ret" != "0" ]; then
174 e600f124 2021-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
175 9e822917 2021-03-23 stsp test_done "$testroot" "$ret"
178 9e822917 2021-03-23 stsp # Asking for backups of a branch which has none should yield an error
179 9e822917 2021-03-23 stsp (cd $testroot/repo && got rebase -l master \
180 9e822917 2021-03-23 stsp > $testroot/stdout 2> $testroot/stderr)
181 9e822917 2021-03-23 stsp echo -n > $testroot/stdout.expected
182 9e822917 2021-03-23 stsp echo "got: refs/got/backup/rebase/master/: no such reference found" \
183 9e822917 2021-03-23 stsp > $testroot/stderr.expected
184 9e822917 2021-03-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
186 9e822917 2021-03-23 stsp if [ "$ret" != "0" ]; then
187 9e822917 2021-03-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
188 9e822917 2021-03-23 stsp test_done "$testroot" "$ret"
191 9e822917 2021-03-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
193 9e822917 2021-03-23 stsp if [ "$ret" != "0" ]; then
194 9e822917 2021-03-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
195 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
199 643b85bc 2021-07-16 stsp # Delete all backup refs
200 643b85bc 2021-07-16 stsp (cd $testroot/repo && got rebase -X \
201 643b85bc 2021-07-16 stsp > $testroot/stdout 2> $testroot/stderr)
202 643b85bc 2021-07-16 stsp echo -n "Deleted refs/got/backup/rebase/newbranch/$new_commit2: " \
203 643b85bc 2021-07-16 stsp > $testroot/stdout.expected
204 643b85bc 2021-07-16 stsp echo "$orig_commit2" >> $testroot/stdout.expected
205 643b85bc 2021-07-16 stsp echo -n > $testroot/stderr.expected
206 643b85bc 2021-07-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
208 643b85bc 2021-07-16 stsp if [ "$ret" != "0" ]; then
209 643b85bc 2021-07-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
210 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
213 643b85bc 2021-07-16 stsp cmp -s $testroot/stderr.expected $testroot/stderr
215 643b85bc 2021-07-16 stsp if [ "$ret" != "0" ]; then
216 643b85bc 2021-07-16 stsp diff -u $testroot/stderr.expected $testroot/stderr
217 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
221 643b85bc 2021-07-16 stsp (cd $testroot/repo && got rebase -l > $testroot/stdout)
222 643b85bc 2021-07-16 stsp echo -n > $testroot/stdout.expected
223 643b85bc 2021-07-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
225 643b85bc 2021-07-16 stsp if [ "$ret" != "0" ]; then
226 643b85bc 2021-07-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
228 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
231 f6cae3ed 2020-09-13 naddy test_rebase_ancestry_check() {
232 818c7501 2019-07-11 stsp local testroot=`test_init rebase_ancestry_check`
234 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
236 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
237 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
241 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
242 818c7501 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
243 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
245 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
246 818c7501 2019-07-11 stsp 2> $testroot/stderr)
248 818c7501 2019-07-11 stsp echo -n > $testroot/stdout.expected
249 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
251 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
252 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
253 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
257 df3ed485 2021-01-31 stsp echo "got: refs/heads/newbranch is already based on refs/heads/master" \
258 818c7501 2019-07-11 stsp > $testroot/stderr.expected
259 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
261 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
262 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
264 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
267 f6cae3ed 2020-09-13 naddy test_rebase_continue() {
268 818c7501 2019-07-11 stsp local testroot=`test_init rebase_continue`
269 f69721c3 2019-10-21 stsp local init_commit=`git_show_head $testroot/repo`
271 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
272 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
273 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
274 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
275 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
277 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
278 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
279 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
280 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
282 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
284 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
285 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
289 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
290 818c7501 2019-07-11 stsp 2> $testroot/stderr)
292 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
293 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
294 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
295 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
296 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
297 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
299 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
300 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
301 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
305 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
306 818c7501 2019-07-11 stsp > $testroot/stderr.expected
307 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
309 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
310 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
311 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
315 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
316 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
317 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
318 f69721c3 2019-10-21 stsp >> $testroot/content.expected
319 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
320 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
321 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
322 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
323 54d5be07 2021-06-03 stsp >> $testroot/content.expected
324 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
325 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
327 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
328 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
329 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
333 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
335 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
336 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
338 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
339 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
340 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
344 818c7501 2019-07-11 stsp # resolve the conflict
345 818c7501 2019-07-11 stsp echo "modified alpha on branch and master" > $testroot/wt/alpha
347 f032f1f7 2019-08-04 stsp # test interaction of 'got stage' and rebase -c
348 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got stage alpha > /dev/null)
349 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout \
350 f032f1f7 2019-08-04 stsp 2> $testroot/stderr)
352 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
353 f032f1f7 2019-08-04 stsp echo "rebase succeeded unexpectedly" >&2
354 f032f1f7 2019-08-04 stsp test_done "$testroot" "1"
357 f032f1f7 2019-08-04 stsp echo -n "got: work tree contains files with staged changes; " \
358 f032f1f7 2019-08-04 stsp > $testroot/stderr.expected
359 f032f1f7 2019-08-04 stsp echo "these changes must be committed or unstaged first" \
360 f032f1f7 2019-08-04 stsp >> $testroot/stderr.expected
361 f032f1f7 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
363 f032f1f7 2019-08-04 stsp if [ "$ret" != "0" ]; then
364 f032f1f7 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
365 f032f1f7 2019-08-04 stsp test_done "$testroot" "$ret"
369 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got unstage alpha > /dev/null)
370 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
372 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
373 818c7501 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
374 818c7501 2019-07-11 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
376 818c7501 2019-07-11 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
377 818c7501 2019-07-11 stsp > $testroot/stdout.expected
378 818c7501 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
379 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
380 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
382 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
384 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
385 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
386 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
391 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
392 818c7501 2019-07-11 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
393 818c7501 2019-07-11 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
394 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
396 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
397 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
399 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
402 f6cae3ed 2020-09-13 naddy test_rebase_abort() {
403 818c7501 2019-07-11 stsp local testroot=`test_init rebase_abort`
405 818c7501 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
407 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
408 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
409 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
410 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
411 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
413 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
414 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
415 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
416 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
418 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
420 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
421 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
425 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
426 818c7501 2019-07-11 stsp 2> $testroot/stderr)
428 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
429 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
430 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
431 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
432 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
433 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
435 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
436 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
437 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
441 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
442 818c7501 2019-07-11 stsp > $testroot/stderr.expected
443 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
445 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
446 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
447 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
451 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
452 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
453 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
454 f69721c3 2019-10-21 stsp >> $testroot/content.expected
455 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
456 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
457 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
458 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
459 54d5be07 2021-06-03 stsp >> $testroot/content.expected
460 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
461 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
463 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
464 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
465 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
469 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
471 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
472 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
474 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
475 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
476 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
480 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -a > $testroot/stdout)
482 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
484 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/master" \
485 818c7501 2019-07-11 stsp > $testroot/stdout.expected
486 818c7501 2019-07-11 stsp echo 'R alpha' >> $testroot/stdout.expected
487 818c7501 2019-07-11 stsp echo "Rebase of refs/heads/newbranch aborted" \
488 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
490 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
492 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
493 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
494 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
498 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/content.expected
499 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
500 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
502 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
503 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
504 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
508 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l3 -c newbranch \
509 818c7501 2019-07-11 stsp | grep ^commit > $testroot/stdout)
510 818c7501 2019-07-11 stsp echo "commit $orig_commit1 (newbranch)" > $testroot/stdout.expected
511 818c7501 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
512 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
514 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
515 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
517 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
520 f6cae3ed 2020-09-13 naddy test_rebase_no_op_change() {
521 ff0d2220 2019-07-11 stsp local testroot=`test_init rebase_no_op_change`
522 ff0d2220 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
524 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
525 ff0d2220 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
526 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
527 ff0d2220 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
528 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
530 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
531 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
532 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
533 ff0d2220 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
535 ff0d2220 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
537 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
538 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
542 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
543 ff0d2220 2019-07-11 stsp 2> $testroot/stderr)
545 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
546 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
547 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
548 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
549 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
550 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
552 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
553 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
554 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
558 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
559 ff0d2220 2019-07-11 stsp > $testroot/stderr.expected
560 ff0d2220 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
562 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
563 ff0d2220 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
564 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
568 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
569 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
570 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
571 f69721c3 2019-10-21 stsp >> $testroot/content.expected
572 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
573 ff0d2220 2019-07-11 stsp echo "=======" >> $testroot/content.expected
574 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
575 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
576 54d5be07 2021-06-03 stsp >> $testroot/content.expected
577 ff0d2220 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
578 ff0d2220 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
580 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
581 ff0d2220 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
582 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
586 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
588 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
589 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
591 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
592 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
593 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
597 ff0d2220 2019-07-11 stsp # resolve the conflict
598 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/wt/alpha
600 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
602 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
603 ff0d2220 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
605 ff0d2220 2019-07-11 stsp echo -n "$short_orig_commit1 -> no-op change" \
606 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
607 ff0d2220 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
608 ff0d2220 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
609 ff0d2220 2019-07-11 stsp >> $testroot/stdout.expected
611 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
613 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
614 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
615 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
620 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
621 ff0d2220 2019-07-11 stsp echo "commit $master_commit (master, newbranch)" \
622 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
623 ff0d2220 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
624 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
626 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
627 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
629 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
632 f6cae3ed 2020-09-13 naddy test_rebase_in_progress() {
633 4ba9c4f6 2019-07-11 stsp local testroot=`test_init rebase_in_progress`
634 7d5807f4 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
636 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
637 7d5807f4 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
638 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
639 7d5807f4 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
640 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
642 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
643 7d5807f4 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
644 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
645 7d5807f4 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
647 7d5807f4 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
649 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
650 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
654 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
655 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
657 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
658 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
659 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
660 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
661 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
662 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
664 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
665 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
666 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
670 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
671 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
672 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
674 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
675 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
676 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
680 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
681 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
682 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
683 f69721c3 2019-10-21 stsp >> $testroot/content.expected
684 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
685 7d5807f4 2019-07-11 stsp echo "=======" >> $testroot/content.expected
686 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
687 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
688 54d5be07 2021-06-03 stsp >> $testroot/content.expected
689 7d5807f4 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
690 7d5807f4 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
692 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
693 7d5807f4 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
694 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
698 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
700 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
701 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
703 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
704 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
705 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
709 7d5807f4 2019-07-11 stsp for cmd in update commit; do
710 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got $cmd > $testroot/stdout \
711 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
713 7d5807f4 2019-07-11 stsp echo -n > $testroot/stdout.expected
714 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
716 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
717 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
718 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
722 7d5807f4 2019-07-11 stsp echo -n "got: a rebase operation is in progress in this " \
723 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
724 7d5807f4 2019-07-11 stsp echo "work tree and must be continued or aborted first" \
725 7d5807f4 2019-07-11 stsp >> $testroot/stderr.expected
726 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
728 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
729 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
730 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
735 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
738 f6cae3ed 2020-09-13 naddy test_rebase_path_prefix() {
739 64c6d990 2019-07-11 stsp local testroot=`test_init rebase_path_prefix`
741 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
742 64c6d990 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
743 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
745 64c6d990 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
746 64c6d990 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
748 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
749 64c6d990 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
750 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
751 64c6d990 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
753 64c6d990 2019-07-11 stsp got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
755 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
756 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
760 64c6d990 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch \
761 64c6d990 2019-07-11 stsp > $testroot/stdout 2> $testroot/stderr)
763 64c6d990 2019-07-11 stsp echo -n > $testroot/stdout.expected
764 64c6d990 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
766 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
767 64c6d990 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
768 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
772 64c6d990 2019-07-11 stsp echo -n "got: cannot rebase branch which contains changes outside " \
773 64c6d990 2019-07-11 stsp > $testroot/stderr.expected
774 64c6d990 2019-07-11 stsp echo "of this work tree's path prefix" >> $testroot/stderr.expected
775 787c8eb6 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
777 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
778 787c8eb6 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
780 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
783 f6cae3ed 2020-09-13 naddy test_rebase_preserves_logmsg() {
784 787c8eb6 2019-07-11 stsp local testroot=`test_init rebase_preserves_logmsg`
786 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
787 787c8eb6 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
788 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified delta on newbranch"
790 787c8eb6 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
791 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified alpha on newbranch"
793 787c8eb6 2019-07-11 stsp (cd $testroot/repo && got log -c newbranch -l2 | grep -v ^date: \
794 787c8eb6 2019-07-11 stsp > $testroot/log.expected)
796 787c8eb6 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
797 787c8eb6 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
799 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
800 787c8eb6 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
801 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
802 787c8eb6 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
804 787c8eb6 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
806 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
807 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
811 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > /dev/null \
812 787c8eb6 2019-07-11 stsp 2> $testroot/stderr)
814 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
815 787c8eb6 2019-07-11 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
816 787c8eb6 2019-07-11 stsp local new_commit2=`git_show_head $testroot/repo`
818 787c8eb6 2019-07-11 stsp echo -n > $testroot/stderr.expected
819 64c6d990 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
821 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
822 64c6d990 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
823 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
827 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got log -c newbranch -l2 | grep -v ^date: \
828 787c8eb6 2019-07-11 stsp > $testroot/log)
829 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit1/$new_commit1/" $testroot/log.expected
830 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit2/$new_commit2/" $testroot/log.expected
831 787c8eb6 2019-07-11 stsp cmp -s $testroot/log.expected $testroot/log
833 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
834 787c8eb6 2019-07-11 stsp diff -u $testroot/log.expected $testroot/log
837 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
840 f6cae3ed 2020-09-13 naddy test_rebase_no_commits_to_rebase() {
841 fc66b545 2019-08-12 stsp local testroot=`test_init rebase_no_commits_to_rebase`
843 fc66b545 2019-08-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
845 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
846 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
850 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n newbranch)
852 fc66b545 2019-08-12 stsp echo "modified alpha on master" > $testroot/wt/alpha
853 fc66b545 2019-08-12 stsp (cd $testroot/wt && got commit -m 'test rebase_no_commits_to_rebase' \
854 fc66b545 2019-08-12 stsp > /dev/null)
855 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > /dev/null)
857 fc66b545 2019-08-12 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
858 fc66b545 2019-08-12 stsp 2> $testroot/stderr)
860 fc66b545 2019-08-12 stsp echo "got: no commits to rebase" > $testroot/stderr.expected
861 fc66b545 2019-08-12 stsp cmp -s $testroot/stderr.expected $testroot/stderr
863 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
864 fc66b545 2019-08-12 stsp diff -u $testroot/stderr.expected $testroot/stderr
865 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
869 fc66b545 2019-08-12 stsp echo "Rebase of refs/heads/newbranch aborted" \
870 fc66b545 2019-08-12 stsp > $testroot/stdout.expected
871 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
873 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
874 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
875 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
879 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
880 fc66b545 2019-08-12 stsp echo "Already up-to-date" > $testroot/stdout.expected
881 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
883 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
884 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
886 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
889 f6cae3ed 2020-09-13 naddy test_rebase_forward() {
890 38b0338b 2019-11-29 stsp local testroot=`test_init rebase_forward`
891 38b0338b 2019-11-29 stsp local commit0=`git_show_head $testroot/repo`
893 38b0338b 2019-11-29 stsp got checkout $testroot/repo $testroot/wt > /dev/null
895 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
896 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
900 38b0338b 2019-11-29 stsp echo "change alpha 1" > $testroot/wt/alpha
901 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
902 38b0338b 2019-11-29 stsp > /dev/null)
903 38b0338b 2019-11-29 stsp local commit1=`git_show_head $testroot/repo`
905 38b0338b 2019-11-29 stsp echo "change alpha 2" > $testroot/wt/alpha
906 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
907 38b0338b 2019-11-29 stsp > /dev/null)
908 38b0338b 2019-11-29 stsp local commit2=`git_show_head $testroot/repo`
910 38b0338b 2019-11-29 stsp # Simulate a situation where fast-forward is required.
911 38b0338b 2019-11-29 stsp # We want to fast-forward master to origin/master:
912 38b0338b 2019-11-29 stsp # commit 3907e11dceaae2ca7f8db79c2af31794673945ad (origin/master)
913 38b0338b 2019-11-29 stsp # commit ffcffcd102cf1af6572fbdbb4cf07a0f1fd2d840 (master)
914 38b0338b 2019-11-29 stsp # commit 87a6a8a2263a15b61c016ff1720b24741d455eb5
915 993f033b 2021-07-16 stsp (cd $testroot/repo && got ref -d master >/dev/null)
916 e31abbf2 2020-03-22 stsp (cd $testroot/repo && got ref -c $commit1 refs/heads/master)
917 e31abbf2 2020-03-22 stsp (cd $testroot/repo && got ref -c $commit2 refs/remotes/origin/master)
919 38b0338b 2019-11-29 stsp (cd $testroot/wt && got up -b origin/master > /dev/null)
921 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase master \
922 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
924 38b0338b 2019-11-29 stsp echo "Forwarding refs/heads/master to commit $commit2" \
925 38b0338b 2019-11-29 stsp > $testroot/stdout.expected
926 38b0338b 2019-11-29 stsp echo "Switching work tree to refs/heads/master" \
927 38b0338b 2019-11-29 stsp >> $testroot/stdout.expected
928 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
930 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
931 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
932 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
936 38b0338b 2019-11-29 stsp # Ensure that rebase operation was completed correctly
937 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase -a \
938 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
939 38b0338b 2019-11-29 stsp echo -n "" > $testroot/stdout.expected
940 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
942 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
943 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
944 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
947 38b0338b 2019-11-29 stsp echo "got: rebase operation not in progress" > $testroot/stderr.expected
948 38b0338b 2019-11-29 stsp cmp -s $testroot/stderr.expected $testroot/stderr
950 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
951 38b0338b 2019-11-29 stsp diff -u $testroot/stderr.expected $testroot/stderr
952 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
956 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n > $testroot/stdout)
957 38b0338b 2019-11-29 stsp echo "master" > $testroot/stdout.expected
958 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
960 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
961 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
962 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
966 38b0338b 2019-11-29 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
967 38b0338b 2019-11-29 stsp echo "commit $commit2 (master, origin/master)" > $testroot/stdout.expected
968 38b0338b 2019-11-29 stsp echo "commit $commit1" >> $testroot/stdout.expected
969 38b0338b 2019-11-29 stsp echo "commit $commit0" >> $testroot/stdout.expected
970 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
972 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
973 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
974 e600f124 2021-03-21 stsp test_done "$testroot" "$ret"
977 e600f124 2021-03-21 stsp # Forward-only rebase operations should not be backed up
978 e600f124 2021-03-21 stsp (cd $testroot/repo && got rebase -l > $testroot/stdout)
979 e600f124 2021-03-21 stsp echo -n > $testroot/stdout.expected
980 e600f124 2021-03-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
982 e600f124 2021-03-21 stsp if [ "$ret" != "0" ]; then
983 e600f124 2021-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
985 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
988 f6cae3ed 2020-09-13 naddy test_rebase_out_of_date() {
989 e51d7b55 2020-01-04 stsp local testroot=`test_init rebase_out_of_date`
990 e51d7b55 2020-01-04 stsp local initial_commit=`git_show_head $testroot/repo`
992 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q -b newbranch)
993 e51d7b55 2020-01-04 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
994 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
996 e51d7b55 2020-01-04 stsp echo "modified alpha on branch" > $testroot/repo/alpha
997 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git rm -q beta)
998 e51d7b55 2020-01-04 stsp echo "new file on branch" > $testroot/repo/epsilon/new
999 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git add epsilon/new)
1000 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
1002 e51d7b55 2020-01-04 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1003 e51d7b55 2020-01-04 stsp local orig_commit2=`git_show_head $testroot/repo`
1005 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
1006 e51d7b55 2020-01-04 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1007 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to zeta on master"
1008 e51d7b55 2020-01-04 stsp local master_commit1=`git_show_head $testroot/repo`
1010 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
1011 e51d7b55 2020-01-04 stsp echo "modified beta on master" > $testroot/repo/beta
1012 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to beta on master"
1013 e51d7b55 2020-01-04 stsp local master_commit2=`git_show_head $testroot/repo`
1015 e51d7b55 2020-01-04 stsp got checkout -c $master_commit1 $testroot/repo $testroot/wt \
1016 e51d7b55 2020-01-04 stsp > /dev/null
1018 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
1019 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1023 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
1024 e51d7b55 2020-01-04 stsp 2> $testroot/stderr)
1026 e51d7b55 2020-01-04 stsp echo -n > $testroot/stdout.expected
1027 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1029 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
1030 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
1031 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1035 e51d7b55 2020-01-04 stsp echo -n "got: work tree must be updated before it can be " \
1036 e51d7b55 2020-01-04 stsp > $testroot/stderr.expected
1037 e51d7b55 2020-01-04 stsp echo "used to rebase a branch" >> $testroot/stderr.expected
1038 e51d7b55 2020-01-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1040 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
1041 e51d7b55 2020-01-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
1042 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1046 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1047 e51d7b55 2020-01-04 stsp echo "commit $master_commit2 (master)" > $testroot/stdout.expected
1048 e51d7b55 2020-01-04 stsp echo "commit $master_commit1" >> $testroot/stdout.expected
1049 e51d7b55 2020-01-04 stsp echo "commit $initial_commit" >> $testroot/stdout.expected
1050 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1052 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1053 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1055 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1058 f6cae3ed 2020-09-13 naddy test_rebase_trims_empty_dir() {
1059 1ae0a341 2020-02-14 stsp local testroot=`test_init rebase_trims_empty_dir`
1061 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1062 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1063 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1065 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git rm -q epsilon/zeta)
1066 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "removing zeta on newbranch"
1068 1ae0a341 2020-02-14 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1069 1ae0a341 2020-02-14 stsp local orig_commit2=`git_show_head $testroot/repo`
1071 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q master)
1072 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/repo/alpha
1073 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to alpha on master"
1074 1ae0a341 2020-02-14 stsp local master_commit=`git_show_head $testroot/repo`
1076 1ae0a341 2020-02-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1078 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1079 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1083 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1085 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q newbranch)
1086 1ae0a341 2020-02-14 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
1087 1ae0a341 2020-02-14 stsp local new_commit2=`git_show_head $testroot/repo`
1089 1ae0a341 2020-02-14 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1090 1ae0a341 2020-02-14 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1091 1ae0a341 2020-02-14 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1092 1ae0a341 2020-02-14 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1094 1ae0a341 2020-02-14 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1095 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1096 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1097 1ae0a341 2020-02-14 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1098 1ae0a341 2020-02-14 stsp echo "D epsilon/zeta" >> $testroot/stdout.expected
1099 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1100 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1101 1ae0a341 2020-02-14 stsp echo ": removing zeta on newbranch" \
1102 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1103 1ae0a341 2020-02-14 stsp echo "Switching work tree to refs/heads/newbranch" \
1104 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1106 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1108 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
1109 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
1110 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1114 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/content.expected
1115 1ae0a341 2020-02-14 stsp cat $testroot/wt/gamma/delta > $testroot/content
1116 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1118 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1119 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1120 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1124 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/content.expected
1125 1ae0a341 2020-02-14 stsp cat $testroot/wt/alpha > $testroot/content
1126 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1128 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1129 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1130 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1134 1ae0a341 2020-02-14 stsp if [ -e $testroot/wt/epsilon ]; then
1135 1ae0a341 2020-02-14 stsp echo "parent of removed zeta still exists on disk" >&2
1136 1ae0a341 2020-02-14 stsp test_done "$testroot" "1"
1140 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got status > $testroot/stdout)
1142 1ae0a341 2020-02-14 stsp echo -n > $testroot/stdout.expected
1143 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1145 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1146 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1147 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1151 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1152 1ae0a341 2020-02-14 stsp echo "commit $new_commit2 (newbranch)" > $testroot/stdout.expected
1153 1ae0a341 2020-02-14 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1154 1ae0a341 2020-02-14 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1155 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1157 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1158 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1160 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1163 f6cae3ed 2020-09-13 naddy test_rebase_delete_missing_file() {
1164 ca6da77d 2020-03-22 stsp local testroot=`test_init rebase_delete_missing_file`
1166 ca6da77d 2020-03-22 stsp mkdir -p $testroot/repo/d/f/g
1167 ca6da77d 2020-03-22 stsp echo "new file" > $testroot/repo/d/f/g/new
1168 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git add d/f/g/new)
1169 ca6da77d 2020-03-22 stsp git_commit $testroot/repo -m "adding a subdir"
1170 ca6da77d 2020-03-22 stsp local commit0=`git_show_head $testroot/repo`
1172 a740a1b3 2020-03-22 stsp got br -r $testroot/repo -c master newbranch
1174 a740a1b3 2020-03-22 stsp got checkout -b newbranch $testroot/repo $testroot/wt > /dev/null
1176 a740a1b3 2020-03-22 stsp echo "modified delta on branch" > $testroot/wt/gamma/delta
1177 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1178 a740a1b3 2020-03-22 stsp -m "committing to delta on newbranch" > /dev/null)
1180 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1181 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1182 a740a1b3 2020-03-22 stsp -m "removing beta and d/f/g/new on newbranch" > /dev/null)
1184 a740a1b3 2020-03-22 stsp (cd $testroot/repo && git checkout -q newbranch)
1185 ca6da77d 2020-03-22 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1186 ca6da77d 2020-03-22 stsp local orig_commit2=`git_show_head $testroot/repo`
1188 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got update -b master > /dev/null)
1189 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1190 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1191 a740a1b3 2020-03-22 stsp -m "removing beta and d/f/g/new on master" > /dev/null)
1193 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git checkout -q master)
1194 ca6da77d 2020-03-22 stsp local master_commit=`git_show_head $testroot/repo`
1196 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got update -b master > /dev/null)
1197 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1199 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git checkout -q newbranch)
1200 ca6da77d 2020-03-22 stsp local new_commit1=`git_show_head $testroot/repo`
1202 ca6da77d 2020-03-22 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1203 ca6da77d 2020-03-22 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1204 ca6da77d 2020-03-22 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1206 ca6da77d 2020-03-22 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1207 ca6da77d 2020-03-22 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1208 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1209 ca6da77d 2020-03-22 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1210 ca6da77d 2020-03-22 stsp echo "! beta" >> $testroot/stdout.expected
1211 ca6da77d 2020-03-22 stsp echo "! d/f/g/new" >> $testroot/stdout.expected
1212 ca6da77d 2020-03-22 stsp echo -n "$short_orig_commit2 -> no-op change" \
1213 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1214 a740a1b3 2020-03-22 stsp echo ": removing beta and d/f/g/new on newbranch" \
1215 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1216 ca6da77d 2020-03-22 stsp echo "Switching work tree to refs/heads/newbranch" \
1217 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1219 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1221 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1222 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1223 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1227 ca6da77d 2020-03-22 stsp echo "modified delta on branch" > $testroot/content.expected
1228 ca6da77d 2020-03-22 stsp cat $testroot/wt/gamma/delta > $testroot/content
1229 ca6da77d 2020-03-22 stsp cmp -s $testroot/content.expected $testroot/content
1231 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1232 ca6da77d 2020-03-22 stsp diff -u $testroot/content.expected $testroot/content
1233 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1237 ca6da77d 2020-03-22 stsp if [ -e $testroot/wt/beta ]; then
1238 ca6da77d 2020-03-22 stsp echo "removed file beta still exists on disk" >&2
1239 ca6da77d 2020-03-22 stsp test_done "$testroot" "1"
1243 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got status > $testroot/stdout)
1245 ca6da77d 2020-03-22 stsp echo -n > $testroot/stdout.expected
1246 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1248 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1249 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1250 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1254 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1255 ca6da77d 2020-03-22 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
1256 ca6da77d 2020-03-22 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1257 ca6da77d 2020-03-22 stsp echo "commit $commit0" >> $testroot/stdout.expected
1258 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1260 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1261 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1263 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1266 f6cae3ed 2020-09-13 naddy test_rebase_rm_add_rm_file() {
1267 70551d57 2020-04-24 stsp local testroot=`test_init rebase_rm_add_rm_file`
1269 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1270 70551d57 2020-04-24 stsp (cd $testroot/repo && git rm -q beta)
1271 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "removing beta from newbranch"
1272 70551d57 2020-04-24 stsp local orig_commit1=`git_show_head $testroot/repo`
1274 70551d57 2020-04-24 stsp echo 'restored beta' > $testroot/repo/beta
1275 70551d57 2020-04-24 stsp (cd $testroot/repo && git add beta)
1276 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "restoring beta on newbranch"
1277 70551d57 2020-04-24 stsp local orig_commit2=`git_show_head $testroot/repo`
1279 70551d57 2020-04-24 stsp (cd $testroot/repo && git rm -q beta)
1280 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "removing beta from newbranch again"
1281 70551d57 2020-04-24 stsp local orig_commit3=`git_show_head $testroot/repo`
1283 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q master)
1284 70551d57 2020-04-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1285 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
1286 70551d57 2020-04-24 stsp local master_commit=`git_show_head $testroot/repo`
1288 70551d57 2020-04-24 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1290 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1291 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1295 70551d57 2020-04-24 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1297 70551d57 2020-04-24 stsp # this would error out with 'got: file index is corrupt'
1298 70551d57 2020-04-24 stsp (cd $testroot/wt && got status > /dev/null)
1300 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1301 70551d57 2020-04-24 stsp echo "got status command failed unexpectedly" >&2
1302 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1306 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q newbranch)
1307 70551d57 2020-04-24 stsp local new_commit3=`git_show_head $testroot/repo`
1308 70551d57 2020-04-24 stsp local new_commit2=`git_show_parent_commit $testroot/repo`
1309 70551d57 2020-04-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo $new_commit2`
1311 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q newbranch)
1313 70551d57 2020-04-24 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1314 70551d57 2020-04-24 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1315 70551d57 2020-04-24 stsp local short_orig_commit3=`trim_obj_id 28 $orig_commit3`
1316 70551d57 2020-04-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1317 70551d57 2020-04-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1318 70551d57 2020-04-24 stsp local short_new_commit3=`trim_obj_id 28 $new_commit3`
1320 70551d57 2020-04-24 stsp echo "D beta" > $testroot/stdout.expected
1321 70551d57 2020-04-24 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1322 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1323 70551d57 2020-04-24 stsp echo ": removing beta from newbranch" >> $testroot/stdout.expected
1324 70551d57 2020-04-24 stsp echo "A beta" >> $testroot/stdout.expected
1325 70551d57 2020-04-24 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1326 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1327 70551d57 2020-04-24 stsp echo ": restoring beta on newbranch" >> $testroot/stdout.expected
1328 70551d57 2020-04-24 stsp echo "D beta" >> $testroot/stdout.expected
1329 70551d57 2020-04-24 stsp echo -n "$short_orig_commit3 -> $short_new_commit3" \
1330 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1331 70551d57 2020-04-24 stsp echo ": removing beta from newbranch again" >> $testroot/stdout.expected
1332 70551d57 2020-04-24 stsp echo "Switching work tree to refs/heads/newbranch" \
1333 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1335 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1337 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1338 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1339 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1343 70551d57 2020-04-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1345 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1346 70551d57 2020-04-24 stsp echo "got status command failed unexpectedly" >&2
1347 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1351 70551d57 2020-04-24 stsp echo -n > $testroot/stdout.expected
1352 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1354 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1355 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1356 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1360 70551d57 2020-04-24 stsp (cd $testroot/wt && got log -l4 | grep ^commit > $testroot/stdout)
1361 70551d57 2020-04-24 stsp echo "commit $new_commit3 (newbranch)" > $testroot/stdout.expected
1362 70551d57 2020-04-24 stsp echo "commit $new_commit2" >> $testroot/stdout.expected
1363 70551d57 2020-04-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1364 70551d57 2020-04-24 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1365 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1367 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1368 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1370 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1373 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1374 dcf44d04 2019-07-11 stsp run_test test_rebase_basic
1375 dcf44d04 2019-07-11 stsp run_test test_rebase_ancestry_check
1376 dcf44d04 2019-07-11 stsp run_test test_rebase_continue
1377 dcf44d04 2019-07-11 stsp run_test test_rebase_abort
1378 ff0d2220 2019-07-11 stsp run_test test_rebase_no_op_change
1379 7d5807f4 2019-07-11 stsp run_test test_rebase_in_progress
1380 64c6d990 2019-07-11 stsp run_test test_rebase_path_prefix
1381 787c8eb6 2019-07-11 stsp run_test test_rebase_preserves_logmsg
1382 fc66b545 2019-08-12 stsp run_test test_rebase_no_commits_to_rebase
1383 38b0338b 2019-11-29 stsp run_test test_rebase_forward
1384 e51d7b55 2020-01-04 stsp run_test test_rebase_out_of_date
1385 1ae0a341 2020-02-14 stsp run_test test_rebase_trims_empty_dir
1386 ca6da77d 2020-03-22 stsp run_test test_rebase_delete_missing_file
1387 70551d57 2020-04-24 stsp run_test test_rebase_rm_add_rm_file