3 5aa81393 2020-01-06 stsp # Copyright (c) 2019, 2020 Stefan Sperling <stsp@openbsd.org>
5 818c7501 2019-07-11 stsp # Permission to use, copy, modify, and distribute this software for any
6 818c7501 2019-07-11 stsp # purpose with or without fee is hereby granted, provided that the above
7 818c7501 2019-07-11 stsp # copyright notice and this permission notice appear in all copies.
9 818c7501 2019-07-11 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 818c7501 2019-07-11 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 818c7501 2019-07-11 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 818c7501 2019-07-11 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 818c7501 2019-07-11 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 818c7501 2019-07-11 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 818c7501 2019-07-11 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 818c7501 2019-07-11 stsp . ./common.sh
19 f6cae3ed 2020-09-13 naddy test_rebase_basic() {
20 818c7501 2019-07-11 stsp local testroot=`test_init rebase_basic`
21 e600f124 2021-03-21 stsp local commit0=`git_show_head $testroot/repo`
22 e600f124 2021-03-21 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
24 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
25 818c7501 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
26 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
28 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
29 818c7501 2019-07-11 stsp (cd $testroot/repo && git rm -q beta)
30 818c7501 2019-07-11 stsp echo "new file on branch" > $testroot/repo/epsilon/new
31 818c7501 2019-07-11 stsp (cd $testroot/repo && git add epsilon/new)
32 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
34 818c7501 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
35 818c7501 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
36 e600f124 2021-03-21 stsp local orig_author_time2=`git_show_author_time $testroot/repo`
38 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
39 818c7501 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
40 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
41 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
43 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
45 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 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
53 818c7501 2019-07-11 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
54 818c7501 2019-07-11 stsp local new_commit2=`git_show_head $testroot/repo`
55 e600f124 2021-03-21 stsp local new_author_time2=`git_show_author_time $testroot/repo`
57 818c7501 2019-07-11 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
58 818c7501 2019-07-11 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
59 818c7501 2019-07-11 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
60 818c7501 2019-07-11 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
62 818c7501 2019-07-11 stsp echo "G gamma/delta" >> $testroot/stdout.expected
63 818c7501 2019-07-11 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
64 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
65 818c7501 2019-07-11 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
66 818c7501 2019-07-11 stsp echo "G alpha" >> $testroot/stdout.expected
67 818c7501 2019-07-11 stsp echo "D beta" >> $testroot/stdout.expected
68 818c7501 2019-07-11 stsp echo "A epsilon/new" >> $testroot/stdout.expected
69 818c7501 2019-07-11 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
70 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
71 818c7501 2019-07-11 stsp echo ": committing more changes on newbranch" \
72 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
73 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
74 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
76 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
78 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 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
244 818c7501 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
245 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
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 818c7501 2019-07-11 stsp (cd $testroot/repo && git 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 818c7501 2019-07-11 stsp (cd $testroot/repo && git 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 818c7501 2019-07-11 stsp (cd $testroot/repo && git 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 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
416 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
417 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha 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 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
422 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
423 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
424 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
426 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
428 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
429 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
433 41f061b2 2021-10-05 stsp # unrelated unversioned file in work tree
434 41f061b2 2021-10-05 stsp touch $testroot/wt/unversioned-file
436 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
437 818c7501 2019-07-11 stsp 2> $testroot/stderr)
439 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
440 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
441 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
442 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
443 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
444 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
446 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
447 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
448 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
452 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
453 818c7501 2019-07-11 stsp > $testroot/stderr.expected
454 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
456 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
457 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
458 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
462 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
463 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
464 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
465 f69721c3 2019-10-21 stsp >> $testroot/content.expected
466 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
467 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
468 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
469 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
470 54d5be07 2021-06-03 stsp >> $testroot/content.expected
471 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
472 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
474 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
475 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
476 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
480 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
482 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
483 41f061b2 2021-10-05 stsp echo "? unversioned-file" >> $testroot/stdout.expected
484 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
486 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
487 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
488 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
492 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -a > $testroot/stdout)
494 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
496 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/master" \
497 818c7501 2019-07-11 stsp > $testroot/stdout.expected
498 818c7501 2019-07-11 stsp echo 'R alpha' >> $testroot/stdout.expected
499 818c7501 2019-07-11 stsp echo "Rebase of refs/heads/newbranch aborted" \
500 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
502 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
504 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
505 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
506 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
510 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/content.expected
511 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
512 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
514 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
515 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
516 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
520 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l3 -c newbranch \
521 818c7501 2019-07-11 stsp | grep ^commit > $testroot/stdout)
522 818c7501 2019-07-11 stsp echo "commit $orig_commit1 (newbranch)" > $testroot/stdout.expected
523 818c7501 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
524 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
526 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
527 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
529 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
532 f6cae3ed 2020-09-13 naddy test_rebase_no_op_change() {
533 ff0d2220 2019-07-11 stsp local testroot=`test_init rebase_no_op_change`
534 ff0d2220 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
536 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
537 ff0d2220 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
538 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
539 ff0d2220 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
540 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
542 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
543 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
544 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
545 ff0d2220 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
547 ff0d2220 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
549 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
550 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
554 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
555 ff0d2220 2019-07-11 stsp 2> $testroot/stderr)
557 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
558 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
559 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
560 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
561 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
562 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
564 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
565 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
566 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
570 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
571 ff0d2220 2019-07-11 stsp > $testroot/stderr.expected
572 ff0d2220 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
574 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
575 ff0d2220 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
576 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
580 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
581 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
582 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
583 f69721c3 2019-10-21 stsp >> $testroot/content.expected
584 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
585 ff0d2220 2019-07-11 stsp echo "=======" >> $testroot/content.expected
586 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
587 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
588 54d5be07 2021-06-03 stsp >> $testroot/content.expected
589 ff0d2220 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
590 ff0d2220 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
592 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
593 ff0d2220 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
594 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
598 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
600 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
601 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
603 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
604 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
605 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
609 ff0d2220 2019-07-11 stsp # resolve the conflict
610 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/wt/alpha
612 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
614 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
615 ff0d2220 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
617 ff0d2220 2019-07-11 stsp echo -n "$short_orig_commit1 -> no-op change" \
618 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
619 ff0d2220 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
620 ff0d2220 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
621 ff0d2220 2019-07-11 stsp >> $testroot/stdout.expected
623 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
625 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
626 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
627 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
632 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
633 ff0d2220 2019-07-11 stsp echo "commit $master_commit (master, newbranch)" \
634 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
635 ff0d2220 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
636 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
638 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
639 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
641 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
644 f6cae3ed 2020-09-13 naddy test_rebase_in_progress() {
645 4ba9c4f6 2019-07-11 stsp local testroot=`test_init rebase_in_progress`
646 7d5807f4 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
648 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
649 7d5807f4 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
650 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
651 7d5807f4 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
652 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
654 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
655 7d5807f4 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
656 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
657 7d5807f4 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
659 7d5807f4 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
661 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
662 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
666 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
667 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
669 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
670 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
671 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
672 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
673 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
674 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
676 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
677 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
678 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
682 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
683 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
684 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
686 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
687 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
688 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
692 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
693 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
694 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
695 f69721c3 2019-10-21 stsp >> $testroot/content.expected
696 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
697 7d5807f4 2019-07-11 stsp echo "=======" >> $testroot/content.expected
698 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
699 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
700 54d5be07 2021-06-03 stsp >> $testroot/content.expected
701 7d5807f4 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
702 7d5807f4 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
704 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
705 7d5807f4 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
706 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
710 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
712 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
713 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
715 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
716 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
717 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
721 7d5807f4 2019-07-11 stsp for cmd in update commit; do
722 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got $cmd > $testroot/stdout \
723 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
725 7d5807f4 2019-07-11 stsp echo -n > $testroot/stdout.expected
726 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
728 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
729 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
730 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
734 7d5807f4 2019-07-11 stsp echo -n "got: a rebase operation is in progress in this " \
735 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
736 7d5807f4 2019-07-11 stsp echo "work tree and must be continued or aborted first" \
737 7d5807f4 2019-07-11 stsp >> $testroot/stderr.expected
738 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
740 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
741 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
742 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
747 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
750 f6cae3ed 2020-09-13 naddy test_rebase_path_prefix() {
751 64c6d990 2019-07-11 stsp local testroot=`test_init rebase_path_prefix`
753 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
754 64c6d990 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
755 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
757 64c6d990 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
758 64c6d990 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
760 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
761 64c6d990 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
762 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
763 64c6d990 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
765 64c6d990 2019-07-11 stsp got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
767 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
768 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
772 64c6d990 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch \
773 64c6d990 2019-07-11 stsp > $testroot/stdout 2> $testroot/stderr)
775 64c6d990 2019-07-11 stsp echo -n > $testroot/stdout.expected
776 64c6d990 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
778 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
779 64c6d990 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
780 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
784 64c6d990 2019-07-11 stsp echo -n "got: cannot rebase branch which contains changes outside " \
785 64c6d990 2019-07-11 stsp > $testroot/stderr.expected
786 64c6d990 2019-07-11 stsp echo "of this work tree's path prefix" >> $testroot/stderr.expected
787 787c8eb6 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
789 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
790 787c8eb6 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
791 67ba6161 2022-04-08 stsp test_done "$testroot" "$ret"
795 67ba6161 2022-04-08 stsp # rebase should succeed when using a complete work tree
796 67ba6161 2022-04-08 stsp got checkout $testroot/repo $testroot/wt2 > /dev/null
798 67ba6161 2022-04-08 stsp if [ $ret -ne 0 ]; then
799 67ba6161 2022-04-08 stsp test_done "$testroot" "$ret"
803 67ba6161 2022-04-08 stsp (cd $testroot/wt2 && got rebase newbranch \
804 67ba6161 2022-04-08 stsp > $testroot/stdout 2> $testroot/stderr)
806 67ba6161 2022-04-08 stsp (cd $testroot/repo && git checkout -q newbranch)
807 67ba6161 2022-04-08 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
808 67ba6161 2022-04-08 stsp local new_commit2=`git_show_head $testroot/repo`
810 67ba6161 2022-04-08 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
811 67ba6161 2022-04-08 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
813 67ba6161 2022-04-08 stsp echo "G gamma/delta" > $testroot/stdout.expected
814 67ba6161 2022-04-08 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
815 67ba6161 2022-04-08 stsp >> $testroot/stdout.expected
816 67ba6161 2022-04-08 stsp echo ": committing to delta on newbranch" \
817 67ba6161 2022-04-08 stsp >> $testroot/stdout.expected
818 67ba6161 2022-04-08 stsp echo "Switching work tree to refs/heads/newbranch" \
819 67ba6161 2022-04-08 stsp >> $testroot/stdout.expected
821 67ba6161 2022-04-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
823 67ba6161 2022-04-08 stsp if [ $ret -ne 0 ]; then
824 67ba6161 2022-04-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
825 67ba6161 2022-04-08 stsp test_done "$testroot" "$ret"
829 67ba6161 2022-04-08 stsp # the first work tree should remain usable
830 67ba6161 2022-04-08 stsp (cd $testroot/wt && got update -b master \
831 67ba6161 2022-04-08 stsp > $testroot/stdout 2> $testroot/stderr)
833 67ba6161 2022-04-08 stsp if [ $ret -ne 0 ]; then
834 67ba6161 2022-04-08 stsp echo "update failed unexpectedly" >&2
835 67ba6161 2022-04-08 stsp test_done "$testroot" "1"
839 67ba6161 2022-04-08 stsp echo 'Already up-to-date' > $testroot/stdout.expected
840 67ba6161 2022-04-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
842 67ba6161 2022-04-08 stsp if [ $ret -ne 0 ]; then
843 67ba6161 2022-04-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
845 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
848 f6cae3ed 2020-09-13 naddy test_rebase_preserves_logmsg() {
849 787c8eb6 2019-07-11 stsp local testroot=`test_init rebase_preserves_logmsg`
851 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
852 787c8eb6 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
853 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified delta on newbranch"
855 787c8eb6 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
856 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified alpha on newbranch"
858 787c8eb6 2019-07-11 stsp (cd $testroot/repo && got log -c newbranch -l2 | grep -v ^date: \
859 787c8eb6 2019-07-11 stsp > $testroot/log.expected)
861 787c8eb6 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
862 787c8eb6 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
864 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
865 787c8eb6 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
866 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
867 787c8eb6 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
869 787c8eb6 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
871 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
872 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
876 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > /dev/null \
877 787c8eb6 2019-07-11 stsp 2> $testroot/stderr)
879 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
880 787c8eb6 2019-07-11 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
881 787c8eb6 2019-07-11 stsp local new_commit2=`git_show_head $testroot/repo`
883 787c8eb6 2019-07-11 stsp echo -n > $testroot/stderr.expected
884 64c6d990 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
886 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
887 64c6d990 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
888 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
892 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got log -c newbranch -l2 | grep -v ^date: \
893 787c8eb6 2019-07-11 stsp > $testroot/log)
894 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit1/$new_commit1/" $testroot/log.expected
895 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit2/$new_commit2/" $testroot/log.expected
896 787c8eb6 2019-07-11 stsp cmp -s $testroot/log.expected $testroot/log
898 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
899 787c8eb6 2019-07-11 stsp diff -u $testroot/log.expected $testroot/log
902 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
905 f6cae3ed 2020-09-13 naddy test_rebase_no_commits_to_rebase() {
906 fc66b545 2019-08-12 stsp local testroot=`test_init rebase_no_commits_to_rebase`
908 fc66b545 2019-08-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
910 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
911 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
915 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n newbranch)
917 fc66b545 2019-08-12 stsp echo "modified alpha on master" > $testroot/wt/alpha
918 fc66b545 2019-08-12 stsp (cd $testroot/wt && got commit -m 'test rebase_no_commits_to_rebase' \
919 fc66b545 2019-08-12 stsp > /dev/null)
920 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > /dev/null)
922 fc66b545 2019-08-12 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
923 fc66b545 2019-08-12 stsp 2> $testroot/stderr)
925 fc66b545 2019-08-12 stsp echo "got: no commits to rebase" > $testroot/stderr.expected
926 fc66b545 2019-08-12 stsp cmp -s $testroot/stderr.expected $testroot/stderr
928 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
929 fc66b545 2019-08-12 stsp diff -u $testroot/stderr.expected $testroot/stderr
930 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
934 67ba6161 2022-04-08 stsp echo -n > $testroot/stdout.expected
935 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
937 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
938 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
939 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
943 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
944 fc66b545 2019-08-12 stsp echo "Already up-to-date" > $testroot/stdout.expected
945 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
947 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
948 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
950 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
953 f6cae3ed 2020-09-13 naddy test_rebase_forward() {
954 38b0338b 2019-11-29 stsp local testroot=`test_init rebase_forward`
955 38b0338b 2019-11-29 stsp local commit0=`git_show_head $testroot/repo`
957 38b0338b 2019-11-29 stsp got checkout $testroot/repo $testroot/wt > /dev/null
959 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
960 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
964 38b0338b 2019-11-29 stsp echo "change alpha 1" > $testroot/wt/alpha
965 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
966 38b0338b 2019-11-29 stsp > /dev/null)
967 38b0338b 2019-11-29 stsp local commit1=`git_show_head $testroot/repo`
969 38b0338b 2019-11-29 stsp echo "change alpha 2" > $testroot/wt/alpha
970 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
971 38b0338b 2019-11-29 stsp > /dev/null)
972 38b0338b 2019-11-29 stsp local commit2=`git_show_head $testroot/repo`
974 38b0338b 2019-11-29 stsp # Simulate a situation where fast-forward is required.
975 38b0338b 2019-11-29 stsp # We want to fast-forward master to origin/master:
976 38b0338b 2019-11-29 stsp # commit 3907e11dceaae2ca7f8db79c2af31794673945ad (origin/master)
977 38b0338b 2019-11-29 stsp # commit ffcffcd102cf1af6572fbdbb4cf07a0f1fd2d840 (master)
978 38b0338b 2019-11-29 stsp # commit 87a6a8a2263a15b61c016ff1720b24741d455eb5
979 993f033b 2021-07-16 stsp (cd $testroot/repo && got ref -d master >/dev/null)
980 e31abbf2 2020-03-22 stsp (cd $testroot/repo && got ref -c $commit1 refs/heads/master)
981 e31abbf2 2020-03-22 stsp (cd $testroot/repo && got ref -c $commit2 refs/remotes/origin/master)
983 38b0338b 2019-11-29 stsp (cd $testroot/wt && got up -b origin/master > /dev/null)
985 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase master \
986 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
988 38b0338b 2019-11-29 stsp echo "Forwarding refs/heads/master to commit $commit2" \
989 38b0338b 2019-11-29 stsp > $testroot/stdout.expected
990 38b0338b 2019-11-29 stsp echo "Switching work tree to refs/heads/master" \
991 38b0338b 2019-11-29 stsp >> $testroot/stdout.expected
992 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
994 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
995 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
996 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1000 38b0338b 2019-11-29 stsp # Ensure that rebase operation was completed correctly
1001 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase -a \
1002 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
1003 38b0338b 2019-11-29 stsp echo -n "" > $testroot/stdout.expected
1004 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1006 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1007 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
1008 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1011 38b0338b 2019-11-29 stsp echo "got: rebase operation not in progress" > $testroot/stderr.expected
1012 38b0338b 2019-11-29 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1014 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1015 38b0338b 2019-11-29 stsp diff -u $testroot/stderr.expected $testroot/stderr
1016 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1020 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n > $testroot/stdout)
1021 38b0338b 2019-11-29 stsp echo "master" > $testroot/stdout.expected
1022 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1024 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1025 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
1026 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1030 38b0338b 2019-11-29 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1031 38b0338b 2019-11-29 stsp echo "commit $commit2 (master, origin/master)" > $testroot/stdout.expected
1032 38b0338b 2019-11-29 stsp echo "commit $commit1" >> $testroot/stdout.expected
1033 38b0338b 2019-11-29 stsp echo "commit $commit0" >> $testroot/stdout.expected
1034 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1036 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1037 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
1038 e600f124 2021-03-21 stsp test_done "$testroot" "$ret"
1042 e600f124 2021-03-21 stsp # Forward-only rebase operations should not be backed up
1043 e600f124 2021-03-21 stsp (cd $testroot/repo && got rebase -l > $testroot/stdout)
1044 e600f124 2021-03-21 stsp echo -n > $testroot/stdout.expected
1045 e600f124 2021-03-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1047 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1048 e600f124 2021-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1050 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1053 f6cae3ed 2020-09-13 naddy test_rebase_out_of_date() {
1054 e51d7b55 2020-01-04 stsp local testroot=`test_init rebase_out_of_date`
1055 e51d7b55 2020-01-04 stsp local initial_commit=`git_show_head $testroot/repo`
1057 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1058 e51d7b55 2020-01-04 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1059 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1061 e51d7b55 2020-01-04 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1062 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git rm -q beta)
1063 e51d7b55 2020-01-04 stsp echo "new file on branch" > $testroot/repo/epsilon/new
1064 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git add epsilon/new)
1065 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
1067 e51d7b55 2020-01-04 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1068 e51d7b55 2020-01-04 stsp local orig_commit2=`git_show_head $testroot/repo`
1070 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
1071 e51d7b55 2020-01-04 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1072 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to zeta on master"
1073 e51d7b55 2020-01-04 stsp local master_commit1=`git_show_head $testroot/repo`
1075 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
1076 e51d7b55 2020-01-04 stsp echo "modified beta on master" > $testroot/repo/beta
1077 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to beta on master"
1078 e51d7b55 2020-01-04 stsp local master_commit2=`git_show_head $testroot/repo`
1080 e51d7b55 2020-01-04 stsp got checkout -c $master_commit1 $testroot/repo $testroot/wt \
1081 e51d7b55 2020-01-04 stsp > /dev/null
1083 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1084 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1088 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
1089 e51d7b55 2020-01-04 stsp 2> $testroot/stderr)
1091 e51d7b55 2020-01-04 stsp echo -n > $testroot/stdout.expected
1092 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1094 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1095 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
1096 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1100 e51d7b55 2020-01-04 stsp echo -n "got: work tree must be updated before it can be " \
1101 e51d7b55 2020-01-04 stsp > $testroot/stderr.expected
1102 e51d7b55 2020-01-04 stsp echo "used to rebase a branch" >> $testroot/stderr.expected
1103 e51d7b55 2020-01-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1105 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1106 e51d7b55 2020-01-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
1107 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1111 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1112 e51d7b55 2020-01-04 stsp echo "commit $master_commit2 (master)" > $testroot/stdout.expected
1113 e51d7b55 2020-01-04 stsp echo "commit $master_commit1" >> $testroot/stdout.expected
1114 e51d7b55 2020-01-04 stsp echo "commit $initial_commit" >> $testroot/stdout.expected
1115 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1117 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1118 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1120 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1123 f6cae3ed 2020-09-13 naddy test_rebase_trims_empty_dir() {
1124 1ae0a341 2020-02-14 stsp local testroot=`test_init rebase_trims_empty_dir`
1126 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1127 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1128 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1130 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git rm -q epsilon/zeta)
1131 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "removing zeta on newbranch"
1133 1ae0a341 2020-02-14 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1134 1ae0a341 2020-02-14 stsp local orig_commit2=`git_show_head $testroot/repo`
1136 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q master)
1137 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/repo/alpha
1138 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to alpha on master"
1139 1ae0a341 2020-02-14 stsp local master_commit=`git_show_head $testroot/repo`
1141 1ae0a341 2020-02-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1143 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1144 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1148 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1150 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q newbranch)
1151 1ae0a341 2020-02-14 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
1152 1ae0a341 2020-02-14 stsp local new_commit2=`git_show_head $testroot/repo`
1154 1ae0a341 2020-02-14 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1155 1ae0a341 2020-02-14 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1156 1ae0a341 2020-02-14 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1157 1ae0a341 2020-02-14 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1159 1ae0a341 2020-02-14 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1160 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1161 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1162 1ae0a341 2020-02-14 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1163 1ae0a341 2020-02-14 stsp echo "D epsilon/zeta" >> $testroot/stdout.expected
1164 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1165 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1166 1ae0a341 2020-02-14 stsp echo ": removing zeta on newbranch" \
1167 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1168 1ae0a341 2020-02-14 stsp echo "Switching work tree to refs/heads/newbranch" \
1169 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1171 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1173 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1174 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
1175 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1179 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/content.expected
1180 1ae0a341 2020-02-14 stsp cat $testroot/wt/gamma/delta > $testroot/content
1181 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1183 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1184 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1185 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1189 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/content.expected
1190 1ae0a341 2020-02-14 stsp cat $testroot/wt/alpha > $testroot/content
1191 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1193 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1194 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1195 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1199 1ae0a341 2020-02-14 stsp if [ -e $testroot/wt/epsilon ]; then
1200 1ae0a341 2020-02-14 stsp echo "parent of removed zeta still exists on disk" >&2
1201 1ae0a341 2020-02-14 stsp test_done "$testroot" "1"
1205 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got status > $testroot/stdout)
1207 1ae0a341 2020-02-14 stsp echo -n > $testroot/stdout.expected
1208 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1210 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1211 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1212 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1216 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1217 1ae0a341 2020-02-14 stsp echo "commit $new_commit2 (newbranch)" > $testroot/stdout.expected
1218 1ae0a341 2020-02-14 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1219 1ae0a341 2020-02-14 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1220 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1222 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1223 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1225 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1228 f6cae3ed 2020-09-13 naddy test_rebase_delete_missing_file() {
1229 ca6da77d 2020-03-22 stsp local testroot=`test_init rebase_delete_missing_file`
1231 ca6da77d 2020-03-22 stsp mkdir -p $testroot/repo/d/f/g
1232 ca6da77d 2020-03-22 stsp echo "new file" > $testroot/repo/d/f/g/new
1233 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git add d/f/g/new)
1234 ca6da77d 2020-03-22 stsp git_commit $testroot/repo -m "adding a subdir"
1235 ca6da77d 2020-03-22 stsp local commit0=`git_show_head $testroot/repo`
1237 a740a1b3 2020-03-22 stsp got br -r $testroot/repo -c master newbranch
1239 a740a1b3 2020-03-22 stsp got checkout -b newbranch $testroot/repo $testroot/wt > /dev/null
1241 a740a1b3 2020-03-22 stsp echo "modified delta on branch" > $testroot/wt/gamma/delta
1242 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1243 a740a1b3 2020-03-22 stsp -m "committing to delta on newbranch" > /dev/null)
1245 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1246 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1247 a740a1b3 2020-03-22 stsp -m "removing beta and d/f/g/new on newbranch" > /dev/null)
1249 a740a1b3 2020-03-22 stsp (cd $testroot/repo && git checkout -q newbranch)
1250 ca6da77d 2020-03-22 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1251 ca6da77d 2020-03-22 stsp local orig_commit2=`git_show_head $testroot/repo`
1253 1fa49072 2021-09-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1254 1fa49072 2021-09-28 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1256 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got update -b master > /dev/null)
1257 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1258 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1259 a740a1b3 2020-03-22 stsp -m "removing beta and d/f/g/new on master" > /dev/null)
1261 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git checkout -q master)
1262 ca6da77d 2020-03-22 stsp local master_commit=`git_show_head $testroot/repo`
1264 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got update -b master > /dev/null)
1265 1fa49072 2021-09-28 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
1266 1fa49072 2021-09-28 stsp 2> $testroot/stderr)
1268 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1269 1fa49072 2021-09-28 stsp echo "rebase succeeded unexpectedly" >&2
1270 1fa49072 2021-09-28 stsp test_done "$testroot" "1"
1274 1fa49072 2021-09-28 stsp local new_commit1=$(cd $testroot/wt && got info | \
1275 1fa49072 2021-09-28 stsp grep '^work tree base commit: ' | cut -d: -f2 | tr -d ' ')
1277 ca6da77d 2020-03-22 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1278 ca6da77d 2020-03-22 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1280 ca6da77d 2020-03-22 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1281 ca6da77d 2020-03-22 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1282 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1283 ca6da77d 2020-03-22 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1284 ca6da77d 2020-03-22 stsp echo "! beta" >> $testroot/stdout.expected
1285 ca6da77d 2020-03-22 stsp echo "! d/f/g/new" >> $testroot/stdout.expected
1286 35ca1db7 2021-09-28 stsp echo -n "Files which had incoming changes but could not be found " \
1287 35ca1db7 2021-09-28 stsp >> $testroot/stdout.expected
1288 35ca1db7 2021-09-28 stsp echo "in the work tree: 2" >> $testroot/stdout.expected
1289 1fa49072 2021-09-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1291 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1292 1fa49072 2021-09-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1293 1fa49072 2021-09-28 stsp test_done "$testroot" "$ret"
1297 1fa49072 2021-09-28 stsp echo -n "got: changes destined for some files were not yet merged " \
1298 1fa49072 2021-09-28 stsp > $testroot/stderr.expected
1299 1fa49072 2021-09-28 stsp echo -n "and should be merged manually if required before the " \
1300 1fa49072 2021-09-28 stsp >> $testroot/stderr.expected
1301 1fa49072 2021-09-28 stsp echo "rebase operation is continued" >> $testroot/stderr.expected
1302 1fa49072 2021-09-28 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1304 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1305 1fa49072 2021-09-28 stsp diff -u $testroot/stderr.expected $testroot/stderr
1306 1fa49072 2021-09-28 stsp test_done "$testroot" "$ret"
1310 1fa49072 2021-09-28 stsp # ignore the missing changes and continue
1311 1fa49072 2021-09-28 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
1313 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1314 1fa49072 2021-09-28 stsp echo "rebase failed unexpectedly" >&2
1315 1fa49072 2021-09-28 stsp test_done "$testroot" "1"
1318 ca6da77d 2020-03-22 stsp echo -n "$short_orig_commit2 -> no-op change" \
1319 1fa49072 2021-09-28 stsp > $testroot/stdout.expected
1320 a740a1b3 2020-03-22 stsp echo ": removing beta and d/f/g/new on newbranch" \
1321 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1322 ca6da77d 2020-03-22 stsp echo "Switching work tree to refs/heads/newbranch" \
1323 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1325 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1327 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1328 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1329 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1333 ca6da77d 2020-03-22 stsp echo "modified delta on branch" > $testroot/content.expected
1334 ca6da77d 2020-03-22 stsp cat $testroot/wt/gamma/delta > $testroot/content
1335 ca6da77d 2020-03-22 stsp cmp -s $testroot/content.expected $testroot/content
1337 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1338 ca6da77d 2020-03-22 stsp diff -u $testroot/content.expected $testroot/content
1339 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1343 ca6da77d 2020-03-22 stsp if [ -e $testroot/wt/beta ]; then
1344 ca6da77d 2020-03-22 stsp echo "removed file beta still exists on disk" >&2
1345 ca6da77d 2020-03-22 stsp test_done "$testroot" "1"
1349 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got status > $testroot/stdout)
1351 ca6da77d 2020-03-22 stsp echo -n > $testroot/stdout.expected
1352 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1354 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1355 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1356 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1360 1fa49072 2021-09-28 stsp (cd $testroot/repo && git checkout -q newbranch)
1361 1fa49072 2021-09-28 stsp local new_commit1=`git_show_head $testroot/repo`
1362 1fa49072 2021-09-28 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1364 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1365 ca6da77d 2020-03-22 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
1366 ca6da77d 2020-03-22 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1367 ca6da77d 2020-03-22 stsp echo "commit $commit0" >> $testroot/stdout.expected
1368 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1370 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1371 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1373 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1376 f6cae3ed 2020-09-13 naddy test_rebase_rm_add_rm_file() {
1377 70551d57 2020-04-24 stsp local testroot=`test_init rebase_rm_add_rm_file`
1379 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1380 70551d57 2020-04-24 stsp (cd $testroot/repo && git rm -q beta)
1381 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "removing beta from newbranch"
1382 70551d57 2020-04-24 stsp local orig_commit1=`git_show_head $testroot/repo`
1384 70551d57 2020-04-24 stsp echo 'restored beta' > $testroot/repo/beta
1385 70551d57 2020-04-24 stsp (cd $testroot/repo && git add beta)
1386 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "restoring beta on newbranch"
1387 70551d57 2020-04-24 stsp local orig_commit2=`git_show_head $testroot/repo`
1389 70551d57 2020-04-24 stsp (cd $testroot/repo && git rm -q beta)
1390 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "removing beta from newbranch again"
1391 70551d57 2020-04-24 stsp local orig_commit3=`git_show_head $testroot/repo`
1393 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q master)
1394 70551d57 2020-04-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1395 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
1396 70551d57 2020-04-24 stsp local master_commit=`git_show_head $testroot/repo`
1398 70551d57 2020-04-24 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1400 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1401 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1405 70551d57 2020-04-24 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1407 70551d57 2020-04-24 stsp # this would error out with 'got: file index is corrupt'
1408 70551d57 2020-04-24 stsp (cd $testroot/wt && got status > /dev/null)
1410 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1411 70551d57 2020-04-24 stsp echo "got status command failed unexpectedly" >&2
1412 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1416 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q newbranch)
1417 70551d57 2020-04-24 stsp local new_commit3=`git_show_head $testroot/repo`
1418 70551d57 2020-04-24 stsp local new_commit2=`git_show_parent_commit $testroot/repo`
1419 70551d57 2020-04-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo $new_commit2`
1421 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q newbranch)
1423 70551d57 2020-04-24 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1424 70551d57 2020-04-24 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1425 70551d57 2020-04-24 stsp local short_orig_commit3=`trim_obj_id 28 $orig_commit3`
1426 70551d57 2020-04-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1427 70551d57 2020-04-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1428 70551d57 2020-04-24 stsp local short_new_commit3=`trim_obj_id 28 $new_commit3`
1430 70551d57 2020-04-24 stsp echo "D beta" > $testroot/stdout.expected
1431 70551d57 2020-04-24 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1432 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1433 70551d57 2020-04-24 stsp echo ": removing beta from newbranch" >> $testroot/stdout.expected
1434 70551d57 2020-04-24 stsp echo "A beta" >> $testroot/stdout.expected
1435 70551d57 2020-04-24 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1436 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1437 70551d57 2020-04-24 stsp echo ": restoring beta on newbranch" >> $testroot/stdout.expected
1438 70551d57 2020-04-24 stsp echo "D beta" >> $testroot/stdout.expected
1439 70551d57 2020-04-24 stsp echo -n "$short_orig_commit3 -> $short_new_commit3" \
1440 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1441 70551d57 2020-04-24 stsp echo ": removing beta from newbranch again" >> $testroot/stdout.expected
1442 70551d57 2020-04-24 stsp echo "Switching work tree to refs/heads/newbranch" \
1443 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1445 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1447 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1448 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1449 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1453 70551d57 2020-04-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1455 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1456 70551d57 2020-04-24 stsp echo "got status command failed unexpectedly" >&2
1457 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1461 70551d57 2020-04-24 stsp echo -n > $testroot/stdout.expected
1462 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1464 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1465 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1466 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1470 70551d57 2020-04-24 stsp (cd $testroot/wt && got log -l4 | grep ^commit > $testroot/stdout)
1471 70551d57 2020-04-24 stsp echo "commit $new_commit3 (newbranch)" > $testroot/stdout.expected
1472 70551d57 2020-04-24 stsp echo "commit $new_commit2" >> $testroot/stdout.expected
1473 70551d57 2020-04-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1474 70551d57 2020-04-24 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1475 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1477 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1478 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1480 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1483 598eac43 2022-07-22 stsp test_rebase_resets_committer() {
1484 598eac43 2022-07-22 stsp local testroot=`test_init rebase_resets_committer`
1485 598eac43 2022-07-22 stsp local commit0=`git_show_head $testroot/repo`
1486 598eac43 2022-07-22 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1487 598eac43 2022-07-22 stsp local committer="Flan Luck <flan_luck@openbsd.org>"
1489 598eac43 2022-07-22 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1490 598eac43 2022-07-22 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1491 598eac43 2022-07-22 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1493 598eac43 2022-07-22 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1494 598eac43 2022-07-22 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
1496 598eac43 2022-07-22 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1497 598eac43 2022-07-22 stsp local orig_commit2=`git_show_head $testroot/repo`
1498 598eac43 2022-07-22 stsp local orig_author_time2=`git_show_author_time $testroot/repo`
1500 598eac43 2022-07-22 stsp (cd $testroot/repo && git checkout -q master)
1501 598eac43 2022-07-22 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1502 598eac43 2022-07-22 stsp git_commit $testroot/repo -m "committing to zeta on master"
1503 598eac43 2022-07-22 stsp local master_commit=`git_show_head $testroot/repo`
1505 598eac43 2022-07-22 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1507 598eac43 2022-07-22 stsp if [ $ret -ne 0 ]; then
1508 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
1512 598eac43 2022-07-22 stsp (cd $testroot/wt && env GOT_AUTHOR="$committer" \
1513 598eac43 2022-07-22 stsp got rebase newbranch > $testroot/stdout)
1515 598eac43 2022-07-22 stsp (cd $testroot/repo && git checkout -q newbranch)
1516 598eac43 2022-07-22 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
1517 598eac43 2022-07-22 stsp local new_commit2=`git_show_head $testroot/repo`
1518 598eac43 2022-07-22 stsp local new_author_time2=`git_show_author_time $testroot/repo`
1520 598eac43 2022-07-22 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1521 598eac43 2022-07-22 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1522 598eac43 2022-07-22 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1523 598eac43 2022-07-22 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1525 598eac43 2022-07-22 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1526 598eac43 2022-07-22 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1527 598eac43 2022-07-22 stsp >> $testroot/stdout.expected
1528 598eac43 2022-07-22 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1529 598eac43 2022-07-22 stsp echo "G alpha" >> $testroot/stdout.expected
1530 598eac43 2022-07-22 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1531 598eac43 2022-07-22 stsp >> $testroot/stdout.expected
1532 598eac43 2022-07-22 stsp echo ": committing more changes on newbranch" \
1533 598eac43 2022-07-22 stsp >> $testroot/stdout.expected
1534 598eac43 2022-07-22 stsp echo "Switching work tree to refs/heads/newbranch" \
1535 598eac43 2022-07-22 stsp >> $testroot/stdout.expected
1537 598eac43 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1539 598eac43 2022-07-22 stsp if [ $ret -ne 0 ]; then
1540 598eac43 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1541 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
1545 598eac43 2022-07-22 stsp # Original commit only had one author
1546 598eac43 2022-07-22 stsp (cd $testroot/repo && got log -l1 -c $orig_commit2 | \
1547 598eac43 2022-07-22 stsp egrep '^(from|via):' > $testroot/stdout)
1548 598eac43 2022-07-22 stsp echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
1549 598eac43 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1551 598eac43 2022-07-22 stsp if [ $ret -ne 0 ]; then
1552 598eac43 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1553 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
1557 598eac43 2022-07-22 stsp # Rebased commit should have new committer name added
1558 598eac43 2022-07-22 stsp (cd $testroot/repo && got log -l1 -c $new_commit2 | \
1559 598eac43 2022-07-22 stsp egrep '^(from|via):' > $testroot/stdout)
1560 598eac43 2022-07-22 stsp echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
1561 598eac43 2022-07-22 stsp echo "via: $committer" >> $testroot/stdout.expected
1563 50e7a649 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1565 50e7a649 2022-07-22 stsp if [ $ret -ne 0 ]; then
1566 50e7a649 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1568 50e7a649 2022-07-22 stsp test_done "$testroot" "$ret"
1571 50e7a649 2022-07-22 stsp test_rebase_no_author_info() {
1572 50e7a649 2022-07-22 stsp local testroot=`test_init rebase_no_author_info`
1573 50e7a649 2022-07-22 stsp local commit0=`git_show_head $testroot/repo`
1574 50e7a649 2022-07-22 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1575 50e7a649 2022-07-22 stsp local committer="$GOT_AUTHOR"
1577 50e7a649 2022-07-22 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1578 50e7a649 2022-07-22 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1579 50e7a649 2022-07-22 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1581 50e7a649 2022-07-22 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1582 50e7a649 2022-07-22 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
1584 50e7a649 2022-07-22 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1585 50e7a649 2022-07-22 stsp local orig_commit2=`git_show_head $testroot/repo`
1586 50e7a649 2022-07-22 stsp local orig_author_time2=`git_show_author_time $testroot/repo`
1588 50e7a649 2022-07-22 stsp (cd $testroot/repo && git checkout -q master)
1589 50e7a649 2022-07-22 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1590 50e7a649 2022-07-22 stsp git_commit $testroot/repo -m "committing to zeta on master"
1591 50e7a649 2022-07-22 stsp local master_commit=`git_show_head $testroot/repo`
1593 50e7a649 2022-07-22 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1595 50e7a649 2022-07-22 stsp if [ $ret -ne 0 ]; then
1596 50e7a649 2022-07-22 stsp test_done "$testroot" "$ret"
1600 1004841d 2022-07-24 op # unset in a subshell to avoid affecting our environment
1601 1004841d 2022-07-24 op (unset GOT_AUTHOR && cd $testroot/wt && \
1602 1004841d 2022-07-24 op got rebase newbranch > $testroot/stdout)
1604 50e7a649 2022-07-22 stsp (cd $testroot/repo && git checkout -q newbranch)
1605 50e7a649 2022-07-22 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
1606 50e7a649 2022-07-22 stsp local new_commit2=`git_show_head $testroot/repo`
1607 50e7a649 2022-07-22 stsp local new_author_time2=`git_show_author_time $testroot/repo`
1609 50e7a649 2022-07-22 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1610 50e7a649 2022-07-22 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1611 50e7a649 2022-07-22 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1612 50e7a649 2022-07-22 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1614 50e7a649 2022-07-22 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1615 50e7a649 2022-07-22 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1616 50e7a649 2022-07-22 stsp >> $testroot/stdout.expected
1617 50e7a649 2022-07-22 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1618 50e7a649 2022-07-22 stsp echo "G alpha" >> $testroot/stdout.expected
1619 50e7a649 2022-07-22 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1620 50e7a649 2022-07-22 stsp >> $testroot/stdout.expected
1621 50e7a649 2022-07-22 stsp echo ": committing more changes on newbranch" \
1622 50e7a649 2022-07-22 stsp >> $testroot/stdout.expected
1623 50e7a649 2022-07-22 stsp echo "Switching work tree to refs/heads/newbranch" \
1624 50e7a649 2022-07-22 stsp >> $testroot/stdout.expected
1626 598eac43 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1628 598eac43 2022-07-22 stsp if [ $ret -ne 0 ]; then
1629 598eac43 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1630 50e7a649 2022-07-22 stsp test_done "$testroot" "$ret"
1634 50e7a649 2022-07-22 stsp # Original commit only had one author
1635 50e7a649 2022-07-22 stsp (cd $testroot/repo && got log -l1 -c $orig_commit2 | \
1636 50e7a649 2022-07-22 stsp egrep '^(from|via):' > $testroot/stdout)
1637 50e7a649 2022-07-22 stsp echo "from: $committer" > $testroot/stdout.expected
1638 50e7a649 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1640 50e7a649 2022-07-22 stsp if [ $ret -ne 0 ]; then
1641 50e7a649 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1642 50e7a649 2022-07-22 stsp test_done "$testroot" "$ret"
1646 50e7a649 2022-07-22 stsp # Author info of rebased commit should match the original
1647 50e7a649 2022-07-22 stsp (cd $testroot/repo && got log -l1 -c $new_commit2 | \
1648 50e7a649 2022-07-22 stsp egrep '^(from|via):' > $testroot/stdout)
1649 50e7a649 2022-07-22 stsp echo "from: $committer" > $testroot/stdout.expected
1651 50e7a649 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1653 50e7a649 2022-07-22 stsp if [ $ret -ne 0 ]; then
1654 50e7a649 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1656 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
1659 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1660 dcf44d04 2019-07-11 stsp run_test test_rebase_basic
1661 dcf44d04 2019-07-11 stsp run_test test_rebase_ancestry_check
1662 dcf44d04 2019-07-11 stsp run_test test_rebase_continue
1663 dcf44d04 2019-07-11 stsp run_test test_rebase_abort
1664 ff0d2220 2019-07-11 stsp run_test test_rebase_no_op_change
1665 7d5807f4 2019-07-11 stsp run_test test_rebase_in_progress
1666 64c6d990 2019-07-11 stsp run_test test_rebase_path_prefix
1667 787c8eb6 2019-07-11 stsp run_test test_rebase_preserves_logmsg
1668 fc66b545 2019-08-12 stsp run_test test_rebase_no_commits_to_rebase
1669 38b0338b 2019-11-29 stsp run_test test_rebase_forward
1670 e51d7b55 2020-01-04 stsp run_test test_rebase_out_of_date
1671 1ae0a341 2020-02-14 stsp run_test test_rebase_trims_empty_dir
1672 ca6da77d 2020-03-22 stsp run_test test_rebase_delete_missing_file
1673 70551d57 2020-04-24 stsp run_test test_rebase_rm_add_rm_file
1674 598eac43 2022-07-22 stsp run_test test_rebase_resets_committer
1675 50e7a649 2022-07-22 stsp run_test test_rebase_no_author_info