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 f73bf5bd 2023-10-01 naddy git -C $testroot/repo 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 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
30 818c7501 2019-07-11 stsp echo "new file on branch" > $testroot/repo/epsilon/new
31 f73bf5bd 2023-10-01 naddy git -C $testroot/repo 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 f73bf5bd 2023-10-01 naddy git -C $testroot/repo 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 f73bf5bd 2023-10-01 naddy git -C $testroot/repo 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
149 a615e0e7 2020-12-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
150 e600f124 2021-03-21 stsp test_done "$testroot" "$ret"
154 e600f124 2021-03-21 stsp # We should have a backup of old commits
155 e600f124 2021-03-21 stsp (cd $testroot/repo && got rebase -l > $testroot/stdout)
156 3a6b8760 2021-08-31 naddy d_orig2=`date -u -r $orig_author_time2 +"%a %b %e %X %Y UTC"`
157 3a6b8760 2021-08-31 naddy d_new2=`date -u -r $new_author_time2 +"%G-%m-%d"`
158 3a6b8760 2021-08-31 naddy d_0=`date -u -r $commit0_author_time +"%G-%m-%d"`
159 e600f124 2021-03-21 stsp cat > $testroot/stdout.expected <<EOF
160 e600f124 2021-03-21 stsp -----------------------------------------------
161 e600f124 2021-03-21 stsp commit $orig_commit2 (formerly newbranch)
162 e600f124 2021-03-21 stsp from: $GOT_AUTHOR
163 e600f124 2021-03-21 stsp date: $d_orig2
165 e600f124 2021-03-21 stsp committing more changes on newbranch
167 e600f124 2021-03-21 stsp has become commit $new_commit2 (newbranch)
168 e600f124 2021-03-21 stsp $d_new2 $GOT_AUTHOR_11 committing more changes on newbranch
169 e600f124 2021-03-21 stsp history forked at $commit0
170 e600f124 2021-03-21 stsp $d_0 $GOT_AUTHOR_11 adding the test tree
172 e600f124 2021-03-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
174 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
175 e600f124 2021-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
176 9e822917 2021-03-23 stsp test_done "$testroot" "$ret"
180 9e822917 2021-03-23 stsp # Asking for backups of a branch which has none should yield an error
181 9e822917 2021-03-23 stsp (cd $testroot/repo && got rebase -l master \
182 9e822917 2021-03-23 stsp > $testroot/stdout 2> $testroot/stderr)
183 9e822917 2021-03-23 stsp echo -n > $testroot/stdout.expected
184 9e822917 2021-03-23 stsp echo "got: refs/got/backup/rebase/master/: no such reference found" \
185 9e822917 2021-03-23 stsp > $testroot/stderr.expected
186 9e822917 2021-03-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
188 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
189 9e822917 2021-03-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
190 9e822917 2021-03-23 stsp test_done "$testroot" "$ret"
193 9e822917 2021-03-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
195 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
196 9e822917 2021-03-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
197 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
201 643b85bc 2021-07-16 stsp # Delete all backup refs
202 643b85bc 2021-07-16 stsp (cd $testroot/repo && got rebase -X \
203 643b85bc 2021-07-16 stsp > $testroot/stdout 2> $testroot/stderr)
204 643b85bc 2021-07-16 stsp echo -n "Deleted refs/got/backup/rebase/newbranch/$new_commit2: " \
205 643b85bc 2021-07-16 stsp > $testroot/stdout.expected
206 643b85bc 2021-07-16 stsp echo "$orig_commit2" >> $testroot/stdout.expected
207 643b85bc 2021-07-16 stsp echo -n > $testroot/stderr.expected
208 643b85bc 2021-07-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
210 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
211 643b85bc 2021-07-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
212 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
215 643b85bc 2021-07-16 stsp cmp -s $testroot/stderr.expected $testroot/stderr
217 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
218 643b85bc 2021-07-16 stsp diff -u $testroot/stderr.expected $testroot/stderr
219 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
223 643b85bc 2021-07-16 stsp (cd $testroot/repo && got rebase -l > $testroot/stdout)
224 643b85bc 2021-07-16 stsp echo -n > $testroot/stdout.expected
225 643b85bc 2021-07-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
227 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
228 643b85bc 2021-07-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
230 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
233 f6cae3ed 2020-09-13 naddy test_rebase_ancestry_check() {
234 818c7501 2019-07-11 stsp local testroot=`test_init rebase_ancestry_check`
236 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
238 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
239 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
243 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q -b newbranch
244 818c7501 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
245 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
246 3d42b266 2021-11-03 jrick local newbranch_id=`git_show_head $testroot/repo`
248 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
249 818c7501 2019-07-11 stsp 2> $testroot/stderr)
251 3d42b266 2021-11-03 jrick echo "refs/heads/newbranch is already based on refs/heads/master" \
252 3d42b266 2021-11-03 jrick > $testroot/stdout.expected
253 3d42b266 2021-11-03 jrick echo "Switching work tree from refs/heads/master to refs/heads/newbranch" \
254 3d42b266 2021-11-03 jrick >> $testroot/stdout.expected
255 3d42b266 2021-11-03 jrick echo "U gamma/delta" >> $testroot/stdout.expected
256 3d42b266 2021-11-03 jrick echo "Updated to refs/heads/newbranch: ${newbranch_id}" \
257 3d42b266 2021-11-03 jrick >> $testroot/stdout.expected
258 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
260 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
261 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
262 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
266 3d42b266 2021-11-03 jrick echo -n > $testroot/stderr.expected
267 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
269 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
270 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
272 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
275 f6cae3ed 2020-09-13 naddy test_rebase_continue() {
276 818c7501 2019-07-11 stsp local testroot=`test_init rebase_continue`
277 f69721c3 2019-10-21 stsp local init_commit=`git_show_head $testroot/repo`
279 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q -b newbranch
280 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
281 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
282 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
283 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
285 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q master
286 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
287 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
288 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
290 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
292 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
293 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
297 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
298 818c7501 2019-07-11 stsp 2> $testroot/stderr)
300 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
301 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
302 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
303 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
304 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
305 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
307 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
308 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
309 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
313 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
314 818c7501 2019-07-11 stsp > $testroot/stderr.expected
315 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
317 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
318 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
319 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
323 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
324 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
325 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
326 f69721c3 2019-10-21 stsp >> $testroot/content.expected
327 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
328 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
329 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
330 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
331 54d5be07 2021-06-03 stsp >> $testroot/content.expected
332 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
333 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
335 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
336 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
337 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
341 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
343 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
344 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
346 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
347 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
348 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
352 818c7501 2019-07-11 stsp # resolve the conflict
353 818c7501 2019-07-11 stsp echo "modified alpha on branch and master" > $testroot/wt/alpha
355 f032f1f7 2019-08-04 stsp # test interaction of 'got stage' and rebase -c
356 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got stage alpha > /dev/null)
357 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout \
358 f032f1f7 2019-08-04 stsp 2> $testroot/stderr)
360 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
361 f032f1f7 2019-08-04 stsp echo "rebase succeeded unexpectedly" >&2
362 f032f1f7 2019-08-04 stsp test_done "$testroot" "1"
365 f032f1f7 2019-08-04 stsp echo -n "got: work tree contains files with staged changes; " \
366 f032f1f7 2019-08-04 stsp > $testroot/stderr.expected
367 f032f1f7 2019-08-04 stsp echo "these changes must be committed or unstaged first" \
368 f032f1f7 2019-08-04 stsp >> $testroot/stderr.expected
369 f032f1f7 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
371 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
372 f032f1f7 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
373 f032f1f7 2019-08-04 stsp test_done "$testroot" "$ret"
377 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got unstage alpha > /dev/null)
378 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
380 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q newbranch
381 818c7501 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
382 818c7501 2019-07-11 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
384 818c7501 2019-07-11 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
385 818c7501 2019-07-11 stsp > $testroot/stdout.expected
386 818c7501 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
387 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
388 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
390 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
392 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
393 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
394 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
399 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
400 818c7501 2019-07-11 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
401 818c7501 2019-07-11 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
402 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
404 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
405 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
407 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
410 f6cae3ed 2020-09-13 naddy test_rebase_abort() {
411 818c7501 2019-07-11 stsp local testroot=`test_init rebase_abort`
413 818c7501 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
415 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q -b newbranch
416 1b093d84 2023-04-12 stsp echo "modified beta on branch" > $testroot/repo/beta
417 1b093d84 2023-04-12 stsp git_commit $testroot/repo -m "committing to beta on newbranch"
418 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
419 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
421 1b093d84 2023-04-12 stsp echo "modified alpha on branch" > $testroot/repo/alpha
422 af179be7 2023-04-14 stsp echo "new file on branch" > $testroot/repo/epsilon/new
423 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
424 af179be7 2023-04-14 stsp git_commit $testroot/repo \
425 af179be7 2023-04-14 stsp -m "changing alpha and adding new on newbranch"
426 1b093d84 2023-04-12 stsp local orig_commit2=`git_show_head $testroot/repo`
427 1b093d84 2023-04-12 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
429 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q master
430 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
431 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
432 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
434 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
436 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
437 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
441 41f061b2 2021-10-05 stsp # unrelated unversioned file in work tree
442 41f061b2 2021-10-05 stsp touch $testroot/wt/unversioned-file
444 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
445 818c7501 2019-07-11 stsp 2> $testroot/stderr)
447 1b093d84 2023-04-12 stsp new_commit1=$(cd $testroot/wt && got info beta | \
448 1b093d84 2023-04-12 stsp grep '^based on commit:' | cut -d' ' -f4)
449 1b093d84 2023-04-12 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
451 1b093d84 2023-04-12 stsp echo "G beta" > $testroot/stdout.expected
452 1b093d84 2023-04-12 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
453 1b093d84 2023-04-12 stsp >> $testroot/stdout.expected
454 1b093d84 2023-04-12 stsp echo ": committing to beta on newbranch" >> $testroot/stdout.expected
455 1b093d84 2023-04-12 stsp echo "C alpha" >> $testroot/stdout.expected
456 af179be7 2023-04-14 stsp echo "A epsilon/new" >> $testroot/stdout.expected
457 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
458 1b093d84 2023-04-12 stsp echo -n "$short_orig_commit2 -> merge conflict" \
459 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
460 af179be7 2023-04-14 stsp echo ": changing alpha and adding new on newbranch" \
461 af179be7 2023-04-14 stsp >> $testroot/stdout.expected
462 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
464 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
465 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
466 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
470 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
471 818c7501 2019-07-11 stsp > $testroot/stderr.expected
472 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
474 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
475 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
476 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
480 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
481 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
482 1b093d84 2023-04-12 stsp echo "||||||| 3-way merge base: commit $orig_commit1" \
483 f69721c3 2019-10-21 stsp >> $testroot/content.expected
484 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
485 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
486 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
487 1b093d84 2023-04-12 stsp echo ">>>>>>> merged change: commit $orig_commit2" \
488 54d5be07 2021-06-03 stsp >> $testroot/content.expected
489 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
490 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
492 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
493 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
494 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
498 af179be7 2023-04-14 stsp # unrelated file in work tree added during conflict resolution
499 af179be7 2023-04-14 stsp touch $testroot/wt/added-file
500 af179be7 2023-04-14 stsp (cd $testroot/wt && got add added-file > /dev/null)
502 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
504 af179be7 2023-04-14 stsp echo "A added-file" > $testroot/stdout.expected
505 af179be7 2023-04-14 stsp echo "C alpha" >> $testroot/stdout.expected
506 af179be7 2023-04-14 stsp echo "A epsilon/new" >> $testroot/stdout.expected
507 41f061b2 2021-10-05 stsp echo "? unversioned-file" >> $testroot/stdout.expected
508 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
510 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
511 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
512 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
516 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -a > $testroot/stdout)
518 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q newbranch
520 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/master" \
521 818c7501 2019-07-11 stsp > $testroot/stdout.expected
522 af179be7 2023-04-14 stsp echo 'R added-file' >> $testroot/stdout.expected
523 818c7501 2019-07-11 stsp echo 'R alpha' >> $testroot/stdout.expected
524 af179be7 2023-04-14 stsp echo 'R epsilon/new' >> $testroot/stdout.expected
525 af179be7 2023-04-14 stsp echo 'G added-file' >> $testroot/stdout.expected
526 1b093d84 2023-04-12 stsp echo 'U beta' >> $testroot/stdout.expected
527 818c7501 2019-07-11 stsp echo "Rebase of refs/heads/newbranch aborted" \
528 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
530 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
532 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
533 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
534 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
538 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/content.expected
539 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
540 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
542 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
543 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
544 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
548 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l3 -c newbranch \
549 818c7501 2019-07-11 stsp | grep ^commit > $testroot/stdout)
550 1b093d84 2023-04-12 stsp echo "commit $orig_commit2 (newbranch)" > $testroot/stdout.expected
551 1b093d84 2023-04-12 stsp echo "commit $orig_commit1" >> $testroot/stdout.expected
552 818c7501 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
553 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
555 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
556 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
557 1b093d84 2023-04-12 stsp test_done "$testroot" "$ret"
561 1b093d84 2023-04-12 stsp (cd $testroot/wt && got info .| \
562 1b093d84 2023-04-12 stsp grep '^based on commit:' | sort | uniq > $testroot/stdout)
563 1b093d84 2023-04-12 stsp echo "based on commit: $master_commit" > $testroot/stdout.expected
564 1b093d84 2023-04-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
566 1b093d84 2023-04-12 stsp if [ $ret -ne 0 ]; then
567 1b093d84 2023-04-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
568 1b093d84 2023-04-12 stsp test_done "$testroot" "$ret"
572 1b093d84 2023-04-12 stsp (cd $testroot/wt && got status > $testroot/stdout)
573 af179be7 2023-04-14 stsp echo "? added-file" > $testroot/stdout.expected
574 af179be7 2023-04-14 stsp echo "? unversioned-file" >> $testroot/stdout.expected
575 1b093d84 2023-04-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
577 1b093d84 2023-04-12 stsp if [ $ret -ne 0 ]; then
578 1b093d84 2023-04-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
579 1b093d84 2023-04-12 stsp test_done "$testroot" "$ret"
583 1b093d84 2023-04-12 stsp cat $testroot/wt/beta > $testroot/content
584 1b093d84 2023-04-12 stsp echo 'beta' > $testroot/content.expected
585 1b093d84 2023-04-12 stsp cmp -s $testroot/content.expected $testroot/content
587 1b093d84 2023-04-12 stsp if [ $ret -ne 0 ]; then
588 1b093d84 2023-04-12 stsp diff -u $testroot/content.expected $testroot/content
589 1b093d84 2023-04-12 stsp test_done "$testroot" "$ret"
593 1b093d84 2023-04-12 stsp # A subsequent update should be a no-op.
594 1b093d84 2023-04-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
595 1b093d84 2023-04-12 stsp echo 'Already up-to-date' > $testroot/stdout.expected
596 1b093d84 2023-04-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
598 1b093d84 2023-04-12 stsp if [ $ret -ne 0 ]; then
599 1b093d84 2023-04-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
601 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
604 f6cae3ed 2020-09-13 naddy test_rebase_no_op_change() {
605 ff0d2220 2019-07-11 stsp local testroot=`test_init rebase_no_op_change`
606 ff0d2220 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
608 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q -b newbranch
609 ff0d2220 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
610 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
611 ff0d2220 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
612 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
614 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q master
615 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
616 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
617 ff0d2220 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
619 ff0d2220 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
621 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
622 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
626 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
627 ff0d2220 2019-07-11 stsp 2> $testroot/stderr)
629 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
630 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
631 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
632 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
633 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
634 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
636 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
637 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
638 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
642 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
643 ff0d2220 2019-07-11 stsp > $testroot/stderr.expected
644 ff0d2220 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
646 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
647 ff0d2220 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
648 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
652 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
653 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
654 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
655 f69721c3 2019-10-21 stsp >> $testroot/content.expected
656 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
657 ff0d2220 2019-07-11 stsp echo "=======" >> $testroot/content.expected
658 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
659 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
660 54d5be07 2021-06-03 stsp >> $testroot/content.expected
661 ff0d2220 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
662 ff0d2220 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
664 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
665 ff0d2220 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
666 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
670 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
672 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
673 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
675 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
676 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
677 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
681 ff0d2220 2019-07-11 stsp # resolve the conflict
682 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/wt/alpha
684 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
686 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q newbranch
687 ff0d2220 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
689 ff0d2220 2019-07-11 stsp echo -n "$short_orig_commit1 -> no-op change" \
690 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
691 ff0d2220 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
692 ff0d2220 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
693 ff0d2220 2019-07-11 stsp >> $testroot/stdout.expected
695 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
697 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
698 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
699 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
704 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
705 ff0d2220 2019-07-11 stsp echo "commit $master_commit (master, newbranch)" \
706 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
707 ff0d2220 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
708 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
710 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
711 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
713 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
716 f6cae3ed 2020-09-13 naddy test_rebase_in_progress() {
717 4ba9c4f6 2019-07-11 stsp local testroot=`test_init rebase_in_progress`
718 7d5807f4 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
720 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q -b newbranch
721 7d5807f4 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
722 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
723 7d5807f4 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
724 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
726 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q master
727 7d5807f4 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
728 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
729 7d5807f4 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
731 7d5807f4 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
733 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
734 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
738 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
739 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
741 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
742 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
743 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
744 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
745 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
746 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
748 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
749 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
750 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
754 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
755 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
756 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
758 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
759 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
760 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
764 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
765 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
766 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
767 f69721c3 2019-10-21 stsp >> $testroot/content.expected
768 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
769 7d5807f4 2019-07-11 stsp echo "=======" >> $testroot/content.expected
770 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
771 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
772 54d5be07 2021-06-03 stsp >> $testroot/content.expected
773 7d5807f4 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
774 7d5807f4 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
776 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
777 7d5807f4 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
778 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
782 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
784 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
785 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
787 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
788 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
789 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
793 7d5807f4 2019-07-11 stsp for cmd in update commit; do
794 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got $cmd > $testroot/stdout \
795 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
797 7d5807f4 2019-07-11 stsp echo -n > $testroot/stdout.expected
798 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
800 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
801 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
802 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
806 7d5807f4 2019-07-11 stsp echo -n "got: a rebase operation is in progress in this " \
807 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
808 7d5807f4 2019-07-11 stsp echo "work tree and must be continued or aborted first" \
809 7d5807f4 2019-07-11 stsp >> $testroot/stderr.expected
810 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
812 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
813 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
814 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
819 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
822 f6cae3ed 2020-09-13 naddy test_rebase_path_prefix() {
823 64c6d990 2019-07-11 stsp local testroot=`test_init rebase_path_prefix`
825 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q -b newbranch
826 64c6d990 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
827 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
829 64c6d990 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
830 64c6d990 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
832 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q master
833 64c6d990 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
834 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
835 64c6d990 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
837 64c6d990 2019-07-11 stsp got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
839 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
840 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
844 64c6d990 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch \
845 64c6d990 2019-07-11 stsp > $testroot/stdout 2> $testroot/stderr)
847 64c6d990 2019-07-11 stsp echo -n > $testroot/stdout.expected
848 64c6d990 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
850 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
851 64c6d990 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
852 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
856 64c6d990 2019-07-11 stsp echo -n "got: cannot rebase branch which contains changes outside " \
857 64c6d990 2019-07-11 stsp > $testroot/stderr.expected
858 64c6d990 2019-07-11 stsp echo "of this work tree's path prefix" >> $testroot/stderr.expected
859 787c8eb6 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
861 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
862 787c8eb6 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
863 67ba6161 2022-04-08 stsp test_done "$testroot" "$ret"
867 67ba6161 2022-04-08 stsp # rebase should succeed when using a complete work tree
868 67ba6161 2022-04-08 stsp got checkout $testroot/repo $testroot/wt2 > /dev/null
870 67ba6161 2022-04-08 stsp if [ $ret -ne 0 ]; then
871 67ba6161 2022-04-08 stsp test_done "$testroot" "$ret"
875 67ba6161 2022-04-08 stsp (cd $testroot/wt2 && got rebase newbranch \
876 67ba6161 2022-04-08 stsp > $testroot/stdout 2> $testroot/stderr)
878 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q newbranch
879 67ba6161 2022-04-08 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
880 67ba6161 2022-04-08 stsp local new_commit2=`git_show_head $testroot/repo`
882 67ba6161 2022-04-08 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
883 67ba6161 2022-04-08 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
885 67ba6161 2022-04-08 stsp echo "G gamma/delta" > $testroot/stdout.expected
886 67ba6161 2022-04-08 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
887 67ba6161 2022-04-08 stsp >> $testroot/stdout.expected
888 67ba6161 2022-04-08 stsp echo ": committing to delta on newbranch" \
889 67ba6161 2022-04-08 stsp >> $testroot/stdout.expected
890 67ba6161 2022-04-08 stsp echo "Switching work tree to refs/heads/newbranch" \
891 67ba6161 2022-04-08 stsp >> $testroot/stdout.expected
893 67ba6161 2022-04-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
895 67ba6161 2022-04-08 stsp if [ $ret -ne 0 ]; then
896 67ba6161 2022-04-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
897 67ba6161 2022-04-08 stsp test_done "$testroot" "$ret"
901 67ba6161 2022-04-08 stsp # the first work tree should remain usable
902 67ba6161 2022-04-08 stsp (cd $testroot/wt && got update -b master \
903 67ba6161 2022-04-08 stsp > $testroot/stdout 2> $testroot/stderr)
905 67ba6161 2022-04-08 stsp if [ $ret -ne 0 ]; then
906 67ba6161 2022-04-08 stsp echo "update failed unexpectedly" >&2
907 67ba6161 2022-04-08 stsp test_done "$testroot" "1"
911 67ba6161 2022-04-08 stsp echo 'Already up-to-date' > $testroot/stdout.expected
912 67ba6161 2022-04-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
914 67ba6161 2022-04-08 stsp if [ $ret -ne 0 ]; then
915 67ba6161 2022-04-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
917 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
920 f6cae3ed 2020-09-13 naddy test_rebase_preserves_logmsg() {
921 787c8eb6 2019-07-11 stsp local testroot=`test_init rebase_preserves_logmsg`
923 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q -b newbranch
924 787c8eb6 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
925 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified delta on newbranch"
927 787c8eb6 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
928 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified alpha on newbranch"
930 787c8eb6 2019-07-11 stsp (cd $testroot/repo && got log -c newbranch -l2 | grep -v ^date: \
931 787c8eb6 2019-07-11 stsp > $testroot/log.expected)
933 787c8eb6 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
934 787c8eb6 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
936 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q master
937 787c8eb6 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
938 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
939 787c8eb6 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
941 787c8eb6 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
943 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
944 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
948 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > /dev/null \
949 787c8eb6 2019-07-11 stsp 2> $testroot/stderr)
951 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q newbranch
952 787c8eb6 2019-07-11 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
953 787c8eb6 2019-07-11 stsp local new_commit2=`git_show_head $testroot/repo`
955 787c8eb6 2019-07-11 stsp echo -n > $testroot/stderr.expected
956 64c6d990 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
958 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
959 64c6d990 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
960 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
964 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got log -c newbranch -l2 | grep -v ^date: \
965 787c8eb6 2019-07-11 stsp > $testroot/log)
966 885e96df 2023-03-06 naddy ed -s $testroot/log.expected <<-EOF
967 885e96df 2023-03-06 naddy ,s/$orig_commit1/$new_commit1/
968 885e96df 2023-03-06 naddy ,s/$orig_commit2/$new_commit2/
971 787c8eb6 2019-07-11 stsp cmp -s $testroot/log.expected $testroot/log
973 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
974 787c8eb6 2019-07-11 stsp diff -u $testroot/log.expected $testroot/log
977 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
980 f6cae3ed 2020-09-13 naddy test_rebase_no_commits_to_rebase() {
981 fc66b545 2019-08-12 stsp local testroot=`test_init rebase_no_commits_to_rebase`
983 fc66b545 2019-08-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
985 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
986 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
990 980c6786 2023-01-31 stsp # Create an unrelated branch with 'got import'.
991 980c6786 2023-01-31 stsp mkdir -p $testroot/newtree
992 980c6786 2023-01-31 stsp echo "new file" > $testroot/newtree/newfile
993 980c6786 2023-01-31 stsp got import -m new -b newbranch -r $testroot/repo \
994 980c6786 2023-01-31 stsp $testroot/newtree > /dev/null
996 fc66b545 2019-08-12 stsp echo "modified alpha on master" > $testroot/wt/alpha
997 fc66b545 2019-08-12 stsp (cd $testroot/wt && got commit -m 'test rebase_no_commits_to_rebase' \
998 fc66b545 2019-08-12 stsp > /dev/null)
999 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > /dev/null)
1001 fc66b545 2019-08-12 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
1002 fc66b545 2019-08-12 stsp 2> $testroot/stderr)
1004 980c6786 2023-01-31 stsp echo -n "got: specified branch shares no common ancestry " \
1005 980c6786 2023-01-31 stsp > $testroot/stderr.expected
1006 980c6786 2023-01-31 stsp echo "with work tree's branch" >> $testroot/stderr.expected
1007 fc66b545 2019-08-12 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1009 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1010 fc66b545 2019-08-12 stsp diff -u $testroot/stderr.expected $testroot/stderr
1011 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
1015 67ba6161 2022-04-08 stsp echo -n > $testroot/stdout.expected
1016 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1018 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1019 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
1020 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
1024 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
1025 fc66b545 2019-08-12 stsp echo "Already up-to-date" > $testroot/stdout.expected
1026 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1028 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1029 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
1031 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
1034 f6cae3ed 2020-09-13 naddy test_rebase_forward() {
1035 38b0338b 2019-11-29 stsp local testroot=`test_init rebase_forward`
1036 38b0338b 2019-11-29 stsp local commit0=`git_show_head $testroot/repo`
1038 38b0338b 2019-11-29 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1040 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1041 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1045 38b0338b 2019-11-29 stsp echo "change alpha 1" > $testroot/wt/alpha
1046 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
1047 38b0338b 2019-11-29 stsp > /dev/null)
1048 38b0338b 2019-11-29 stsp local commit1=`git_show_head $testroot/repo`
1050 38b0338b 2019-11-29 stsp echo "change alpha 2" > $testroot/wt/alpha
1051 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
1052 38b0338b 2019-11-29 stsp > /dev/null)
1053 38b0338b 2019-11-29 stsp local commit2=`git_show_head $testroot/repo`
1055 5e91dae4 2022-08-30 stsp # Simulate a situation where fast-forward is required.
1056 38b0338b 2019-11-29 stsp # We want to fast-forward master to origin/master:
1057 38b0338b 2019-11-29 stsp # commit 3907e11dceaae2ca7f8db79c2af31794673945ad (origin/master)
1058 38b0338b 2019-11-29 stsp # commit ffcffcd102cf1af6572fbdbb4cf07a0f1fd2d840 (master)
1059 38b0338b 2019-11-29 stsp # commit 87a6a8a2263a15b61c016ff1720b24741d455eb5
1060 993f033b 2021-07-16 stsp (cd $testroot/repo && got ref -d master >/dev/null)
1061 e31abbf2 2020-03-22 stsp (cd $testroot/repo && got ref -c $commit1 refs/heads/master)
1062 e31abbf2 2020-03-22 stsp (cd $testroot/repo && got ref -c $commit2 refs/remotes/origin/master)
1064 38b0338b 2019-11-29 stsp (cd $testroot/wt && got up -b origin/master > /dev/null)
1066 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase master \
1067 0a706d22 2022-09-21 stsp > $testroot/stdout 2> $testroot/stderr)
1069 0a706d22 2022-09-21 stsp echo "Forwarding refs/heads/master to commit $commit2" \
1070 0a706d22 2022-09-21 stsp > $testroot/stdout.expected
1071 0a706d22 2022-09-21 stsp echo "Switching work tree to refs/heads/master" \
1072 0a706d22 2022-09-21 stsp >> $testroot/stdout.expected
1073 0a706d22 2022-09-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1075 0a706d22 2022-09-21 stsp if [ $ret -ne 0 ]; then
1076 0a706d22 2022-09-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1077 0a706d22 2022-09-21 stsp test_done "$testroot" "$ret"
1081 0a706d22 2022-09-21 stsp # Ensure that rebase operation was completed correctly
1082 0a706d22 2022-09-21 stsp (cd $testroot/wt && got rebase -a \
1083 0a706d22 2022-09-21 stsp > $testroot/stdout 2> $testroot/stderr)
1084 0a706d22 2022-09-21 stsp echo -n "" > $testroot/stdout.expected
1085 0a706d22 2022-09-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1087 0a706d22 2022-09-21 stsp if [ $ret -ne 0 ]; then
1088 0a706d22 2022-09-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1089 0a706d22 2022-09-21 stsp test_done "$testroot" "$ret"
1092 0a706d22 2022-09-21 stsp echo "got: rebase operation not in progress" > $testroot/stderr.expected
1093 0a706d22 2022-09-21 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1095 0a706d22 2022-09-21 stsp if [ $ret -ne 0 ]; then
1096 0a706d22 2022-09-21 stsp diff -u $testroot/stderr.expected $testroot/stderr
1097 0a706d22 2022-09-21 stsp test_done "$testroot" "$ret"
1101 0a706d22 2022-09-21 stsp (cd $testroot/wt && got branch -n > $testroot/stdout)
1102 0a706d22 2022-09-21 stsp echo "master" > $testroot/stdout.expected
1103 0a706d22 2022-09-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1105 0a706d22 2022-09-21 stsp if [ $ret -ne 0 ]; then
1106 0a706d22 2022-09-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1107 0a706d22 2022-09-21 stsp test_done "$testroot" "$ret"
1111 0a706d22 2022-09-21 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1112 0a706d22 2022-09-21 stsp echo "commit $commit2 (master, origin/master)" > $testroot/stdout.expected
1113 0a706d22 2022-09-21 stsp echo "commit $commit1" >> $testroot/stdout.expected
1114 0a706d22 2022-09-21 stsp echo "commit $commit0" >> $testroot/stdout.expected
1115 0a706d22 2022-09-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1117 0a706d22 2022-09-21 stsp if [ $ret -ne 0 ]; then
1118 0a706d22 2022-09-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1119 0a706d22 2022-09-21 stsp test_done "$testroot" "$ret"
1123 0a706d22 2022-09-21 stsp # Forward-only rebase operations should not be backed up
1124 0a706d22 2022-09-21 stsp (cd $testroot/repo && got rebase -l > $testroot/stdout)
1125 0a706d22 2022-09-21 stsp echo -n > $testroot/stdout.expected
1126 0a706d22 2022-09-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1128 0a706d22 2022-09-21 stsp if [ $ret -ne 0 ]; then
1129 0a706d22 2022-09-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1131 0a706d22 2022-09-21 stsp test_done "$testroot" "$ret"
1134 0a706d22 2022-09-21 stsp test_rebase_forward_path_prefix() {
1135 0a706d22 2022-09-21 stsp local testroot=`test_init rebase_forward_path_prefix`
1136 0a706d22 2022-09-21 stsp local commit0=`git_show_head $testroot/repo`
1138 0a706d22 2022-09-21 stsp got checkout $testroot/repo $testroot/wt-full > /dev/null
1140 0a706d22 2022-09-21 stsp if [ $ret -ne 0 ]; then
1141 0a706d22 2022-09-21 stsp test_done "$testroot" "$ret"
1145 0a706d22 2022-09-21 stsp echo "change alpha 1" > $testroot/wt-full/alpha
1146 0a706d22 2022-09-21 stsp (cd $testroot/wt-full && got commit -m 'test rebase_forward' \
1147 0a706d22 2022-09-21 stsp > /dev/null)
1148 0a706d22 2022-09-21 stsp local commit1=`git_show_head $testroot/repo`
1150 0a706d22 2022-09-21 stsp echo "change alpha 2" > $testroot/wt-full/alpha
1151 0a706d22 2022-09-21 stsp (cd $testroot/wt-full && got commit -m 'test rebase_forward' \
1152 0a706d22 2022-09-21 stsp > /dev/null)
1153 0a706d22 2022-09-21 stsp local commit2=`git_show_head $testroot/repo`
1155 0a706d22 2022-09-21 stsp # Simulate a situation where fast-forward is required.
1156 0a706d22 2022-09-21 stsp # We want to fast-forward master to origin/master:
1157 0a706d22 2022-09-21 stsp # commit 3907e11dceaae2ca7f8db79c2af31794673945ad (origin/master)
1158 0a706d22 2022-09-21 stsp # commit ffcffcd102cf1af6572fbdbb4cf07a0f1fd2d840 (master)
1159 0a706d22 2022-09-21 stsp # commit 87a6a8a2263a15b61c016ff1720b24741d455eb5
1160 0a706d22 2022-09-21 stsp (cd $testroot/repo && got ref -d master >/dev/null)
1161 0a706d22 2022-09-21 stsp (cd $testroot/repo && got ref -c $commit1 refs/heads/master)
1162 0a706d22 2022-09-21 stsp (cd $testroot/repo && got ref -c $commit2 refs/remotes/origin/master)
1164 0a706d22 2022-09-21 stsp # Work tree which uses a path-prefix and will be used for rebasing
1165 0a706d22 2022-09-21 stsp got checkout -p epsilon -b origin/master $testroot/repo $testroot/wt \
1166 0a706d22 2022-09-21 stsp > /dev/null
1168 0a706d22 2022-09-21 stsp if [ $ret -ne 0 ]; then
1169 0a706d22 2022-09-21 stsp test_done "$testroot" "$ret"
1173 2c75f174 2022-10-24 naddy (cd $testroot/wt && got rebase master \
1174 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
1176 38b0338b 2019-11-29 stsp echo "Forwarding refs/heads/master to commit $commit2" \
1177 38b0338b 2019-11-29 stsp > $testroot/stdout.expected
1178 38b0338b 2019-11-29 stsp echo "Switching work tree to refs/heads/master" \
1179 38b0338b 2019-11-29 stsp >> $testroot/stdout.expected
1180 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1182 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1183 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
1184 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1188 38b0338b 2019-11-29 stsp # Ensure that rebase operation was completed correctly
1189 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase -a \
1190 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
1191 38b0338b 2019-11-29 stsp echo -n "" > $testroot/stdout.expected
1192 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1194 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1195 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
1196 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1199 38b0338b 2019-11-29 stsp echo "got: rebase operation not in progress" > $testroot/stderr.expected
1200 38b0338b 2019-11-29 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1202 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1203 38b0338b 2019-11-29 stsp diff -u $testroot/stderr.expected $testroot/stderr
1204 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1208 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n > $testroot/stdout)
1209 38b0338b 2019-11-29 stsp echo "master" > $testroot/stdout.expected
1210 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1212 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1213 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
1214 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1218 38b0338b 2019-11-29 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1219 38b0338b 2019-11-29 stsp echo "commit $commit2 (master, origin/master)" > $testroot/stdout.expected
1220 38b0338b 2019-11-29 stsp echo "commit $commit1" >> $testroot/stdout.expected
1221 38b0338b 2019-11-29 stsp echo "commit $commit0" >> $testroot/stdout.expected
1222 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1224 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1225 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
1226 e600f124 2021-03-21 stsp test_done "$testroot" "$ret"
1230 e600f124 2021-03-21 stsp # Forward-only rebase operations should not be backed up
1231 e600f124 2021-03-21 stsp (cd $testroot/repo && got rebase -l > $testroot/stdout)
1232 e600f124 2021-03-21 stsp echo -n > $testroot/stdout.expected
1233 e600f124 2021-03-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1235 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1236 e600f124 2021-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1238 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1241 f6cae3ed 2020-09-13 naddy test_rebase_out_of_date() {
1242 e51d7b55 2020-01-04 stsp local testroot=`test_init rebase_out_of_date`
1243 e51d7b55 2020-01-04 stsp local initial_commit=`git_show_head $testroot/repo`
1245 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q -b newbranch
1246 e51d7b55 2020-01-04 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1247 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1249 e51d7b55 2020-01-04 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1250 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
1251 e51d7b55 2020-01-04 stsp echo "new file on branch" > $testroot/repo/epsilon/new
1252 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add epsilon/new
1253 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
1255 e51d7b55 2020-01-04 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1256 e51d7b55 2020-01-04 stsp local orig_commit2=`git_show_head $testroot/repo`
1258 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q master
1259 e51d7b55 2020-01-04 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1260 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to zeta on master"
1261 e51d7b55 2020-01-04 stsp local master_commit1=`git_show_head $testroot/repo`
1263 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q master
1264 e51d7b55 2020-01-04 stsp echo "modified beta on master" > $testroot/repo/beta
1265 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to beta on master"
1266 e51d7b55 2020-01-04 stsp local master_commit2=`git_show_head $testroot/repo`
1268 e51d7b55 2020-01-04 stsp got checkout -c $master_commit1 $testroot/repo $testroot/wt \
1269 e51d7b55 2020-01-04 stsp > /dev/null
1271 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1272 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1276 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
1277 e51d7b55 2020-01-04 stsp 2> $testroot/stderr)
1279 e51d7b55 2020-01-04 stsp echo -n > $testroot/stdout.expected
1280 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1282 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1283 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
1284 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1288 e51d7b55 2020-01-04 stsp echo -n "got: work tree must be updated before it can be " \
1289 e51d7b55 2020-01-04 stsp > $testroot/stderr.expected
1290 e51d7b55 2020-01-04 stsp echo "used to rebase a branch" >> $testroot/stderr.expected
1291 e51d7b55 2020-01-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1293 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1294 e51d7b55 2020-01-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
1295 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1299 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1300 e51d7b55 2020-01-04 stsp echo "commit $master_commit2 (master)" > $testroot/stdout.expected
1301 e51d7b55 2020-01-04 stsp echo "commit $master_commit1" >> $testroot/stdout.expected
1302 e51d7b55 2020-01-04 stsp echo "commit $initial_commit" >> $testroot/stdout.expected
1303 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1305 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1306 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1308 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1311 f6cae3ed 2020-09-13 naddy test_rebase_trims_empty_dir() {
1312 1ae0a341 2020-02-14 stsp local testroot=`test_init rebase_trims_empty_dir`
1314 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q -b newbranch
1315 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1316 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1318 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q epsilon/zeta
1319 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "removing zeta on newbranch"
1321 1ae0a341 2020-02-14 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1322 1ae0a341 2020-02-14 stsp local orig_commit2=`git_show_head $testroot/repo`
1324 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q master
1325 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/repo/alpha
1326 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to alpha on master"
1327 1ae0a341 2020-02-14 stsp local master_commit=`git_show_head $testroot/repo`
1329 1ae0a341 2020-02-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1331 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1332 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1336 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1338 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q newbranch
1339 1ae0a341 2020-02-14 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
1340 1ae0a341 2020-02-14 stsp local new_commit2=`git_show_head $testroot/repo`
1342 1ae0a341 2020-02-14 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1343 1ae0a341 2020-02-14 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1344 1ae0a341 2020-02-14 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1345 1ae0a341 2020-02-14 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1347 1ae0a341 2020-02-14 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1348 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1349 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1350 1ae0a341 2020-02-14 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1351 1ae0a341 2020-02-14 stsp echo "D epsilon/zeta" >> $testroot/stdout.expected
1352 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1353 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1354 1ae0a341 2020-02-14 stsp echo ": removing zeta on newbranch" \
1355 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1356 1ae0a341 2020-02-14 stsp echo "Switching work tree to refs/heads/newbranch" \
1357 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1359 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1361 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1362 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
1363 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1367 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/content.expected
1368 1ae0a341 2020-02-14 stsp cat $testroot/wt/gamma/delta > $testroot/content
1369 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1371 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1372 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1373 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1377 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/content.expected
1378 1ae0a341 2020-02-14 stsp cat $testroot/wt/alpha > $testroot/content
1379 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1381 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1382 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1383 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1387 1ae0a341 2020-02-14 stsp if [ -e $testroot/wt/epsilon ]; then
1388 1ae0a341 2020-02-14 stsp echo "parent of removed zeta still exists on disk" >&2
1389 1ae0a341 2020-02-14 stsp test_done "$testroot" "1"
1393 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got status > $testroot/stdout)
1395 1ae0a341 2020-02-14 stsp echo -n > $testroot/stdout.expected
1396 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1398 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1399 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1400 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1404 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1405 1ae0a341 2020-02-14 stsp echo "commit $new_commit2 (newbranch)" > $testroot/stdout.expected
1406 1ae0a341 2020-02-14 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1407 1ae0a341 2020-02-14 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1408 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1410 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1411 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1413 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1416 f6cae3ed 2020-09-13 naddy test_rebase_delete_missing_file() {
1417 ca6da77d 2020-03-22 stsp local testroot=`test_init rebase_delete_missing_file`
1419 ca6da77d 2020-03-22 stsp mkdir -p $testroot/repo/d/f/g
1420 ca6da77d 2020-03-22 stsp echo "new file" > $testroot/repo/d/f/g/new
1421 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add d/f/g/new
1422 ca6da77d 2020-03-22 stsp git_commit $testroot/repo -m "adding a subdir"
1423 ca6da77d 2020-03-22 stsp local commit0=`git_show_head $testroot/repo`
1425 a740a1b3 2020-03-22 stsp got br -r $testroot/repo -c master newbranch
1427 a740a1b3 2020-03-22 stsp got checkout -b newbranch $testroot/repo $testroot/wt > /dev/null
1429 a740a1b3 2020-03-22 stsp echo "modified delta on branch" > $testroot/wt/gamma/delta
1430 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1431 a740a1b3 2020-03-22 stsp -m "committing to delta on newbranch" > /dev/null)
1433 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1434 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1435 a740a1b3 2020-03-22 stsp -m "removing beta and d/f/g/new on newbranch" > /dev/null)
1437 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q newbranch
1438 ca6da77d 2020-03-22 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1439 ca6da77d 2020-03-22 stsp local orig_commit2=`git_show_head $testroot/repo`
1441 1fa49072 2021-09-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1442 1fa49072 2021-09-28 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1444 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got update -b master > /dev/null)
1445 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1446 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1447 a740a1b3 2020-03-22 stsp -m "removing beta and d/f/g/new on master" > /dev/null)
1449 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q master
1450 ca6da77d 2020-03-22 stsp local master_commit=`git_show_head $testroot/repo`
1452 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got update -b master > /dev/null)
1453 1fa49072 2021-09-28 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
1454 1fa49072 2021-09-28 stsp 2> $testroot/stderr)
1456 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1457 1fa49072 2021-09-28 stsp echo "rebase succeeded unexpectedly" >&2
1458 1fa49072 2021-09-28 stsp test_done "$testroot" "1"
1462 1fa49072 2021-09-28 stsp local new_commit1=$(cd $testroot/wt && got info | \
1463 1fa49072 2021-09-28 stsp grep '^work tree base commit: ' | cut -d: -f2 | tr -d ' ')
1465 ca6da77d 2020-03-22 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1466 ca6da77d 2020-03-22 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1468 ca6da77d 2020-03-22 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1469 ca6da77d 2020-03-22 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1470 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1471 ca6da77d 2020-03-22 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1472 ca6da77d 2020-03-22 stsp echo "! beta" >> $testroot/stdout.expected
1473 ca6da77d 2020-03-22 stsp echo "! d/f/g/new" >> $testroot/stdout.expected
1474 35ca1db7 2021-09-28 stsp echo -n "Files which had incoming changes but could not be found " \
1475 35ca1db7 2021-09-28 stsp >> $testroot/stdout.expected
1476 35ca1db7 2021-09-28 stsp echo "in the work tree: 2" >> $testroot/stdout.expected
1477 1fa49072 2021-09-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1479 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1480 1fa49072 2021-09-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1481 1fa49072 2021-09-28 stsp test_done "$testroot" "$ret"
1485 1fa49072 2021-09-28 stsp echo -n "got: changes destined for some files were not yet merged " \
1486 1fa49072 2021-09-28 stsp > $testroot/stderr.expected
1487 1fa49072 2021-09-28 stsp echo -n "and should be merged manually if required before the " \
1488 1fa49072 2021-09-28 stsp >> $testroot/stderr.expected
1489 1fa49072 2021-09-28 stsp echo "rebase operation is continued" >> $testroot/stderr.expected
1490 1fa49072 2021-09-28 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1492 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1493 1fa49072 2021-09-28 stsp diff -u $testroot/stderr.expected $testroot/stderr
1494 1fa49072 2021-09-28 stsp test_done "$testroot" "$ret"
1498 1fa49072 2021-09-28 stsp # ignore the missing changes and continue
1499 1fa49072 2021-09-28 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
1501 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1502 1fa49072 2021-09-28 stsp echo "rebase failed unexpectedly" >&2
1503 1fa49072 2021-09-28 stsp test_done "$testroot" "1"
1506 ca6da77d 2020-03-22 stsp echo -n "$short_orig_commit2 -> no-op change" \
1507 1fa49072 2021-09-28 stsp > $testroot/stdout.expected
1508 a740a1b3 2020-03-22 stsp echo ": removing beta and d/f/g/new on newbranch" \
1509 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1510 ca6da77d 2020-03-22 stsp echo "Switching work tree to refs/heads/newbranch" \
1511 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1513 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1515 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1516 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1517 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1521 ca6da77d 2020-03-22 stsp echo "modified delta on branch" > $testroot/content.expected
1522 ca6da77d 2020-03-22 stsp cat $testroot/wt/gamma/delta > $testroot/content
1523 ca6da77d 2020-03-22 stsp cmp -s $testroot/content.expected $testroot/content
1525 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1526 ca6da77d 2020-03-22 stsp diff -u $testroot/content.expected $testroot/content
1527 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1531 ca6da77d 2020-03-22 stsp if [ -e $testroot/wt/beta ]; then
1532 ca6da77d 2020-03-22 stsp echo "removed file beta still exists on disk" >&2
1533 ca6da77d 2020-03-22 stsp test_done "$testroot" "1"
1537 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got status > $testroot/stdout)
1539 ca6da77d 2020-03-22 stsp echo -n > $testroot/stdout.expected
1540 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1542 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1543 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1544 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1548 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q newbranch
1549 1fa49072 2021-09-28 stsp local new_commit1=`git_show_head $testroot/repo`
1550 1fa49072 2021-09-28 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1552 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1553 ca6da77d 2020-03-22 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
1554 ca6da77d 2020-03-22 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1555 ca6da77d 2020-03-22 stsp echo "commit $commit0" >> $testroot/stdout.expected
1556 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1558 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1559 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1561 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1564 f6cae3ed 2020-09-13 naddy test_rebase_rm_add_rm_file() {
1565 70551d57 2020-04-24 stsp local testroot=`test_init rebase_rm_add_rm_file`
1567 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q -b newbranch
1568 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
1569 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "removing beta from newbranch"
1570 70551d57 2020-04-24 stsp local orig_commit1=`git_show_head $testroot/repo`
1572 70551d57 2020-04-24 stsp echo 'restored beta' > $testroot/repo/beta
1573 f73bf5bd 2023-10-01 naddy git -C $testroot/repo add beta
1574 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "restoring beta on newbranch"
1575 70551d57 2020-04-24 stsp local orig_commit2=`git_show_head $testroot/repo`
1577 f73bf5bd 2023-10-01 naddy git -C $testroot/repo rm -q beta
1578 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "removing beta from newbranch again"
1579 70551d57 2020-04-24 stsp local orig_commit3=`git_show_head $testroot/repo`
1581 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q master
1582 70551d57 2020-04-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1583 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
1584 70551d57 2020-04-24 stsp local master_commit=`git_show_head $testroot/repo`
1586 70551d57 2020-04-24 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1588 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1589 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1593 70551d57 2020-04-24 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1595 70551d57 2020-04-24 stsp # this would error out with 'got: file index is corrupt'
1596 70551d57 2020-04-24 stsp (cd $testroot/wt && got status > /dev/null)
1598 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1599 70551d57 2020-04-24 stsp echo "got status command failed unexpectedly" >&2
1600 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1604 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q newbranch
1605 70551d57 2020-04-24 stsp local new_commit3=`git_show_head $testroot/repo`
1606 70551d57 2020-04-24 stsp local new_commit2=`git_show_parent_commit $testroot/repo`
1607 70551d57 2020-04-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo $new_commit2`
1609 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q newbranch
1611 70551d57 2020-04-24 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1612 70551d57 2020-04-24 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1613 70551d57 2020-04-24 stsp local short_orig_commit3=`trim_obj_id 28 $orig_commit3`
1614 70551d57 2020-04-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1615 70551d57 2020-04-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1616 70551d57 2020-04-24 stsp local short_new_commit3=`trim_obj_id 28 $new_commit3`
1618 70551d57 2020-04-24 stsp echo "D beta" > $testroot/stdout.expected
1619 70551d57 2020-04-24 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1620 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1621 70551d57 2020-04-24 stsp echo ": removing beta from newbranch" >> $testroot/stdout.expected
1622 70551d57 2020-04-24 stsp echo "A beta" >> $testroot/stdout.expected
1623 70551d57 2020-04-24 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1624 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1625 70551d57 2020-04-24 stsp echo ": restoring beta on newbranch" >> $testroot/stdout.expected
1626 70551d57 2020-04-24 stsp echo "D beta" >> $testroot/stdout.expected
1627 70551d57 2020-04-24 stsp echo -n "$short_orig_commit3 -> $short_new_commit3" \
1628 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1629 70551d57 2020-04-24 stsp echo ": removing beta from newbranch again" >> $testroot/stdout.expected
1630 70551d57 2020-04-24 stsp echo "Switching work tree to refs/heads/newbranch" \
1631 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1633 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1635 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1636 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1637 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1641 70551d57 2020-04-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1643 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1644 70551d57 2020-04-24 stsp echo "got status command failed unexpectedly" >&2
1645 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1649 70551d57 2020-04-24 stsp echo -n > $testroot/stdout.expected
1650 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1652 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1653 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1654 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1658 70551d57 2020-04-24 stsp (cd $testroot/wt && got log -l4 | grep ^commit > $testroot/stdout)
1659 70551d57 2020-04-24 stsp echo "commit $new_commit3 (newbranch)" > $testroot/stdout.expected
1660 70551d57 2020-04-24 stsp echo "commit $new_commit2" >> $testroot/stdout.expected
1661 70551d57 2020-04-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1662 70551d57 2020-04-24 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1663 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1665 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1666 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1668 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1671 598eac43 2022-07-22 stsp test_rebase_resets_committer() {
1672 598eac43 2022-07-22 stsp local testroot=`test_init rebase_resets_committer`
1673 598eac43 2022-07-22 stsp local commit0=`git_show_head $testroot/repo`
1674 598eac43 2022-07-22 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1675 598eac43 2022-07-22 stsp local committer="Flan Luck <flan_luck@openbsd.org>"
1677 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q -b newbranch
1678 598eac43 2022-07-22 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1679 598eac43 2022-07-22 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1681 598eac43 2022-07-22 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1682 598eac43 2022-07-22 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
1684 598eac43 2022-07-22 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1685 598eac43 2022-07-22 stsp local orig_commit2=`git_show_head $testroot/repo`
1686 598eac43 2022-07-22 stsp local orig_author_time2=`git_show_author_time $testroot/repo`
1688 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q master
1689 598eac43 2022-07-22 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1690 598eac43 2022-07-22 stsp git_commit $testroot/repo -m "committing to zeta on master"
1691 598eac43 2022-07-22 stsp local master_commit=`git_show_head $testroot/repo`
1693 598eac43 2022-07-22 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1695 598eac43 2022-07-22 stsp if [ $ret -ne 0 ]; then
1696 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
1700 598eac43 2022-07-22 stsp (cd $testroot/wt && env GOT_AUTHOR="$committer" \
1701 598eac43 2022-07-22 stsp got rebase newbranch > $testroot/stdout)
1703 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q newbranch
1704 598eac43 2022-07-22 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
1705 598eac43 2022-07-22 stsp local new_commit2=`git_show_head $testroot/repo`
1706 598eac43 2022-07-22 stsp local new_author_time2=`git_show_author_time $testroot/repo`
1708 598eac43 2022-07-22 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1709 598eac43 2022-07-22 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1710 598eac43 2022-07-22 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1711 598eac43 2022-07-22 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1713 598eac43 2022-07-22 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1714 598eac43 2022-07-22 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1715 598eac43 2022-07-22 stsp >> $testroot/stdout.expected
1716 598eac43 2022-07-22 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1717 598eac43 2022-07-22 stsp echo "G alpha" >> $testroot/stdout.expected
1718 598eac43 2022-07-22 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1719 598eac43 2022-07-22 stsp >> $testroot/stdout.expected
1720 598eac43 2022-07-22 stsp echo ": committing more changes on newbranch" \
1721 598eac43 2022-07-22 stsp >> $testroot/stdout.expected
1722 598eac43 2022-07-22 stsp echo "Switching work tree to refs/heads/newbranch" \
1723 598eac43 2022-07-22 stsp >> $testroot/stdout.expected
1725 598eac43 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1727 598eac43 2022-07-22 stsp if [ $ret -ne 0 ]; then
1728 598eac43 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1729 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
1733 598eac43 2022-07-22 stsp # Original commit only had one author
1734 598eac43 2022-07-22 stsp (cd $testroot/repo && got log -l1 -c $orig_commit2 | \
1735 598eac43 2022-07-22 stsp egrep '^(from|via):' > $testroot/stdout)
1736 598eac43 2022-07-22 stsp echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
1737 598eac43 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1739 598eac43 2022-07-22 stsp if [ $ret -ne 0 ]; then
1740 598eac43 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1741 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
1745 598eac43 2022-07-22 stsp # Rebased commit should have new committer name added
1746 598eac43 2022-07-22 stsp (cd $testroot/repo && got log -l1 -c $new_commit2 | \
1747 598eac43 2022-07-22 stsp egrep '^(from|via):' > $testroot/stdout)
1748 598eac43 2022-07-22 stsp echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
1749 598eac43 2022-07-22 stsp echo "via: $committer" >> $testroot/stdout.expected
1751 50e7a649 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1753 50e7a649 2022-07-22 stsp if [ $ret -ne 0 ]; then
1754 50e7a649 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1756 50e7a649 2022-07-22 stsp test_done "$testroot" "$ret"
1759 50e7a649 2022-07-22 stsp test_rebase_no_author_info() {
1760 50e7a649 2022-07-22 stsp local testroot=`test_init rebase_no_author_info`
1761 50e7a649 2022-07-22 stsp local commit0=`git_show_head $testroot/repo`
1762 50e7a649 2022-07-22 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1763 50e7a649 2022-07-22 stsp local committer="$GOT_AUTHOR"
1765 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q -b newbranch
1766 50e7a649 2022-07-22 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1767 50e7a649 2022-07-22 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1769 50e7a649 2022-07-22 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1770 50e7a649 2022-07-22 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
1772 50e7a649 2022-07-22 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1773 50e7a649 2022-07-22 stsp local orig_commit2=`git_show_head $testroot/repo`
1774 50e7a649 2022-07-22 stsp local orig_author_time2=`git_show_author_time $testroot/repo`
1776 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q master
1777 50e7a649 2022-07-22 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1778 50e7a649 2022-07-22 stsp git_commit $testroot/repo -m "committing to zeta on master"
1779 50e7a649 2022-07-22 stsp local master_commit=`git_show_head $testroot/repo`
1781 50e7a649 2022-07-22 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1783 50e7a649 2022-07-22 stsp if [ $ret -ne 0 ]; then
1784 50e7a649 2022-07-22 stsp test_done "$testroot" "$ret"
1788 1004841d 2022-07-24 op # unset in a subshell to avoid affecting our environment
1789 1004841d 2022-07-24 op (unset GOT_AUTHOR && cd $testroot/wt && \
1790 1004841d 2022-07-24 op got rebase newbranch > $testroot/stdout)
1792 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q newbranch
1793 50e7a649 2022-07-22 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
1794 50e7a649 2022-07-22 stsp local new_commit2=`git_show_head $testroot/repo`
1795 50e7a649 2022-07-22 stsp local new_author_time2=`git_show_author_time $testroot/repo`
1797 50e7a649 2022-07-22 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1798 50e7a649 2022-07-22 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1799 50e7a649 2022-07-22 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1800 50e7a649 2022-07-22 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1802 50e7a649 2022-07-22 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1803 50e7a649 2022-07-22 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1804 50e7a649 2022-07-22 stsp >> $testroot/stdout.expected
1805 50e7a649 2022-07-22 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1806 50e7a649 2022-07-22 stsp echo "G alpha" >> $testroot/stdout.expected
1807 50e7a649 2022-07-22 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1808 50e7a649 2022-07-22 stsp >> $testroot/stdout.expected
1809 50e7a649 2022-07-22 stsp echo ": committing more changes on newbranch" \
1810 50e7a649 2022-07-22 stsp >> $testroot/stdout.expected
1811 50e7a649 2022-07-22 stsp echo "Switching work tree to refs/heads/newbranch" \
1812 50e7a649 2022-07-22 stsp >> $testroot/stdout.expected
1814 598eac43 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1816 598eac43 2022-07-22 stsp if [ $ret -ne 0 ]; then
1817 598eac43 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1818 50e7a649 2022-07-22 stsp test_done "$testroot" "$ret"
1822 50e7a649 2022-07-22 stsp # Original commit only had one author
1823 50e7a649 2022-07-22 stsp (cd $testroot/repo && got log -l1 -c $orig_commit2 | \
1824 50e7a649 2022-07-22 stsp egrep '^(from|via):' > $testroot/stdout)
1825 50e7a649 2022-07-22 stsp echo "from: $committer" > $testroot/stdout.expected
1826 50e7a649 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1828 50e7a649 2022-07-22 stsp if [ $ret -ne 0 ]; then
1829 50e7a649 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1830 50e7a649 2022-07-22 stsp test_done "$testroot" "$ret"
1834 50e7a649 2022-07-22 stsp # Author info of rebased commit should match the original
1835 50e7a649 2022-07-22 stsp (cd $testroot/repo && got log -l1 -c $new_commit2 | \
1836 50e7a649 2022-07-22 stsp egrep '^(from|via):' > $testroot/stdout)
1837 50e7a649 2022-07-22 stsp echo "from: $committer" > $testroot/stdout.expected
1839 50e7a649 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1841 50e7a649 2022-07-22 stsp if [ $ret -ne 0 ]; then
1842 50e7a649 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1844 442ede73 2022-09-04 stsp test_done "$testroot" "$ret"
1847 442ede73 2022-09-04 stsp test_rebase_nonbranch() {
1848 442ede73 2022-09-04 stsp local testroot=`test_init rebase_nonbranch`
1850 442ede73 2022-09-04 stsp got ref -r $testroot/repo -c refs/heads/master \
1851 442ede73 2022-09-04 stsp refs/remotes/origin/master >/dev/null
1853 442ede73 2022-09-04 stsp got checkout -b master $testroot/repo $testroot/wt >/dev/null
1855 442ede73 2022-09-04 stsp (cd $testroot/wt && got rebase origin/master > $testroot/stdout \
1856 442ede73 2022-09-04 stsp 2> $testroot/stderr)
1858 442ede73 2022-09-04 stsp if [ $ret -eq 0 ]; then
1859 442ede73 2022-09-04 stsp echo "rebase succeeded unexpectedly" >&2
1860 442ede73 2022-09-04 stsp test_done "$testroot" "1"
1863 442ede73 2022-09-04 stsp echo -n "got: will not rebase a branch which lives outside the " \
1864 442ede73 2022-09-04 stsp > $testroot/stderr.expected
1865 442ede73 2022-09-04 stsp echo '"refs/heads/" reference namespace' >> $testroot/stderr.expected
1866 442ede73 2022-09-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1868 442ede73 2022-09-04 stsp if [ $ret -ne 0 ]; then
1869 442ede73 2022-09-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
1871 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
1874 b2b3fce1 2022-10-29 op test_rebase_umask() {
1875 b2b3fce1 2022-10-29 op local testroot=`test_init rebase_umask`
1876 b2b3fce1 2022-10-29 op local commit0=`git_show_head "$testroot/repo"`
1878 b2b3fce1 2022-10-29 op got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1879 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got branch newbranch) >/dev/null
1881 b2b3fce1 2022-10-29 op echo "modified alpha on branch" >$testroot/wt/alpha
1882 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got commit -m 'modified alpha on newbranch') \
1885 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got update -b master) >/dev/null
1887 b2b3fce1 2022-10-29 op if [ $ret -ne 0 ]; then
1888 b2b3fce1 2022-10-29 op echo "got update failed!" >&2
1889 b2b3fce1 2022-10-29 op test_done "$testroot" $ret
1893 b2b3fce1 2022-10-29 op echo "modified beta on master" >$testroot/wt/beta
1894 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got commit -m 'modified beta on master') \
1896 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got update) >/dev/null
1898 b2b3fce1 2022-10-29 op # using a subshell to avoid clobbering global umask
1899 b2b3fce1 2022-10-29 op (umask 077 && cd "$testroot/wt" && got rebase newbranch) >/dev/null
1901 b2b3fce1 2022-10-29 op if [ $ret -ne 0 ]; then
1902 b2b3fce1 2022-10-29 op echo "got rebase failed" >&2
1903 b2b3fce1 2022-10-29 op test_done "$testroot" $ret
1907 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/alpha" | grep -q ^-rw-------
1908 b2b3fce1 2022-10-29 op if [ $? -ne 0 ]; then
1909 b2b3fce1 2022-10-29 op echo "alpha is not 0600 after rebase" >&2
1910 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/alpha" >&2
1911 b2b3fce1 2022-10-29 op test_done "$testroot" 1
1915 b2b3fce1 2022-10-29 op test_done "$testroot" 0
1918 49a1ae4b 2023-01-08 stsp test_rebase_out_of_date2() {
1919 49a1ae4b 2023-01-08 stsp local testroot=`test_init rebase_out_of_date2`
1920 49a1ae4b 2023-01-08 stsp local commit0=`git_show_head $testroot/repo`
1921 49a1ae4b 2023-01-08 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1923 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q -b newbranch
1924 49a1ae4b 2023-01-08 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1925 49a1ae4b 2023-01-08 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1927 49a1ae4b 2023-01-08 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1928 49a1ae4b 2023-01-08 stsp local orig_commit2=`git_show_head $testroot/repo`
1929 49a1ae4b 2023-01-08 stsp local orig_author_time2=`git_show_author_time $testroot/repo`
1931 f73bf5bd 2023-10-01 naddy git -C $testroot/repo checkout -q master
1932 49a1ae4b 2023-01-08 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1933 49a1ae4b 2023-01-08 stsp git_commit $testroot/repo -m "committing to zeta on master"
1934 49a1ae4b 2023-01-08 stsp local master_commit=`git_show_head $testroot/repo`
1936 49a1ae4b 2023-01-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1938 49a1ae4b 2023-01-08 stsp if [ $ret -ne 0 ]; then
1939 49a1ae4b 2023-01-08 stsp test_done "$testroot" "$ret"
1943 49a1ae4b 2023-01-08 stsp # Backdate the file alpha to an earlier version.
1944 49a1ae4b 2023-01-08 stsp # This sets the work tree's base commit ID back to $commit0,
1945 49a1ae4b 2023-01-08 stsp # which is out-of-date with respect to the master branch.
1946 49a1ae4b 2023-01-08 stsp (cd $testroot/wt && got update -c $commit0 alpha > /dev/null)
1948 49a1ae4b 2023-01-08 stsp # Rebase into an out-of-date work tree should be refused.
1949 49a1ae4b 2023-01-08 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
1950 49a1ae4b 2023-01-08 stsp 2> $testroot/stderr)
1952 49a1ae4b 2023-01-08 stsp if [ $ret -eq 0 ]; then
1953 49a1ae4b 2023-01-08 stsp echo "rebase succeeded unexpectedly" >&2
1954 49a1ae4b 2023-01-08 stsp test_done "$testroot" "1"
1957 49a1ae4b 2023-01-08 stsp echo -n > $testroot/stdout.expected
1958 49a1ae4b 2023-01-08 stsp echo -n "got: work tree must be updated before it can be used to " \
1959 49a1ae4b 2023-01-08 stsp > $testroot/stderr.expected
1960 49a1ae4b 2023-01-08 stsp echo "rebase a branch" >> $testroot/stderr.expected
1961 49a1ae4b 2023-01-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1963 49a1ae4b 2023-01-08 stsp if [ $ret -ne 0 ]; then
1964 49a1ae4b 2023-01-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
1966 49a1ae4b 2023-01-08 stsp test_done "$testroot" "$ret"
1969 980c6786 2023-01-31 stsp test_rebase_one_commit() {
1970 980c6786 2023-01-31 stsp local testroot=`test_init rebase_one_commit`
1972 980c6786 2023-01-31 stsp if ! got checkout $testroot/repo $testroot/wt >/dev/null; then
1973 980c6786 2023-01-31 stsp test_done "$testroot" 1
1977 980c6786 2023-01-31 stsp (cd $testroot/wt && got branch newbranch) >/dev/null
1979 980c6786 2023-01-31 stsp echo "modified alpha on newbranch" >$testroot/wt/alpha
1980 980c6786 2023-01-31 stsp (cd $testroot/wt && got commit -m 'edit alpha') >/dev/null
1981 980c6786 2023-01-31 stsp (cd $testroot/wt && got update) >/dev/null
1982 980c6786 2023-01-31 stsp local commit=`git_show_branch_head $testroot/repo newbranch`
1984 980c6786 2023-01-31 stsp echo -n '' > $testroot/stderr.expected
1986 980c6786 2023-01-31 stsp (cd $testroot/wt && got rebase master >$testroot/stdout \
1987 980c6786 2023-01-31 stsp 2> $testroot/stderr)
1989 980c6786 2023-01-31 stsp if [ $ret -ne 0 ]; then
1990 980c6786 2023-01-31 stsp echo "rebase comand failed unexpectedly" >&2
1991 980c6786 2023-01-31 stsp diff -u $testroot/stderr.expected $testroot/stderr
1992 980c6786 2023-01-31 stsp test_done "$testroot" "1"
1996 980c6786 2023-01-31 stsp echo "Forwarding refs/heads/master to commit $commit" \
1997 980c6786 2023-01-31 stsp >$testroot/stdout.expected
1998 980c6786 2023-01-31 stsp echo "Switching work tree to refs/heads/master" \
1999 980c6786 2023-01-31 stsp >> $testroot/stdout.expected
2001 980c6786 2023-01-31 stsp if ! cmp -s $testroot/stdout.expected $testroot/stdout; then
2002 980c6786 2023-01-31 stsp diff -u $testroot/stdout.expected $testroot/stdout
2003 980c6786 2023-01-31 stsp test_done "$testroot" 1
2007 980c6786 2023-01-31 stsp test_done "$testroot" 0
2010 7fb414ae 2020-08-08 stsp test_parseargs "$@"
2011 dcf44d04 2019-07-11 stsp run_test test_rebase_basic
2012 dcf44d04 2019-07-11 stsp run_test test_rebase_ancestry_check
2013 dcf44d04 2019-07-11 stsp run_test test_rebase_continue
2014 dcf44d04 2019-07-11 stsp run_test test_rebase_abort
2015 ff0d2220 2019-07-11 stsp run_test test_rebase_no_op_change
2016 7d5807f4 2019-07-11 stsp run_test test_rebase_in_progress
2017 64c6d990 2019-07-11 stsp run_test test_rebase_path_prefix
2018 787c8eb6 2019-07-11 stsp run_test test_rebase_preserves_logmsg
2019 fc66b545 2019-08-12 stsp run_test test_rebase_no_commits_to_rebase
2020 38b0338b 2019-11-29 stsp run_test test_rebase_forward
2021 0a706d22 2022-09-21 stsp run_test test_rebase_forward_path_prefix
2022 e51d7b55 2020-01-04 stsp run_test test_rebase_out_of_date
2023 1ae0a341 2020-02-14 stsp run_test test_rebase_trims_empty_dir
2024 ca6da77d 2020-03-22 stsp run_test test_rebase_delete_missing_file
2025 70551d57 2020-04-24 stsp run_test test_rebase_rm_add_rm_file
2026 598eac43 2022-07-22 stsp run_test test_rebase_resets_committer
2027 50e7a649 2022-07-22 stsp run_test test_rebase_no_author_info
2028 442ede73 2022-09-04 stsp run_test test_rebase_nonbranch
2029 b2b3fce1 2022-10-29 op run_test test_rebase_umask
2030 49a1ae4b 2023-01-08 stsp run_test test_rebase_out_of_date2
2031 980c6786 2023-01-31 stsp run_test test_rebase_one_commit