3 5aa81393 2020-01-06 stsp # Copyright (c) 2019, 2020 Stefan Sperling <stsp@openbsd.org>
5 818c7501 2019-07-11 stsp # Permission to use, copy, modify, and distribute this software for any
6 818c7501 2019-07-11 stsp # purpose with or without fee is hereby granted, provided that the above
7 818c7501 2019-07-11 stsp # copyright notice and this permission notice appear in all copies.
9 818c7501 2019-07-11 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 818c7501 2019-07-11 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 818c7501 2019-07-11 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 818c7501 2019-07-11 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 818c7501 2019-07-11 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 818c7501 2019-07-11 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 818c7501 2019-07-11 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 818c7501 2019-07-11 stsp . ./common.sh
19 f6cae3ed 2020-09-13 naddy test_rebase_basic() {
20 818c7501 2019-07-11 stsp local testroot=`test_init rebase_basic`
21 e600f124 2021-03-21 stsp local commit0=`git_show_head $testroot/repo`
22 e600f124 2021-03-21 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
24 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
25 818c7501 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
26 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
28 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
29 818c7501 2019-07-11 stsp (cd $testroot/repo && git rm -q beta)
30 818c7501 2019-07-11 stsp echo "new file on branch" > $testroot/repo/epsilon/new
31 818c7501 2019-07-11 stsp (cd $testroot/repo && git add epsilon/new)
32 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
34 818c7501 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
35 818c7501 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
36 e600f124 2021-03-21 stsp local orig_author_time2=`git_show_author_time $testroot/repo`
38 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
39 818c7501 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
40 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
41 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
43 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
45 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
46 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
50 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
52 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
53 818c7501 2019-07-11 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
54 818c7501 2019-07-11 stsp local new_commit2=`git_show_head $testroot/repo`
55 e600f124 2021-03-21 stsp local new_author_time2=`git_show_author_time $testroot/repo`
57 818c7501 2019-07-11 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
58 818c7501 2019-07-11 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
59 818c7501 2019-07-11 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
60 818c7501 2019-07-11 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
62 818c7501 2019-07-11 stsp echo "G gamma/delta" >> $testroot/stdout.expected
63 818c7501 2019-07-11 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
64 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
65 818c7501 2019-07-11 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
66 818c7501 2019-07-11 stsp echo "G alpha" >> $testroot/stdout.expected
67 818c7501 2019-07-11 stsp echo "D beta" >> $testroot/stdout.expected
68 818c7501 2019-07-11 stsp echo "A epsilon/new" >> $testroot/stdout.expected
69 818c7501 2019-07-11 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
70 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
71 818c7501 2019-07-11 stsp echo ": committing more changes on newbranch" \
72 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
73 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
74 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
76 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
78 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
79 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
80 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
84 818c7501 2019-07-11 stsp echo "modified delta on branch" > $testroot/content.expected
85 818c7501 2019-07-11 stsp cat $testroot/wt/gamma/delta > $testroot/content
86 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
88 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
89 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
90 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
94 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/content.expected
95 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
96 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
98 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
99 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
100 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
104 818c7501 2019-07-11 stsp if [ -e $testroot/wt/beta ]; then
105 818c7501 2019-07-11 stsp echo "removed file beta still exists on disk" >&2
106 818c7501 2019-07-11 stsp test_done "$testroot" "1"
110 818c7501 2019-07-11 stsp echo "new file on branch" > $testroot/content.expected
111 818c7501 2019-07-11 stsp cat $testroot/wt/epsilon/new > $testroot/content
112 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
114 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
115 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
116 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
120 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
122 818c7501 2019-07-11 stsp echo -n > $testroot/stdout.expected
123 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
125 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
126 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
127 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
131 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
132 818c7501 2019-07-11 stsp echo "commit $new_commit2 (newbranch)" > $testroot/stdout.expected
133 818c7501 2019-07-11 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
134 818c7501 2019-07-11 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
135 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
137 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
138 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
139 a615e0e7 2020-12-16 stsp test_done "$testroot" "$ret"
143 a615e0e7 2020-12-16 stsp (cd $testroot/wt && got update > $testroot/stdout)
145 a615e0e7 2020-12-16 stsp echo 'Already up-to-date' > $testroot/stdout.expected
146 a615e0e7 2020-12-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
148 a615e0e7 2020-12-16 stsp if [ "$ret" != "0" ]; then
149 a615e0e7 2020-12-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
150 e600f124 2021-03-21 stsp test_done "$testroot" "$ret"
154 e600f124 2021-03-21 stsp # We should have a backup of old commits
155 e600f124 2021-03-21 stsp (cd $testroot/repo && got rebase -l > $testroot/stdout)
156 fa37079f 2021-10-09 thomas local prev_LC_TIME="$LC_TIME"
157 fa37079f 2021-10-09 thomas export LC_TIME=C
158 fa37079f 2021-10-09 thomas d_orig2=`date -u -d "@$orig_author_time2" +"%a %b %e %X %Y UTC"`
159 fa37079f 2021-10-09 thomas export LC_TIME="$prev_LC_TIME"
160 180f111d 2021-09-21 thomas.ad d_new2=`date -u -d "@$new_author_time2" +"%G-%m-%d"`
161 180f111d 2021-09-21 thomas.ad d_0=`date -u -d "@$commit0_author_time" +"%G-%m-%d"`
162 e600f124 2021-03-21 stsp cat > $testroot/stdout.expected <<EOF
163 e600f124 2021-03-21 stsp -----------------------------------------------
164 e600f124 2021-03-21 stsp commit $orig_commit2 (formerly newbranch)
165 e600f124 2021-03-21 stsp from: $GOT_AUTHOR
166 e600f124 2021-03-21 stsp date: $d_orig2
168 e600f124 2021-03-21 stsp committing more changes on newbranch
170 e600f124 2021-03-21 stsp has become commit $new_commit2 (newbranch)
171 e600f124 2021-03-21 stsp $d_new2 $GOT_AUTHOR_11 committing more changes on newbranch
172 e600f124 2021-03-21 stsp history forked at $commit0
173 e600f124 2021-03-21 stsp $d_0 $GOT_AUTHOR_11 adding the test tree
175 e600f124 2021-03-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
177 e600f124 2021-03-21 stsp if [ "$ret" != "0" ]; then
178 e600f124 2021-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
179 9e822917 2021-03-23 stsp test_done "$testroot" "$ret"
183 9e822917 2021-03-23 stsp # Asking for backups of a branch which has none should yield an error
184 9e822917 2021-03-23 stsp (cd $testroot/repo && got rebase -l master \
185 9e822917 2021-03-23 stsp > $testroot/stdout 2> $testroot/stderr)
186 9e822917 2021-03-23 stsp echo -n > $testroot/stdout.expected
187 9e822917 2021-03-23 stsp echo "got: refs/got/backup/rebase/master/: no such reference found" \
188 9e822917 2021-03-23 stsp > $testroot/stderr.expected
189 9e822917 2021-03-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
191 9e822917 2021-03-23 stsp if [ "$ret" != "0" ]; then
192 9e822917 2021-03-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
193 9e822917 2021-03-23 stsp test_done "$testroot" "$ret"
196 9e822917 2021-03-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
198 9e822917 2021-03-23 stsp if [ "$ret" != "0" ]; then
199 9e822917 2021-03-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
200 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
204 643b85bc 2021-07-16 stsp # Delete all backup refs
205 643b85bc 2021-07-16 stsp (cd $testroot/repo && got rebase -X \
206 643b85bc 2021-07-16 stsp > $testroot/stdout 2> $testroot/stderr)
207 643b85bc 2021-07-16 stsp echo -n "Deleted refs/got/backup/rebase/newbranch/$new_commit2: " \
208 643b85bc 2021-07-16 stsp > $testroot/stdout.expected
209 643b85bc 2021-07-16 stsp echo "$orig_commit2" >> $testroot/stdout.expected
210 643b85bc 2021-07-16 stsp echo -n > $testroot/stderr.expected
211 643b85bc 2021-07-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
213 643b85bc 2021-07-16 stsp if [ "$ret" != "0" ]; then
214 643b85bc 2021-07-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
215 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
218 643b85bc 2021-07-16 stsp cmp -s $testroot/stderr.expected $testroot/stderr
220 643b85bc 2021-07-16 stsp if [ "$ret" != "0" ]; then
221 643b85bc 2021-07-16 stsp diff -u $testroot/stderr.expected $testroot/stderr
222 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
226 643b85bc 2021-07-16 stsp (cd $testroot/repo && got rebase -l > $testroot/stdout)
227 643b85bc 2021-07-16 stsp echo -n > $testroot/stdout.expected
228 643b85bc 2021-07-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
230 643b85bc 2021-07-16 stsp if [ "$ret" != "0" ]; then
231 643b85bc 2021-07-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
233 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
236 f6cae3ed 2020-09-13 naddy test_rebase_ancestry_check() {
237 818c7501 2019-07-11 stsp local testroot=`test_init rebase_ancestry_check`
239 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
241 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
242 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
246 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
247 818c7501 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
248 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
250 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
251 818c7501 2019-07-11 stsp 2> $testroot/stderr)
253 818c7501 2019-07-11 stsp echo -n > $testroot/stdout.expected
254 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
256 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
257 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
258 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
262 df3ed485 2021-01-31 stsp echo "got: refs/heads/newbranch is already based on refs/heads/master" \
263 818c7501 2019-07-11 stsp > $testroot/stderr.expected
264 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
266 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
267 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
269 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
272 f6cae3ed 2020-09-13 naddy test_rebase_continue() {
273 818c7501 2019-07-11 stsp local testroot=`test_init rebase_continue`
274 f69721c3 2019-10-21 stsp local init_commit=`git_show_head $testroot/repo`
276 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
277 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
278 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
279 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
280 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
282 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
283 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
284 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
285 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
287 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
289 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
290 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
294 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
295 818c7501 2019-07-11 stsp 2> $testroot/stderr)
297 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
298 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
299 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
300 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
301 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
302 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
304 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
305 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
306 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
310 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
311 818c7501 2019-07-11 stsp > $testroot/stderr.expected
312 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
314 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
315 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
316 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
320 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
321 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
322 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
323 f69721c3 2019-10-21 stsp >> $testroot/content.expected
324 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
325 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
326 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
327 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
328 54d5be07 2021-06-03 stsp >> $testroot/content.expected
329 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
330 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
332 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
333 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
334 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
338 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
340 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
341 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
343 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
344 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
345 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
349 818c7501 2019-07-11 stsp # resolve the conflict
350 818c7501 2019-07-11 stsp echo "modified alpha on branch and master" > $testroot/wt/alpha
352 f032f1f7 2019-08-04 stsp # test interaction of 'got stage' and rebase -c
353 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got stage alpha > /dev/null)
354 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout \
355 f032f1f7 2019-08-04 stsp 2> $testroot/stderr)
357 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
358 f032f1f7 2019-08-04 stsp echo "rebase succeeded unexpectedly" >&2
359 f032f1f7 2019-08-04 stsp test_done "$testroot" "1"
362 f032f1f7 2019-08-04 stsp echo -n "got: work tree contains files with staged changes; " \
363 f032f1f7 2019-08-04 stsp > $testroot/stderr.expected
364 f032f1f7 2019-08-04 stsp echo "these changes must be committed or unstaged first" \
365 f032f1f7 2019-08-04 stsp >> $testroot/stderr.expected
366 f032f1f7 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
368 f032f1f7 2019-08-04 stsp if [ "$ret" != "0" ]; then
369 f032f1f7 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
370 f032f1f7 2019-08-04 stsp test_done "$testroot" "$ret"
374 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got unstage alpha > /dev/null)
375 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
377 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
378 818c7501 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
379 818c7501 2019-07-11 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
381 818c7501 2019-07-11 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
382 818c7501 2019-07-11 stsp > $testroot/stdout.expected
383 818c7501 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
384 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
385 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
387 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
389 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
390 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
391 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
396 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
397 818c7501 2019-07-11 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
398 818c7501 2019-07-11 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
399 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
401 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
402 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
404 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
407 f6cae3ed 2020-09-13 naddy test_rebase_abort() {
408 818c7501 2019-07-11 stsp local testroot=`test_init rebase_abort`
410 818c7501 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
412 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
413 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
414 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
415 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
416 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
418 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
419 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
420 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
421 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
423 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
425 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
426 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
430 d52bac28 2021-10-08 thomas # unrelated unversioned file in work tree
431 d52bac28 2021-10-08 thomas touch $testroot/wt/unversioned-file
433 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
434 818c7501 2019-07-11 stsp 2> $testroot/stderr)
436 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
437 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
438 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
439 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
440 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
441 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
443 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
444 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
445 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
449 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
450 818c7501 2019-07-11 stsp > $testroot/stderr.expected
451 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
453 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
454 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
455 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
459 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
460 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
461 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
462 f69721c3 2019-10-21 stsp >> $testroot/content.expected
463 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
464 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
465 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
466 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
467 54d5be07 2021-06-03 stsp >> $testroot/content.expected
468 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
469 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
471 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
472 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
473 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
477 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
479 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
480 d52bac28 2021-10-08 thomas echo "? unversioned-file" >> $testroot/stdout.expected
481 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
483 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
484 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
485 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
489 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -a > $testroot/stdout)
491 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
493 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/master" \
494 818c7501 2019-07-11 stsp > $testroot/stdout.expected
495 818c7501 2019-07-11 stsp echo 'R alpha' >> $testroot/stdout.expected
496 818c7501 2019-07-11 stsp echo "Rebase of refs/heads/newbranch aborted" \
497 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
499 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
501 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
502 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
503 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
507 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/content.expected
508 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
509 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
511 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
512 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
513 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
517 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l3 -c newbranch \
518 818c7501 2019-07-11 stsp | grep ^commit > $testroot/stdout)
519 818c7501 2019-07-11 stsp echo "commit $orig_commit1 (newbranch)" > $testroot/stdout.expected
520 818c7501 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
521 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
523 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
524 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
526 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
529 f6cae3ed 2020-09-13 naddy test_rebase_no_op_change() {
530 ff0d2220 2019-07-11 stsp local testroot=`test_init rebase_no_op_change`
531 ff0d2220 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
533 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
534 ff0d2220 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
535 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
536 ff0d2220 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
537 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
539 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
540 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
541 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
542 ff0d2220 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
544 ff0d2220 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
546 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
547 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
551 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
552 ff0d2220 2019-07-11 stsp 2> $testroot/stderr)
554 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
555 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
556 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
557 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
558 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
559 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
561 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
562 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
563 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
567 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
568 ff0d2220 2019-07-11 stsp > $testroot/stderr.expected
569 ff0d2220 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
571 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
572 ff0d2220 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
573 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
577 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
578 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
579 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
580 f69721c3 2019-10-21 stsp >> $testroot/content.expected
581 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
582 ff0d2220 2019-07-11 stsp echo "=======" >> $testroot/content.expected
583 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
584 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
585 54d5be07 2021-06-03 stsp >> $testroot/content.expected
586 ff0d2220 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
587 ff0d2220 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
589 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
590 ff0d2220 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
591 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
595 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
597 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
598 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
600 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
601 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
602 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
606 ff0d2220 2019-07-11 stsp # resolve the conflict
607 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/wt/alpha
609 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
611 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
612 ff0d2220 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
614 ff0d2220 2019-07-11 stsp echo -n "$short_orig_commit1 -> no-op change" \
615 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
616 ff0d2220 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
617 ff0d2220 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
618 ff0d2220 2019-07-11 stsp >> $testroot/stdout.expected
620 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
622 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
623 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
624 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
629 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
630 ff0d2220 2019-07-11 stsp echo "commit $master_commit (master, newbranch)" \
631 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
632 ff0d2220 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
633 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
635 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
636 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
638 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
641 f6cae3ed 2020-09-13 naddy test_rebase_in_progress() {
642 4ba9c4f6 2019-07-11 stsp local testroot=`test_init rebase_in_progress`
643 7d5807f4 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
645 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
646 7d5807f4 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
647 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
648 7d5807f4 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
649 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
651 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
652 7d5807f4 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
653 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
654 7d5807f4 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
656 7d5807f4 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
658 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
659 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
663 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
664 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
666 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
667 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
668 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
669 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
670 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
671 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
673 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
674 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
675 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
679 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
680 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
681 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
683 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
684 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
685 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
689 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
690 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
691 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
692 f69721c3 2019-10-21 stsp >> $testroot/content.expected
693 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
694 7d5807f4 2019-07-11 stsp echo "=======" >> $testroot/content.expected
695 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
696 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
697 54d5be07 2021-06-03 stsp >> $testroot/content.expected
698 7d5807f4 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
699 7d5807f4 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
701 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
702 7d5807f4 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
703 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
707 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
709 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
710 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
712 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
713 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
714 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
718 7d5807f4 2019-07-11 stsp for cmd in update commit; do
719 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got $cmd > $testroot/stdout \
720 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
722 7d5807f4 2019-07-11 stsp echo -n > $testroot/stdout.expected
723 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
725 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
726 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
727 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
731 7d5807f4 2019-07-11 stsp echo -n "got: a rebase operation is in progress in this " \
732 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
733 7d5807f4 2019-07-11 stsp echo "work tree and must be continued or aborted first" \
734 7d5807f4 2019-07-11 stsp >> $testroot/stderr.expected
735 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
737 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
738 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
739 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
744 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
747 f6cae3ed 2020-09-13 naddy test_rebase_path_prefix() {
748 64c6d990 2019-07-11 stsp local testroot=`test_init rebase_path_prefix`
750 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
751 64c6d990 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
752 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
754 64c6d990 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
755 64c6d990 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
757 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
758 64c6d990 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
759 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
760 64c6d990 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
762 64c6d990 2019-07-11 stsp got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
764 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
765 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
769 64c6d990 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch \
770 64c6d990 2019-07-11 stsp > $testroot/stdout 2> $testroot/stderr)
772 64c6d990 2019-07-11 stsp echo -n > $testroot/stdout.expected
773 64c6d990 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
775 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
776 64c6d990 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
777 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
781 64c6d990 2019-07-11 stsp echo -n "got: cannot rebase branch which contains changes outside " \
782 64c6d990 2019-07-11 stsp > $testroot/stderr.expected
783 64c6d990 2019-07-11 stsp echo "of this work tree's path prefix" >> $testroot/stderr.expected
784 787c8eb6 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
786 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
787 787c8eb6 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
789 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
792 f6cae3ed 2020-09-13 naddy test_rebase_preserves_logmsg() {
793 787c8eb6 2019-07-11 stsp local testroot=`test_init rebase_preserves_logmsg`
795 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
796 787c8eb6 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
797 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified delta on newbranch"
799 787c8eb6 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
800 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified alpha on newbranch"
802 787c8eb6 2019-07-11 stsp (cd $testroot/repo && got log -c newbranch -l2 | grep -v ^date: \
803 787c8eb6 2019-07-11 stsp > $testroot/log.expected)
805 787c8eb6 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
806 787c8eb6 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
808 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
809 787c8eb6 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
810 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
811 787c8eb6 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
813 787c8eb6 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
815 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
816 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
820 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > /dev/null \
821 787c8eb6 2019-07-11 stsp 2> $testroot/stderr)
823 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
824 787c8eb6 2019-07-11 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
825 787c8eb6 2019-07-11 stsp local new_commit2=`git_show_head $testroot/repo`
827 787c8eb6 2019-07-11 stsp echo -n > $testroot/stderr.expected
828 64c6d990 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
830 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
831 64c6d990 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
832 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
836 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got log -c newbranch -l2 | grep -v ^date: \
837 787c8eb6 2019-07-11 stsp > $testroot/log)
838 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit1/$new_commit1/" $testroot/log.expected
839 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit2/$new_commit2/" $testroot/log.expected
840 787c8eb6 2019-07-11 stsp cmp -s $testroot/log.expected $testroot/log
842 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
843 787c8eb6 2019-07-11 stsp diff -u $testroot/log.expected $testroot/log
846 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
849 f6cae3ed 2020-09-13 naddy test_rebase_no_commits_to_rebase() {
850 fc66b545 2019-08-12 stsp local testroot=`test_init rebase_no_commits_to_rebase`
852 fc66b545 2019-08-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
854 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
855 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
859 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n newbranch)
861 fc66b545 2019-08-12 stsp echo "modified alpha on master" > $testroot/wt/alpha
862 fc66b545 2019-08-12 stsp (cd $testroot/wt && got commit -m 'test rebase_no_commits_to_rebase' \
863 fc66b545 2019-08-12 stsp > /dev/null)
864 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > /dev/null)
866 fc66b545 2019-08-12 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
867 fc66b545 2019-08-12 stsp 2> $testroot/stderr)
869 fc66b545 2019-08-12 stsp echo "got: no commits to rebase" > $testroot/stderr.expected
870 fc66b545 2019-08-12 stsp cmp -s $testroot/stderr.expected $testroot/stderr
872 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
873 fc66b545 2019-08-12 stsp diff -u $testroot/stderr.expected $testroot/stderr
874 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
878 fc66b545 2019-08-12 stsp echo "Rebase of refs/heads/newbranch aborted" \
879 fc66b545 2019-08-12 stsp > $testroot/stdout.expected
880 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
882 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
883 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
884 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
888 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
889 fc66b545 2019-08-12 stsp echo "Already up-to-date" > $testroot/stdout.expected
890 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
892 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
893 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
895 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
898 f6cae3ed 2020-09-13 naddy test_rebase_forward() {
899 38b0338b 2019-11-29 stsp local testroot=`test_init rebase_forward`
900 38b0338b 2019-11-29 stsp local commit0=`git_show_head $testroot/repo`
902 38b0338b 2019-11-29 stsp got checkout $testroot/repo $testroot/wt > /dev/null
904 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
905 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
909 38b0338b 2019-11-29 stsp echo "change alpha 1" > $testroot/wt/alpha
910 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
911 38b0338b 2019-11-29 stsp > /dev/null)
912 38b0338b 2019-11-29 stsp local commit1=`git_show_head $testroot/repo`
914 38b0338b 2019-11-29 stsp echo "change alpha 2" > $testroot/wt/alpha
915 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
916 38b0338b 2019-11-29 stsp > /dev/null)
917 38b0338b 2019-11-29 stsp local commit2=`git_show_head $testroot/repo`
919 38b0338b 2019-11-29 stsp # Simulate a situation where fast-forward is required.
920 38b0338b 2019-11-29 stsp # We want to fast-forward master to origin/master:
921 38b0338b 2019-11-29 stsp # commit 3907e11dceaae2ca7f8db79c2af31794673945ad (origin/master)
922 38b0338b 2019-11-29 stsp # commit ffcffcd102cf1af6572fbdbb4cf07a0f1fd2d840 (master)
923 38b0338b 2019-11-29 stsp # commit 87a6a8a2263a15b61c016ff1720b24741d455eb5
924 993f033b 2021-07-16 stsp (cd $testroot/repo && got ref -d master >/dev/null)
925 e31abbf2 2020-03-22 stsp (cd $testroot/repo && got ref -c $commit1 refs/heads/master)
926 e31abbf2 2020-03-22 stsp (cd $testroot/repo && got ref -c $commit2 refs/remotes/origin/master)
928 38b0338b 2019-11-29 stsp (cd $testroot/wt && got up -b origin/master > /dev/null)
930 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase master \
931 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
933 38b0338b 2019-11-29 stsp echo "Forwarding refs/heads/master to commit $commit2" \
934 38b0338b 2019-11-29 stsp > $testroot/stdout.expected
935 38b0338b 2019-11-29 stsp echo "Switching work tree to refs/heads/master" \
936 38b0338b 2019-11-29 stsp >> $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 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
945 38b0338b 2019-11-29 stsp # Ensure that rebase operation was completed correctly
946 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase -a \
947 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
948 38b0338b 2019-11-29 stsp echo -n "" > $testroot/stdout.expected
949 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
951 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
952 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
953 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
956 38b0338b 2019-11-29 stsp echo "got: rebase operation not in progress" > $testroot/stderr.expected
957 38b0338b 2019-11-29 stsp cmp -s $testroot/stderr.expected $testroot/stderr
959 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
960 38b0338b 2019-11-29 stsp diff -u $testroot/stderr.expected $testroot/stderr
961 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
965 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n > $testroot/stdout)
966 38b0338b 2019-11-29 stsp echo "master" > $testroot/stdout.expected
967 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
969 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
970 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
971 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
975 38b0338b 2019-11-29 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
976 38b0338b 2019-11-29 stsp echo "commit $commit2 (master, origin/master)" > $testroot/stdout.expected
977 38b0338b 2019-11-29 stsp echo "commit $commit1" >> $testroot/stdout.expected
978 38b0338b 2019-11-29 stsp echo "commit $commit0" >> $testroot/stdout.expected
979 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
981 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
982 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
983 e600f124 2021-03-21 stsp test_done "$testroot" "$ret"
987 e600f124 2021-03-21 stsp # Forward-only rebase operations should not be backed up
988 e600f124 2021-03-21 stsp (cd $testroot/repo && got rebase -l > $testroot/stdout)
989 e600f124 2021-03-21 stsp echo -n > $testroot/stdout.expected
990 e600f124 2021-03-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
992 e600f124 2021-03-21 stsp if [ "$ret" != "0" ]; then
993 e600f124 2021-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
995 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
998 f6cae3ed 2020-09-13 naddy test_rebase_out_of_date() {
999 e51d7b55 2020-01-04 stsp local testroot=`test_init rebase_out_of_date`
1000 e51d7b55 2020-01-04 stsp local initial_commit=`git_show_head $testroot/repo`
1002 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1003 e51d7b55 2020-01-04 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1004 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1006 e51d7b55 2020-01-04 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1007 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git rm -q beta)
1008 e51d7b55 2020-01-04 stsp echo "new file on branch" > $testroot/repo/epsilon/new
1009 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git add epsilon/new)
1010 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
1012 e51d7b55 2020-01-04 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1013 e51d7b55 2020-01-04 stsp local orig_commit2=`git_show_head $testroot/repo`
1015 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
1016 e51d7b55 2020-01-04 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1017 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to zeta on master"
1018 e51d7b55 2020-01-04 stsp local master_commit1=`git_show_head $testroot/repo`
1020 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
1021 e51d7b55 2020-01-04 stsp echo "modified beta on master" > $testroot/repo/beta
1022 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to beta on master"
1023 e51d7b55 2020-01-04 stsp local master_commit2=`git_show_head $testroot/repo`
1025 e51d7b55 2020-01-04 stsp got checkout -c $master_commit1 $testroot/repo $testroot/wt \
1026 e51d7b55 2020-01-04 stsp > /dev/null
1028 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
1029 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1033 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
1034 e51d7b55 2020-01-04 stsp 2> $testroot/stderr)
1036 e51d7b55 2020-01-04 stsp echo -n > $testroot/stdout.expected
1037 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1039 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
1040 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
1041 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1045 e51d7b55 2020-01-04 stsp echo -n "got: work tree must be updated before it can be " \
1046 e51d7b55 2020-01-04 stsp > $testroot/stderr.expected
1047 e51d7b55 2020-01-04 stsp echo "used to rebase a branch" >> $testroot/stderr.expected
1048 e51d7b55 2020-01-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1050 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
1051 e51d7b55 2020-01-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
1052 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1056 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1057 e51d7b55 2020-01-04 stsp echo "commit $master_commit2 (master)" > $testroot/stdout.expected
1058 e51d7b55 2020-01-04 stsp echo "commit $master_commit1" >> $testroot/stdout.expected
1059 e51d7b55 2020-01-04 stsp echo "commit $initial_commit" >> $testroot/stdout.expected
1060 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1062 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1063 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1065 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1068 f6cae3ed 2020-09-13 naddy test_rebase_trims_empty_dir() {
1069 1ae0a341 2020-02-14 stsp local testroot=`test_init rebase_trims_empty_dir`
1071 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1072 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1073 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1075 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git rm -q epsilon/zeta)
1076 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "removing zeta on newbranch"
1078 1ae0a341 2020-02-14 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1079 1ae0a341 2020-02-14 stsp local orig_commit2=`git_show_head $testroot/repo`
1081 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q master)
1082 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/repo/alpha
1083 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to alpha on master"
1084 1ae0a341 2020-02-14 stsp local master_commit=`git_show_head $testroot/repo`
1086 1ae0a341 2020-02-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1088 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1089 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1093 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1095 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q newbranch)
1096 1ae0a341 2020-02-14 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
1097 1ae0a341 2020-02-14 stsp local new_commit2=`git_show_head $testroot/repo`
1099 1ae0a341 2020-02-14 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1100 1ae0a341 2020-02-14 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1101 1ae0a341 2020-02-14 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1102 1ae0a341 2020-02-14 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1104 1ae0a341 2020-02-14 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1105 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1106 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1107 1ae0a341 2020-02-14 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1108 1ae0a341 2020-02-14 stsp echo "D epsilon/zeta" >> $testroot/stdout.expected
1109 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1110 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1111 1ae0a341 2020-02-14 stsp echo ": removing zeta on newbranch" \
1112 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1113 1ae0a341 2020-02-14 stsp echo "Switching work tree to refs/heads/newbranch" \
1114 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1116 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1118 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
1119 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
1120 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1124 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/content.expected
1125 1ae0a341 2020-02-14 stsp cat $testroot/wt/gamma/delta > $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 echo "modified alpha on master" > $testroot/content.expected
1135 1ae0a341 2020-02-14 stsp cat $testroot/wt/alpha > $testroot/content
1136 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1138 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1139 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1140 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1144 1ae0a341 2020-02-14 stsp if [ -e $testroot/wt/epsilon ]; then
1145 1ae0a341 2020-02-14 stsp echo "parent of removed zeta still exists on disk" >&2
1146 1ae0a341 2020-02-14 stsp test_done "$testroot" "1"
1150 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got status > $testroot/stdout)
1152 1ae0a341 2020-02-14 stsp echo -n > $testroot/stdout.expected
1153 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1155 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1156 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1157 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1161 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1162 1ae0a341 2020-02-14 stsp echo "commit $new_commit2 (newbranch)" > $testroot/stdout.expected
1163 1ae0a341 2020-02-14 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1164 1ae0a341 2020-02-14 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1165 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1167 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1168 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1170 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1173 f6cae3ed 2020-09-13 naddy test_rebase_delete_missing_file() {
1174 ca6da77d 2020-03-22 stsp local testroot=`test_init rebase_delete_missing_file`
1176 ca6da77d 2020-03-22 stsp mkdir -p $testroot/repo/d/f/g
1177 ca6da77d 2020-03-22 stsp echo "new file" > $testroot/repo/d/f/g/new
1178 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git add d/f/g/new)
1179 ca6da77d 2020-03-22 stsp git_commit $testroot/repo -m "adding a subdir"
1180 ca6da77d 2020-03-22 stsp local commit0=`git_show_head $testroot/repo`
1182 a740a1b3 2020-03-22 stsp got br -r $testroot/repo -c master newbranch
1184 a740a1b3 2020-03-22 stsp got checkout -b newbranch $testroot/repo $testroot/wt > /dev/null
1186 a740a1b3 2020-03-22 stsp echo "modified delta on branch" > $testroot/wt/gamma/delta
1187 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1188 a740a1b3 2020-03-22 stsp -m "committing to delta on newbranch" > /dev/null)
1190 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1191 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1192 a740a1b3 2020-03-22 stsp -m "removing beta and d/f/g/new on newbranch" > /dev/null)
1194 a740a1b3 2020-03-22 stsp (cd $testroot/repo && git checkout -q newbranch)
1195 ca6da77d 2020-03-22 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1196 ca6da77d 2020-03-22 stsp local orig_commit2=`git_show_head $testroot/repo`
1198 bb494413 2021-09-28 thomas local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1199 bb494413 2021-09-28 thomas local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1201 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got update -b master > /dev/null)
1202 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1203 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1204 a740a1b3 2020-03-22 stsp -m "removing beta and d/f/g/new on master" > /dev/null)
1206 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git checkout -q master)
1207 ca6da77d 2020-03-22 stsp local master_commit=`git_show_head $testroot/repo`
1209 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got update -b master > /dev/null)
1210 bb494413 2021-09-28 thomas (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
1211 bb494413 2021-09-28 thomas 2> $testroot/stderr)
1212 bb494413 2021-09-28 thomas ret="$?"
1213 bb494413 2021-09-28 thomas if [ "$ret" = "0" ]; then
1214 bb494413 2021-09-28 thomas echo "rebase succeeded unexpectedly" >&2
1215 bb494413 2021-09-28 thomas test_done "$testroot" "1"
1216 bb494413 2021-09-28 thomas return 1
1219 bb494413 2021-09-28 thomas local new_commit1=$(cd $testroot/wt && got info | \
1220 bb494413 2021-09-28 thomas grep '^work tree base commit: ' | cut -d: -f2 | tr -d ' ')
1222 ca6da77d 2020-03-22 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1223 ca6da77d 2020-03-22 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1225 ca6da77d 2020-03-22 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1226 ca6da77d 2020-03-22 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1227 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1228 ca6da77d 2020-03-22 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1229 ca6da77d 2020-03-22 stsp echo "! beta" >> $testroot/stdout.expected
1230 ca6da77d 2020-03-22 stsp echo "! d/f/g/new" >> $testroot/stdout.expected
1231 0ef68859 2021-09-28 thomas echo -n "Files which had incoming changes but could not be found " \
1232 0ef68859 2021-09-28 thomas >> $testroot/stdout.expected
1233 0ef68859 2021-09-28 thomas echo "in the work tree: 2" >> $testroot/stdout.expected
1234 bb494413 2021-09-28 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1235 bb494413 2021-09-28 thomas ret="$?"
1236 bb494413 2021-09-28 thomas if [ "$ret" != "0" ]; then
1237 bb494413 2021-09-28 thomas diff -u $testroot/stdout.expected $testroot/stdout
1238 bb494413 2021-09-28 thomas test_done "$testroot" "$ret"
1239 bb494413 2021-09-28 thomas return 1
1242 bb494413 2021-09-28 thomas echo -n "got: changes destined for some files were not yet merged " \
1243 bb494413 2021-09-28 thomas > $testroot/stderr.expected
1244 bb494413 2021-09-28 thomas echo -n "and should be merged manually if required before the " \
1245 bb494413 2021-09-28 thomas >> $testroot/stderr.expected
1246 bb494413 2021-09-28 thomas echo "rebase operation is continued" >> $testroot/stderr.expected
1247 bb494413 2021-09-28 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1248 bb494413 2021-09-28 thomas ret="$?"
1249 bb494413 2021-09-28 thomas if [ "$ret" != "0" ]; then
1250 bb494413 2021-09-28 thomas diff -u $testroot/stderr.expected $testroot/stderr
1251 bb494413 2021-09-28 thomas test_done "$testroot" "$ret"
1252 bb494413 2021-09-28 thomas return 1
1255 bb494413 2021-09-28 thomas # ignore the missing changes and continue
1256 bb494413 2021-09-28 thomas (cd $testroot/wt && got rebase -c > $testroot/stdout)
1257 bb494413 2021-09-28 thomas ret="$?"
1258 bb494413 2021-09-28 thomas if [ "$ret" != "0" ]; then
1259 bb494413 2021-09-28 thomas echo "rebase failed unexpectedly" >&2
1260 bb494413 2021-09-28 thomas test_done "$testroot" "1"
1261 bb494413 2021-09-28 thomas return 1
1263 ca6da77d 2020-03-22 stsp echo -n "$short_orig_commit2 -> no-op change" \
1264 bb494413 2021-09-28 thomas > $testroot/stdout.expected
1265 a740a1b3 2020-03-22 stsp echo ": removing beta and d/f/g/new on newbranch" \
1266 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1267 ca6da77d 2020-03-22 stsp echo "Switching work tree to refs/heads/newbranch" \
1268 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1270 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1272 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1273 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1274 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1278 ca6da77d 2020-03-22 stsp echo "modified delta on branch" > $testroot/content.expected
1279 ca6da77d 2020-03-22 stsp cat $testroot/wt/gamma/delta > $testroot/content
1280 ca6da77d 2020-03-22 stsp cmp -s $testroot/content.expected $testroot/content
1282 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1283 ca6da77d 2020-03-22 stsp diff -u $testroot/content.expected $testroot/content
1284 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1288 ca6da77d 2020-03-22 stsp if [ -e $testroot/wt/beta ]; then
1289 ca6da77d 2020-03-22 stsp echo "removed file beta still exists on disk" >&2
1290 ca6da77d 2020-03-22 stsp test_done "$testroot" "1"
1294 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got status > $testroot/stdout)
1296 ca6da77d 2020-03-22 stsp echo -n > $testroot/stdout.expected
1297 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1299 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1300 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1301 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1305 bb494413 2021-09-28 thomas (cd $testroot/repo && git checkout -q newbranch)
1306 bb494413 2021-09-28 thomas local new_commit1=`git_show_head $testroot/repo`
1307 bb494413 2021-09-28 thomas local short_new_commit1=`trim_obj_id 28 $new_commit1`
1309 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1310 ca6da77d 2020-03-22 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
1311 ca6da77d 2020-03-22 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1312 ca6da77d 2020-03-22 stsp echo "commit $commit0" >> $testroot/stdout.expected
1313 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1315 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1316 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1318 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1321 f6cae3ed 2020-09-13 naddy test_rebase_rm_add_rm_file() {
1322 70551d57 2020-04-24 stsp local testroot=`test_init rebase_rm_add_rm_file`
1324 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1325 70551d57 2020-04-24 stsp (cd $testroot/repo && git rm -q beta)
1326 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "removing beta from newbranch"
1327 70551d57 2020-04-24 stsp local orig_commit1=`git_show_head $testroot/repo`
1329 70551d57 2020-04-24 stsp echo 'restored beta' > $testroot/repo/beta
1330 70551d57 2020-04-24 stsp (cd $testroot/repo && git add beta)
1331 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "restoring beta on newbranch"
1332 70551d57 2020-04-24 stsp local orig_commit2=`git_show_head $testroot/repo`
1334 70551d57 2020-04-24 stsp (cd $testroot/repo && git rm -q beta)
1335 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "removing beta from newbranch again"
1336 70551d57 2020-04-24 stsp local orig_commit3=`git_show_head $testroot/repo`
1338 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q master)
1339 70551d57 2020-04-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1340 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
1341 70551d57 2020-04-24 stsp local master_commit=`git_show_head $testroot/repo`
1343 70551d57 2020-04-24 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1345 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1346 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1350 70551d57 2020-04-24 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1352 70551d57 2020-04-24 stsp # this would error out with 'got: file index is corrupt'
1353 70551d57 2020-04-24 stsp (cd $testroot/wt && got status > /dev/null)
1355 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1356 70551d57 2020-04-24 stsp echo "got status command failed unexpectedly" >&2
1357 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1361 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q newbranch)
1362 70551d57 2020-04-24 stsp local new_commit3=`git_show_head $testroot/repo`
1363 70551d57 2020-04-24 stsp local new_commit2=`git_show_parent_commit $testroot/repo`
1364 70551d57 2020-04-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo $new_commit2`
1366 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q newbranch)
1368 70551d57 2020-04-24 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1369 70551d57 2020-04-24 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1370 70551d57 2020-04-24 stsp local short_orig_commit3=`trim_obj_id 28 $orig_commit3`
1371 70551d57 2020-04-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1372 70551d57 2020-04-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1373 70551d57 2020-04-24 stsp local short_new_commit3=`trim_obj_id 28 $new_commit3`
1375 70551d57 2020-04-24 stsp echo "D beta" > $testroot/stdout.expected
1376 70551d57 2020-04-24 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1377 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1378 70551d57 2020-04-24 stsp echo ": removing beta from newbranch" >> $testroot/stdout.expected
1379 70551d57 2020-04-24 stsp echo "A beta" >> $testroot/stdout.expected
1380 70551d57 2020-04-24 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1381 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1382 70551d57 2020-04-24 stsp echo ": restoring beta on newbranch" >> $testroot/stdout.expected
1383 70551d57 2020-04-24 stsp echo "D beta" >> $testroot/stdout.expected
1384 70551d57 2020-04-24 stsp echo -n "$short_orig_commit3 -> $short_new_commit3" \
1385 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1386 70551d57 2020-04-24 stsp echo ": removing beta from newbranch again" >> $testroot/stdout.expected
1387 70551d57 2020-04-24 stsp echo "Switching work tree to refs/heads/newbranch" \
1388 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1390 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1392 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1393 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1394 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1398 70551d57 2020-04-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1400 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1401 70551d57 2020-04-24 stsp echo "got status command failed unexpectedly" >&2
1402 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1406 70551d57 2020-04-24 stsp echo -n > $testroot/stdout.expected
1407 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1409 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1410 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1411 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1415 70551d57 2020-04-24 stsp (cd $testroot/wt && got log -l4 | grep ^commit > $testroot/stdout)
1416 70551d57 2020-04-24 stsp echo "commit $new_commit3 (newbranch)" > $testroot/stdout.expected
1417 70551d57 2020-04-24 stsp echo "commit $new_commit2" >> $testroot/stdout.expected
1418 70551d57 2020-04-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1419 70551d57 2020-04-24 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1420 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1422 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1423 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1425 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1428 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1429 dcf44d04 2019-07-11 stsp run_test test_rebase_basic
1430 dcf44d04 2019-07-11 stsp run_test test_rebase_ancestry_check
1431 dcf44d04 2019-07-11 stsp run_test test_rebase_continue
1432 dcf44d04 2019-07-11 stsp run_test test_rebase_abort
1433 ff0d2220 2019-07-11 stsp run_test test_rebase_no_op_change
1434 7d5807f4 2019-07-11 stsp run_test test_rebase_in_progress
1435 64c6d990 2019-07-11 stsp run_test test_rebase_path_prefix
1436 787c8eb6 2019-07-11 stsp run_test test_rebase_preserves_logmsg
1437 fc66b545 2019-08-12 stsp run_test test_rebase_no_commits_to_rebase
1438 38b0338b 2019-11-29 stsp run_test test_rebase_forward
1439 e51d7b55 2020-01-04 stsp run_test test_rebase_out_of_date
1440 1ae0a341 2020-02-14 stsp run_test test_rebase_trims_empty_dir
1441 ca6da77d 2020-03-22 stsp run_test test_rebase_delete_missing_file
1442 70551d57 2020-04-24 stsp run_test test_rebase_rm_add_rm_file