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"
190 9e822917 2021-03-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
192 9e822917 2021-03-23 stsp if [ "$ret" != "0" ]; then
193 9e822917 2021-03-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
195 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
198 f6cae3ed 2020-09-13 naddy test_rebase_ancestry_check() {
199 818c7501 2019-07-11 stsp local testroot=`test_init rebase_ancestry_check`
201 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
203 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
204 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
208 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
209 818c7501 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
210 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
212 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
213 818c7501 2019-07-11 stsp 2> $testroot/stderr)
215 818c7501 2019-07-11 stsp echo -n > $testroot/stdout.expected
216 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
218 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
219 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
220 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
224 df3ed485 2021-01-31 stsp echo "got: refs/heads/newbranch is already based on refs/heads/master" \
225 818c7501 2019-07-11 stsp > $testroot/stderr.expected
226 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
228 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
229 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
231 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
234 f6cae3ed 2020-09-13 naddy test_rebase_continue() {
235 818c7501 2019-07-11 stsp local testroot=`test_init rebase_continue`
236 f69721c3 2019-10-21 stsp local init_commit=`git_show_head $testroot/repo`
238 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
239 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
240 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
241 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
242 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
244 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
245 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
246 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
247 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
249 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
251 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
252 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
256 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
257 818c7501 2019-07-11 stsp 2> $testroot/stderr)
259 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
260 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
261 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
262 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
263 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
264 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
266 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
267 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
268 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
272 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
273 818c7501 2019-07-11 stsp > $testroot/stderr.expected
274 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
276 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
277 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
278 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
282 f69721c3 2019-10-21 stsp echo "<<<<<<< merged change: commit $orig_commit1" \
283 f69721c3 2019-10-21 stsp > $testroot/content.expected
284 818c7501 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
285 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
286 f69721c3 2019-10-21 stsp >> $testroot/content.expected
287 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
288 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
289 818c7501 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
290 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
291 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
292 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
294 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
295 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
296 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
300 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
302 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
303 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
305 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
306 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
307 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
311 818c7501 2019-07-11 stsp # resolve the conflict
312 818c7501 2019-07-11 stsp echo "modified alpha on branch and master" > $testroot/wt/alpha
314 f032f1f7 2019-08-04 stsp # test interaction of 'got stage' and rebase -c
315 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got stage alpha > /dev/null)
316 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout \
317 f032f1f7 2019-08-04 stsp 2> $testroot/stderr)
319 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
320 f032f1f7 2019-08-04 stsp echo "rebase succeeded unexpectedly" >&2
321 f032f1f7 2019-08-04 stsp test_done "$testroot" "1"
324 f032f1f7 2019-08-04 stsp echo -n "got: work tree contains files with staged changes; " \
325 f032f1f7 2019-08-04 stsp > $testroot/stderr.expected
326 f032f1f7 2019-08-04 stsp echo "these changes must be committed or unstaged first" \
327 f032f1f7 2019-08-04 stsp >> $testroot/stderr.expected
328 f032f1f7 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
330 f032f1f7 2019-08-04 stsp if [ "$ret" != "0" ]; then
331 f032f1f7 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
332 f032f1f7 2019-08-04 stsp test_done "$testroot" "$ret"
336 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got unstage alpha > /dev/null)
337 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
339 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
340 818c7501 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
341 818c7501 2019-07-11 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
343 818c7501 2019-07-11 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
344 818c7501 2019-07-11 stsp > $testroot/stdout.expected
345 818c7501 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
346 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
347 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
349 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
351 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
352 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
353 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
358 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
359 818c7501 2019-07-11 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
360 818c7501 2019-07-11 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
361 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
363 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
364 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
366 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
369 f6cae3ed 2020-09-13 naddy test_rebase_abort() {
370 818c7501 2019-07-11 stsp local testroot=`test_init rebase_abort`
372 818c7501 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
374 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
375 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
376 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
377 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
378 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
380 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
381 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
382 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
383 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
385 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
387 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
388 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
392 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
393 818c7501 2019-07-11 stsp 2> $testroot/stderr)
395 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
396 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
397 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
398 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
399 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
400 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
402 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
403 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
404 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
408 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
409 818c7501 2019-07-11 stsp > $testroot/stderr.expected
410 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
412 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
413 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
414 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
418 f69721c3 2019-10-21 stsp echo "<<<<<<< merged change: commit $orig_commit1" \
419 f69721c3 2019-10-21 stsp > $testroot/content.expected
420 818c7501 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
421 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
422 f69721c3 2019-10-21 stsp >> $testroot/content.expected
423 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
424 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
425 818c7501 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
426 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
427 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
428 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
430 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
431 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
432 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
436 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
438 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
439 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
441 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
442 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
443 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
447 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -a > $testroot/stdout)
449 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
451 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/master" \
452 818c7501 2019-07-11 stsp > $testroot/stdout.expected
453 818c7501 2019-07-11 stsp echo 'R alpha' >> $testroot/stdout.expected
454 818c7501 2019-07-11 stsp echo "Rebase of refs/heads/newbranch aborted" \
455 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
457 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
459 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
460 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
461 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
465 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/content.expected
466 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
467 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
469 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
470 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
471 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
475 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l3 -c newbranch \
476 818c7501 2019-07-11 stsp | grep ^commit > $testroot/stdout)
477 818c7501 2019-07-11 stsp echo "commit $orig_commit1 (newbranch)" > $testroot/stdout.expected
478 818c7501 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
479 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
481 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
482 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
484 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
487 f6cae3ed 2020-09-13 naddy test_rebase_no_op_change() {
488 ff0d2220 2019-07-11 stsp local testroot=`test_init rebase_no_op_change`
489 ff0d2220 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
491 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
492 ff0d2220 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
493 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
494 ff0d2220 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
495 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
497 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
498 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
499 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
500 ff0d2220 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
502 ff0d2220 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
504 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
505 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
509 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
510 ff0d2220 2019-07-11 stsp 2> $testroot/stderr)
512 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
513 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
514 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
515 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
516 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
517 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
519 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
520 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
521 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
525 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
526 ff0d2220 2019-07-11 stsp > $testroot/stderr.expected
527 ff0d2220 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
529 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
530 ff0d2220 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
531 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
535 f69721c3 2019-10-21 stsp echo "<<<<<<< merged change: commit $orig_commit1" \
536 f69721c3 2019-10-21 stsp > $testroot/content.expected
537 ff0d2220 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
538 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
539 f69721c3 2019-10-21 stsp >> $testroot/content.expected
540 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
541 ff0d2220 2019-07-11 stsp echo "=======" >> $testroot/content.expected
542 ff0d2220 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
543 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
544 ff0d2220 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
545 ff0d2220 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
547 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
548 ff0d2220 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
549 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
553 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
555 ff0d2220 2019-07-11 stsp echo "C alpha" > $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 ff0d2220 2019-07-11 stsp # resolve the conflict
565 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/wt/alpha
567 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
569 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
570 ff0d2220 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
572 ff0d2220 2019-07-11 stsp echo -n "$short_orig_commit1 -> no-op change" \
573 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
574 ff0d2220 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
575 ff0d2220 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
576 ff0d2220 2019-07-11 stsp >> $testroot/stdout.expected
578 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
580 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
581 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
582 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
587 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
588 ff0d2220 2019-07-11 stsp echo "commit $master_commit (master, newbranch)" \
589 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
590 ff0d2220 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
591 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
593 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
594 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
596 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
599 f6cae3ed 2020-09-13 naddy test_rebase_in_progress() {
600 4ba9c4f6 2019-07-11 stsp local testroot=`test_init rebase_in_progress`
601 7d5807f4 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
603 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
604 7d5807f4 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
605 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
606 7d5807f4 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
607 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
609 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
610 7d5807f4 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
611 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
612 7d5807f4 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
614 7d5807f4 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
616 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
617 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
621 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
622 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
624 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
625 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
626 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
627 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
628 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
629 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
631 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
632 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
633 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
637 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
638 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
639 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
641 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
642 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
643 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
647 f69721c3 2019-10-21 stsp echo "<<<<<<< merged change: commit $orig_commit1" \
648 f69721c3 2019-10-21 stsp > $testroot/content.expected
649 7d5807f4 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
650 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
651 f69721c3 2019-10-21 stsp >> $testroot/content.expected
652 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
653 7d5807f4 2019-07-11 stsp echo "=======" >> $testroot/content.expected
654 7d5807f4 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
655 f69721c3 2019-10-21 stsp echo '>>>>>>>' >> $testroot/content.expected
656 7d5807f4 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
657 7d5807f4 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
659 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
660 7d5807f4 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
661 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
665 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
667 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
668 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
670 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
671 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
672 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
676 7d5807f4 2019-07-11 stsp for cmd in update commit; do
677 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got $cmd > $testroot/stdout \
678 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
680 7d5807f4 2019-07-11 stsp echo -n > $testroot/stdout.expected
681 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
683 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
684 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
685 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
689 7d5807f4 2019-07-11 stsp echo -n "got: a rebase operation is in progress in this " \
690 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
691 7d5807f4 2019-07-11 stsp echo "work tree and must be continued or aborted first" \
692 7d5807f4 2019-07-11 stsp >> $testroot/stderr.expected
693 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
695 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
696 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
697 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
702 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
705 f6cae3ed 2020-09-13 naddy test_rebase_path_prefix() {
706 64c6d990 2019-07-11 stsp local testroot=`test_init rebase_path_prefix`
708 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
709 64c6d990 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
710 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
712 64c6d990 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
713 64c6d990 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
715 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
716 64c6d990 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
717 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
718 64c6d990 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
720 64c6d990 2019-07-11 stsp got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
722 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
723 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
727 64c6d990 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch \
728 64c6d990 2019-07-11 stsp > $testroot/stdout 2> $testroot/stderr)
730 64c6d990 2019-07-11 stsp echo -n > $testroot/stdout.expected
731 64c6d990 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
733 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
734 64c6d990 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
735 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
739 64c6d990 2019-07-11 stsp echo -n "got: cannot rebase branch which contains changes outside " \
740 64c6d990 2019-07-11 stsp > $testroot/stderr.expected
741 64c6d990 2019-07-11 stsp echo "of this work tree's path prefix" >> $testroot/stderr.expected
742 787c8eb6 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
744 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
745 787c8eb6 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
747 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
750 f6cae3ed 2020-09-13 naddy test_rebase_preserves_logmsg() {
751 787c8eb6 2019-07-11 stsp local testroot=`test_init rebase_preserves_logmsg`
753 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
754 787c8eb6 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
755 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified delta on newbranch"
757 787c8eb6 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
758 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified alpha on newbranch"
760 787c8eb6 2019-07-11 stsp (cd $testroot/repo && got log -c newbranch -l2 | grep -v ^date: \
761 787c8eb6 2019-07-11 stsp > $testroot/log.expected)
763 787c8eb6 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
764 787c8eb6 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
766 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
767 787c8eb6 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
768 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
769 787c8eb6 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
771 787c8eb6 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
773 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
774 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
778 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > /dev/null \
779 787c8eb6 2019-07-11 stsp 2> $testroot/stderr)
781 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
782 787c8eb6 2019-07-11 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
783 787c8eb6 2019-07-11 stsp local new_commit2=`git_show_head $testroot/repo`
785 787c8eb6 2019-07-11 stsp echo -n > $testroot/stderr.expected
786 64c6d990 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
788 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
789 64c6d990 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
790 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
794 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got log -c newbranch -l2 | grep -v ^date: \
795 787c8eb6 2019-07-11 stsp > $testroot/log)
796 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit1/$new_commit1/" $testroot/log.expected
797 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit2/$new_commit2/" $testroot/log.expected
798 787c8eb6 2019-07-11 stsp cmp -s $testroot/log.expected $testroot/log
800 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
801 787c8eb6 2019-07-11 stsp diff -u $testroot/log.expected $testroot/log
804 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
807 f6cae3ed 2020-09-13 naddy test_rebase_no_commits_to_rebase() {
808 fc66b545 2019-08-12 stsp local testroot=`test_init rebase_no_commits_to_rebase`
810 fc66b545 2019-08-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
812 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
813 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
817 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n newbranch)
819 fc66b545 2019-08-12 stsp echo "modified alpha on master" > $testroot/wt/alpha
820 fc66b545 2019-08-12 stsp (cd $testroot/wt && got commit -m 'test rebase_no_commits_to_rebase' \
821 fc66b545 2019-08-12 stsp > /dev/null)
822 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > /dev/null)
824 fc66b545 2019-08-12 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
825 fc66b545 2019-08-12 stsp 2> $testroot/stderr)
827 fc66b545 2019-08-12 stsp echo "got: no commits to rebase" > $testroot/stderr.expected
828 fc66b545 2019-08-12 stsp cmp -s $testroot/stderr.expected $testroot/stderr
830 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
831 fc66b545 2019-08-12 stsp diff -u $testroot/stderr.expected $testroot/stderr
832 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
836 fc66b545 2019-08-12 stsp echo "Rebase of refs/heads/newbranch aborted" \
837 fc66b545 2019-08-12 stsp > $testroot/stdout.expected
838 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
840 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
841 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
842 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
846 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
847 fc66b545 2019-08-12 stsp echo "Already up-to-date" > $testroot/stdout.expected
848 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
850 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
851 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
853 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
856 f6cae3ed 2020-09-13 naddy test_rebase_forward() {
857 38b0338b 2019-11-29 stsp local testroot=`test_init rebase_forward`
858 38b0338b 2019-11-29 stsp local commit0=`git_show_head $testroot/repo`
860 38b0338b 2019-11-29 stsp got checkout $testroot/repo $testroot/wt > /dev/null
862 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
863 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
867 38b0338b 2019-11-29 stsp echo "change alpha 1" > $testroot/wt/alpha
868 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
869 38b0338b 2019-11-29 stsp > /dev/null)
870 38b0338b 2019-11-29 stsp local commit1=`git_show_head $testroot/repo`
872 38b0338b 2019-11-29 stsp echo "change alpha 2" > $testroot/wt/alpha
873 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
874 38b0338b 2019-11-29 stsp > /dev/null)
875 38b0338b 2019-11-29 stsp local commit2=`git_show_head $testroot/repo`
877 38b0338b 2019-11-29 stsp # Simulate a situation where fast-forward is required.
878 38b0338b 2019-11-29 stsp # We want to fast-forward master to origin/master:
879 38b0338b 2019-11-29 stsp # commit 3907e11dceaae2ca7f8db79c2af31794673945ad (origin/master)
880 38b0338b 2019-11-29 stsp # commit ffcffcd102cf1af6572fbdbb4cf07a0f1fd2d840 (master)
881 38b0338b 2019-11-29 stsp # commit 87a6a8a2263a15b61c016ff1720b24741d455eb5
882 38b0338b 2019-11-29 stsp (cd $testroot/repo && got ref -d master)
883 e31abbf2 2020-03-22 stsp (cd $testroot/repo && got ref -c $commit1 refs/heads/master)
884 e31abbf2 2020-03-22 stsp (cd $testroot/repo && got ref -c $commit2 refs/remotes/origin/master)
886 38b0338b 2019-11-29 stsp (cd $testroot/wt && got up -b origin/master > /dev/null)
888 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase master \
889 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
891 38b0338b 2019-11-29 stsp echo "Forwarding refs/heads/master to commit $commit2" \
892 38b0338b 2019-11-29 stsp > $testroot/stdout.expected
893 38b0338b 2019-11-29 stsp echo "Switching work tree to refs/heads/master" \
894 38b0338b 2019-11-29 stsp >> $testroot/stdout.expected
895 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
897 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
898 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
899 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
903 38b0338b 2019-11-29 stsp # Ensure that rebase operation was completed correctly
904 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase -a \
905 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
906 38b0338b 2019-11-29 stsp echo -n "" > $testroot/stdout.expected
907 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
909 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
910 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
911 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
914 38b0338b 2019-11-29 stsp echo "got: rebase operation not in progress" > $testroot/stderr.expected
915 38b0338b 2019-11-29 stsp cmp -s $testroot/stderr.expected $testroot/stderr
917 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
918 38b0338b 2019-11-29 stsp diff -u $testroot/stderr.expected $testroot/stderr
919 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
923 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n > $testroot/stdout)
924 38b0338b 2019-11-29 stsp echo "master" > $testroot/stdout.expected
925 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
927 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
928 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
929 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
933 38b0338b 2019-11-29 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
934 38b0338b 2019-11-29 stsp echo "commit $commit2 (master, origin/master)" > $testroot/stdout.expected
935 38b0338b 2019-11-29 stsp echo "commit $commit1" >> $testroot/stdout.expected
936 38b0338b 2019-11-29 stsp echo "commit $commit0" >> $testroot/stdout.expected
937 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
939 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
940 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
941 e600f124 2021-03-21 stsp test_done "$testroot" "$ret"
944 e600f124 2021-03-21 stsp # Forward-only rebase operations should not be backed up
945 e600f124 2021-03-21 stsp (cd $testroot/repo && got rebase -l > $testroot/stdout)
946 e600f124 2021-03-21 stsp echo -n > $testroot/stdout.expected
947 e600f124 2021-03-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
949 e600f124 2021-03-21 stsp if [ "$ret" != "0" ]; then
950 e600f124 2021-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
952 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
955 f6cae3ed 2020-09-13 naddy test_rebase_out_of_date() {
956 e51d7b55 2020-01-04 stsp local testroot=`test_init rebase_out_of_date`
957 e51d7b55 2020-01-04 stsp local initial_commit=`git_show_head $testroot/repo`
959 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q -b newbranch)
960 e51d7b55 2020-01-04 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
961 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
963 e51d7b55 2020-01-04 stsp echo "modified alpha on branch" > $testroot/repo/alpha
964 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git rm -q beta)
965 e51d7b55 2020-01-04 stsp echo "new file on branch" > $testroot/repo/epsilon/new
966 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git add epsilon/new)
967 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
969 e51d7b55 2020-01-04 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
970 e51d7b55 2020-01-04 stsp local orig_commit2=`git_show_head $testroot/repo`
972 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
973 e51d7b55 2020-01-04 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
974 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to zeta on master"
975 e51d7b55 2020-01-04 stsp local master_commit1=`git_show_head $testroot/repo`
977 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
978 e51d7b55 2020-01-04 stsp echo "modified beta on master" > $testroot/repo/beta
979 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to beta on master"
980 e51d7b55 2020-01-04 stsp local master_commit2=`git_show_head $testroot/repo`
982 e51d7b55 2020-01-04 stsp got checkout -c $master_commit1 $testroot/repo $testroot/wt \
983 e51d7b55 2020-01-04 stsp > /dev/null
985 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
986 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
990 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
991 e51d7b55 2020-01-04 stsp 2> $testroot/stderr)
993 e51d7b55 2020-01-04 stsp echo -n > $testroot/stdout.expected
994 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
996 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
997 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
998 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1002 e51d7b55 2020-01-04 stsp echo -n "got: work tree must be updated before it can be " \
1003 e51d7b55 2020-01-04 stsp > $testroot/stderr.expected
1004 e51d7b55 2020-01-04 stsp echo "used to rebase a branch" >> $testroot/stderr.expected
1005 e51d7b55 2020-01-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1007 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
1008 e51d7b55 2020-01-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
1009 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1013 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1014 e51d7b55 2020-01-04 stsp echo "commit $master_commit2 (master)" > $testroot/stdout.expected
1015 e51d7b55 2020-01-04 stsp echo "commit $master_commit1" >> $testroot/stdout.expected
1016 e51d7b55 2020-01-04 stsp echo "commit $initial_commit" >> $testroot/stdout.expected
1017 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1019 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1020 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1022 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1025 f6cae3ed 2020-09-13 naddy test_rebase_trims_empty_dir() {
1026 1ae0a341 2020-02-14 stsp local testroot=`test_init rebase_trims_empty_dir`
1028 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1029 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1030 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1032 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git rm -q epsilon/zeta)
1033 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "removing zeta on newbranch"
1035 1ae0a341 2020-02-14 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1036 1ae0a341 2020-02-14 stsp local orig_commit2=`git_show_head $testroot/repo`
1038 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q master)
1039 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/repo/alpha
1040 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to alpha on master"
1041 1ae0a341 2020-02-14 stsp local master_commit=`git_show_head $testroot/repo`
1043 1ae0a341 2020-02-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1045 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1046 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1050 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1052 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q newbranch)
1053 1ae0a341 2020-02-14 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
1054 1ae0a341 2020-02-14 stsp local new_commit2=`git_show_head $testroot/repo`
1056 1ae0a341 2020-02-14 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1057 1ae0a341 2020-02-14 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1058 1ae0a341 2020-02-14 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1059 1ae0a341 2020-02-14 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1061 1ae0a341 2020-02-14 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1062 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1063 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1064 1ae0a341 2020-02-14 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1065 1ae0a341 2020-02-14 stsp echo "D epsilon/zeta" >> $testroot/stdout.expected
1066 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1067 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1068 1ae0a341 2020-02-14 stsp echo ": removing zeta on newbranch" \
1069 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1070 1ae0a341 2020-02-14 stsp echo "Switching work tree to refs/heads/newbranch" \
1071 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1073 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1075 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
1076 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
1077 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1081 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/content.expected
1082 1ae0a341 2020-02-14 stsp cat $testroot/wt/gamma/delta > $testroot/content
1083 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1085 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1086 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1087 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1091 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/content.expected
1092 1ae0a341 2020-02-14 stsp cat $testroot/wt/alpha > $testroot/content
1093 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1095 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1096 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1097 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1101 1ae0a341 2020-02-14 stsp if [ -e $testroot/wt/epsilon ]; then
1102 1ae0a341 2020-02-14 stsp echo "parent of removed zeta still exists on disk" >&2
1103 1ae0a341 2020-02-14 stsp test_done "$testroot" "1"
1107 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got status > $testroot/stdout)
1109 1ae0a341 2020-02-14 stsp echo -n > $testroot/stdout.expected
1110 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1112 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1113 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1114 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1118 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1119 1ae0a341 2020-02-14 stsp echo "commit $new_commit2 (newbranch)" > $testroot/stdout.expected
1120 1ae0a341 2020-02-14 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1121 1ae0a341 2020-02-14 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1122 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1124 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1125 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1127 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1130 f6cae3ed 2020-09-13 naddy test_rebase_delete_missing_file() {
1131 ca6da77d 2020-03-22 stsp local testroot=`test_init rebase_delete_missing_file`
1133 ca6da77d 2020-03-22 stsp mkdir -p $testroot/repo/d/f/g
1134 ca6da77d 2020-03-22 stsp echo "new file" > $testroot/repo/d/f/g/new
1135 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git add d/f/g/new)
1136 ca6da77d 2020-03-22 stsp git_commit $testroot/repo -m "adding a subdir"
1137 ca6da77d 2020-03-22 stsp local commit0=`git_show_head $testroot/repo`
1139 a740a1b3 2020-03-22 stsp got br -r $testroot/repo -c master newbranch
1141 a740a1b3 2020-03-22 stsp got checkout -b newbranch $testroot/repo $testroot/wt > /dev/null
1143 a740a1b3 2020-03-22 stsp echo "modified delta on branch" > $testroot/wt/gamma/delta
1144 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1145 a740a1b3 2020-03-22 stsp -m "committing to delta on newbranch" > /dev/null)
1147 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1148 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1149 a740a1b3 2020-03-22 stsp -m "removing beta and d/f/g/new on newbranch" > /dev/null)
1151 a740a1b3 2020-03-22 stsp (cd $testroot/repo && git checkout -q newbranch)
1152 ca6da77d 2020-03-22 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1153 ca6da77d 2020-03-22 stsp local orig_commit2=`git_show_head $testroot/repo`
1155 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got update -b master > /dev/null)
1156 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1157 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1158 a740a1b3 2020-03-22 stsp -m "removing beta and d/f/g/new on master" > /dev/null)
1160 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git checkout -q master)
1161 ca6da77d 2020-03-22 stsp local master_commit=`git_show_head $testroot/repo`
1163 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got update -b master > /dev/null)
1164 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1166 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git checkout -q newbranch)
1167 ca6da77d 2020-03-22 stsp local new_commit1=`git_show_head $testroot/repo`
1169 ca6da77d 2020-03-22 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1170 ca6da77d 2020-03-22 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1171 ca6da77d 2020-03-22 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1173 ca6da77d 2020-03-22 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1174 ca6da77d 2020-03-22 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1175 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1176 ca6da77d 2020-03-22 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1177 ca6da77d 2020-03-22 stsp echo "! beta" >> $testroot/stdout.expected
1178 ca6da77d 2020-03-22 stsp echo "! d/f/g/new" >> $testroot/stdout.expected
1179 ca6da77d 2020-03-22 stsp echo -n "$short_orig_commit2 -> no-op change" \
1180 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1181 a740a1b3 2020-03-22 stsp echo ": removing beta and d/f/g/new on newbranch" \
1182 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1183 ca6da77d 2020-03-22 stsp echo "Switching work tree to refs/heads/newbranch" \
1184 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1186 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1188 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1189 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1190 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1194 ca6da77d 2020-03-22 stsp echo "modified delta on branch" > $testroot/content.expected
1195 ca6da77d 2020-03-22 stsp cat $testroot/wt/gamma/delta > $testroot/content
1196 ca6da77d 2020-03-22 stsp cmp -s $testroot/content.expected $testroot/content
1198 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1199 ca6da77d 2020-03-22 stsp diff -u $testroot/content.expected $testroot/content
1200 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1204 ca6da77d 2020-03-22 stsp if [ -e $testroot/wt/beta ]; then
1205 ca6da77d 2020-03-22 stsp echo "removed file beta still exists on disk" >&2
1206 ca6da77d 2020-03-22 stsp test_done "$testroot" "1"
1210 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got status > $testroot/stdout)
1212 ca6da77d 2020-03-22 stsp echo -n > $testroot/stdout.expected
1213 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1215 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1216 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1217 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1221 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1222 ca6da77d 2020-03-22 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
1223 ca6da77d 2020-03-22 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1224 ca6da77d 2020-03-22 stsp echo "commit $commit0" >> $testroot/stdout.expected
1225 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1227 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1228 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1230 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1233 f6cae3ed 2020-09-13 naddy test_rebase_rm_add_rm_file() {
1234 70551d57 2020-04-24 stsp local testroot=`test_init rebase_rm_add_rm_file`
1236 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1237 70551d57 2020-04-24 stsp (cd $testroot/repo && git rm -q beta)
1238 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "removing beta from newbranch"
1239 70551d57 2020-04-24 stsp local orig_commit1=`git_show_head $testroot/repo`
1241 70551d57 2020-04-24 stsp echo 'restored beta' > $testroot/repo/beta
1242 70551d57 2020-04-24 stsp (cd $testroot/repo && git add beta)
1243 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "restoring beta on newbranch"
1244 70551d57 2020-04-24 stsp local orig_commit2=`git_show_head $testroot/repo`
1246 70551d57 2020-04-24 stsp (cd $testroot/repo && git rm -q beta)
1247 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "removing beta from newbranch again"
1248 70551d57 2020-04-24 stsp local orig_commit3=`git_show_head $testroot/repo`
1250 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q master)
1251 70551d57 2020-04-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1252 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
1253 70551d57 2020-04-24 stsp local master_commit=`git_show_head $testroot/repo`
1255 70551d57 2020-04-24 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1257 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1258 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1262 70551d57 2020-04-24 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1264 70551d57 2020-04-24 stsp # this would error out with 'got: file index is corrupt'
1265 70551d57 2020-04-24 stsp (cd $testroot/wt && got status > /dev/null)
1267 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1268 70551d57 2020-04-24 stsp echo "got status command failed unexpectedly" >&2
1269 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1273 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q newbranch)
1274 70551d57 2020-04-24 stsp local new_commit3=`git_show_head $testroot/repo`
1275 70551d57 2020-04-24 stsp local new_commit2=`git_show_parent_commit $testroot/repo`
1276 70551d57 2020-04-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo $new_commit2`
1278 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q newbranch)
1280 70551d57 2020-04-24 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1281 70551d57 2020-04-24 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1282 70551d57 2020-04-24 stsp local short_orig_commit3=`trim_obj_id 28 $orig_commit3`
1283 70551d57 2020-04-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1284 70551d57 2020-04-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1285 70551d57 2020-04-24 stsp local short_new_commit3=`trim_obj_id 28 $new_commit3`
1287 70551d57 2020-04-24 stsp echo "D beta" > $testroot/stdout.expected
1288 70551d57 2020-04-24 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1289 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1290 70551d57 2020-04-24 stsp echo ": removing beta from newbranch" >> $testroot/stdout.expected
1291 70551d57 2020-04-24 stsp echo "A beta" >> $testroot/stdout.expected
1292 70551d57 2020-04-24 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1293 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1294 70551d57 2020-04-24 stsp echo ": restoring beta on newbranch" >> $testroot/stdout.expected
1295 70551d57 2020-04-24 stsp echo "D beta" >> $testroot/stdout.expected
1296 70551d57 2020-04-24 stsp echo -n "$short_orig_commit3 -> $short_new_commit3" \
1297 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1298 70551d57 2020-04-24 stsp echo ": removing beta from newbranch again" >> $testroot/stdout.expected
1299 70551d57 2020-04-24 stsp echo "Switching work tree to refs/heads/newbranch" \
1300 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1302 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1304 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1305 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1306 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1310 70551d57 2020-04-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1312 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1313 70551d57 2020-04-24 stsp echo "got status command failed unexpectedly" >&2
1314 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1318 70551d57 2020-04-24 stsp echo -n > $testroot/stdout.expected
1319 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1321 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1322 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1323 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1327 70551d57 2020-04-24 stsp (cd $testroot/wt && got log -l4 | grep ^commit > $testroot/stdout)
1328 70551d57 2020-04-24 stsp echo "commit $new_commit3 (newbranch)" > $testroot/stdout.expected
1329 70551d57 2020-04-24 stsp echo "commit $new_commit2" >> $testroot/stdout.expected
1330 70551d57 2020-04-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1331 70551d57 2020-04-24 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1332 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1334 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1335 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1337 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1340 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1341 dcf44d04 2019-07-11 stsp run_test test_rebase_basic
1342 dcf44d04 2019-07-11 stsp run_test test_rebase_ancestry_check
1343 dcf44d04 2019-07-11 stsp run_test test_rebase_continue
1344 dcf44d04 2019-07-11 stsp run_test test_rebase_abort
1345 ff0d2220 2019-07-11 stsp run_test test_rebase_no_op_change
1346 7d5807f4 2019-07-11 stsp run_test test_rebase_in_progress
1347 64c6d990 2019-07-11 stsp run_test test_rebase_path_prefix
1348 787c8eb6 2019-07-11 stsp run_test test_rebase_preserves_logmsg
1349 fc66b545 2019-08-12 stsp run_test test_rebase_no_commits_to_rebase
1350 38b0338b 2019-11-29 stsp run_test test_rebase_forward
1351 e51d7b55 2020-01-04 stsp run_test test_rebase_out_of_date
1352 1ae0a341 2020-02-14 stsp run_test test_rebase_trims_empty_dir
1353 ca6da77d 2020-03-22 stsp run_test test_rebase_delete_missing_file
1354 70551d57 2020-04-24 stsp run_test test_rebase_rm_add_rm_file