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 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas 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 fc414659 2022-04-16 thomas 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 fa37079f 2021-10-09 thomas local prev_LC_TIME="$LC_TIME"
157 fa37079f 2021-10-09 thomas export LC_TIME=C
158 fa37079f 2021-10-09 thomas d_orig2=`date -u -d "@$orig_author_time2" +"%a %b %e %X %Y UTC"`
159 fa37079f 2021-10-09 thomas export LC_TIME="$prev_LC_TIME"
160 180f111d 2021-09-21 thomas.ad d_new2=`date -u -d "@$new_author_time2" +"%G-%m-%d"`
161 180f111d 2021-09-21 thomas.ad d_0=`date -u -d "@$commit0_author_time" +"%G-%m-%d"`
162 e600f124 2021-03-21 stsp cat > $testroot/stdout.expected <<EOF
163 e600f124 2021-03-21 stsp -----------------------------------------------
164 e600f124 2021-03-21 stsp commit $orig_commit2 (formerly newbranch)
165 e600f124 2021-03-21 stsp from: $GOT_AUTHOR
166 e600f124 2021-03-21 stsp date: $d_orig2
168 e600f124 2021-03-21 stsp committing more changes on newbranch
170 e600f124 2021-03-21 stsp has become commit $new_commit2 (newbranch)
171 e600f124 2021-03-21 stsp $d_new2 $GOT_AUTHOR_11 committing more changes on newbranch
172 e600f124 2021-03-21 stsp history forked at $commit0
173 e600f124 2021-03-21 stsp $d_0 $GOT_AUTHOR_11 adding the test tree
175 e600f124 2021-03-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
177 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
178 e600f124 2021-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
179 9e822917 2021-03-23 stsp test_done "$testroot" "$ret"
183 9e822917 2021-03-23 stsp # Asking for backups of a branch which has none should yield an error
184 9e822917 2021-03-23 stsp (cd $testroot/repo && got rebase -l master \
185 9e822917 2021-03-23 stsp > $testroot/stdout 2> $testroot/stderr)
186 9e822917 2021-03-23 stsp echo -n > $testroot/stdout.expected
187 9e822917 2021-03-23 stsp echo "got: refs/got/backup/rebase/master/: no such reference found" \
188 9e822917 2021-03-23 stsp > $testroot/stderr.expected
189 9e822917 2021-03-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
191 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
192 9e822917 2021-03-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
193 9e822917 2021-03-23 stsp test_done "$testroot" "$ret"
196 9e822917 2021-03-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
198 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
199 9e822917 2021-03-23 stsp diff -u $testroot/stderr.expected $testroot/stderr
200 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
204 643b85bc 2021-07-16 stsp # Delete all backup refs
205 643b85bc 2021-07-16 stsp (cd $testroot/repo && got rebase -X \
206 643b85bc 2021-07-16 stsp > $testroot/stdout 2> $testroot/stderr)
207 643b85bc 2021-07-16 stsp echo -n "Deleted refs/got/backup/rebase/newbranch/$new_commit2: " \
208 643b85bc 2021-07-16 stsp > $testroot/stdout.expected
209 643b85bc 2021-07-16 stsp echo "$orig_commit2" >> $testroot/stdout.expected
210 643b85bc 2021-07-16 stsp echo -n > $testroot/stderr.expected
211 643b85bc 2021-07-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
213 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
214 643b85bc 2021-07-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
215 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
218 643b85bc 2021-07-16 stsp cmp -s $testroot/stderr.expected $testroot/stderr
220 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
221 643b85bc 2021-07-16 stsp diff -u $testroot/stderr.expected $testroot/stderr
222 643b85bc 2021-07-16 stsp test_done "$testroot" "$ret"
226 643b85bc 2021-07-16 stsp (cd $testroot/repo && got rebase -l > $testroot/stdout)
227 643b85bc 2021-07-16 stsp echo -n > $testroot/stdout.expected
228 643b85bc 2021-07-16 stsp cmp -s $testroot/stdout.expected $testroot/stdout
230 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
231 643b85bc 2021-07-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
233 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
236 f6cae3ed 2020-09-13 naddy test_rebase_ancestry_check() {
237 818c7501 2019-07-11 stsp local testroot=`test_init rebase_ancestry_check`
239 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
241 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
242 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
246 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
247 818c7501 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
248 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
249 82d979c5 2021-11-04 thomas local newbranch_id=`git_show_head $testroot/repo`
251 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
252 818c7501 2019-07-11 stsp 2> $testroot/stderr)
254 82d979c5 2021-11-04 thomas echo "refs/heads/newbranch is already based on refs/heads/master" \
255 82d979c5 2021-11-04 thomas > $testroot/stdout.expected
256 82d979c5 2021-11-04 thomas echo "Switching work tree from refs/heads/master to refs/heads/newbranch" \
257 82d979c5 2021-11-04 thomas >> $testroot/stdout.expected
258 82d979c5 2021-11-04 thomas echo "U gamma/delta" >> $testroot/stdout.expected
259 82d979c5 2021-11-04 thomas echo "Updated to refs/heads/newbranch: ${newbranch_id}" \
260 82d979c5 2021-11-04 thomas >> $testroot/stdout.expected
261 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
263 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
264 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
265 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
269 82d979c5 2021-11-04 thomas echo -n > $testroot/stderr.expected
270 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
272 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
273 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
275 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
278 f6cae3ed 2020-09-13 naddy test_rebase_continue() {
279 818c7501 2019-07-11 stsp local testroot=`test_init rebase_continue`
280 f69721c3 2019-10-21 stsp local init_commit=`git_show_head $testroot/repo`
282 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
283 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
284 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
285 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
286 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
288 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
289 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
290 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
291 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
293 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
295 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
296 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
300 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
301 818c7501 2019-07-11 stsp 2> $testroot/stderr)
303 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
304 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
305 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
306 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
307 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
308 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
310 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
311 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
312 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
316 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
317 818c7501 2019-07-11 stsp > $testroot/stderr.expected
318 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
320 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
321 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
322 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
326 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
327 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
328 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
329 f69721c3 2019-10-21 stsp >> $testroot/content.expected
330 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
331 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
332 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
333 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
334 54d5be07 2021-06-03 stsp >> $testroot/content.expected
335 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
336 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
338 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
339 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
340 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
344 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
346 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
347 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
349 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
350 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
351 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
355 818c7501 2019-07-11 stsp # resolve the conflict
356 818c7501 2019-07-11 stsp echo "modified alpha on branch and master" > $testroot/wt/alpha
358 f032f1f7 2019-08-04 stsp # test interaction of 'got stage' and rebase -c
359 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got stage alpha > /dev/null)
360 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout \
361 f032f1f7 2019-08-04 stsp 2> $testroot/stderr)
363 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
364 f032f1f7 2019-08-04 stsp echo "rebase succeeded unexpectedly" >&2
365 f032f1f7 2019-08-04 stsp test_done "$testroot" "1"
368 f032f1f7 2019-08-04 stsp echo -n "got: work tree contains files with staged changes; " \
369 f032f1f7 2019-08-04 stsp > $testroot/stderr.expected
370 f032f1f7 2019-08-04 stsp echo "these changes must be committed or unstaged first" \
371 f032f1f7 2019-08-04 stsp >> $testroot/stderr.expected
372 f032f1f7 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
374 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
375 f032f1f7 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
376 f032f1f7 2019-08-04 stsp test_done "$testroot" "$ret"
380 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got unstage alpha > /dev/null)
381 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
383 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
384 818c7501 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
385 818c7501 2019-07-11 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
387 818c7501 2019-07-11 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
388 818c7501 2019-07-11 stsp > $testroot/stdout.expected
389 818c7501 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
390 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
391 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
393 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
395 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
396 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
397 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
402 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
403 818c7501 2019-07-11 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
404 818c7501 2019-07-11 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
405 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
407 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
408 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
410 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
413 f6cae3ed 2020-09-13 naddy test_rebase_abort() {
414 818c7501 2019-07-11 stsp local testroot=`test_init rebase_abort`
416 818c7501 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
418 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
419 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
420 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
421 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
422 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
424 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
425 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
426 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
427 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
429 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
431 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
432 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
436 d52bac28 2021-10-08 thomas # unrelated unversioned file in work tree
437 d52bac28 2021-10-08 thomas touch $testroot/wt/unversioned-file
439 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
440 818c7501 2019-07-11 stsp 2> $testroot/stderr)
442 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
443 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
444 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
445 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
446 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
447 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
449 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
450 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
451 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
455 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
456 818c7501 2019-07-11 stsp > $testroot/stderr.expected
457 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
459 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
460 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
461 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
465 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
466 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
467 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
468 f69721c3 2019-10-21 stsp >> $testroot/content.expected
469 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
470 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
471 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
472 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
473 54d5be07 2021-06-03 stsp >> $testroot/content.expected
474 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
475 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
477 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
478 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
479 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
483 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
485 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
486 d52bac28 2021-10-08 thomas echo "? unversioned-file" >> $testroot/stdout.expected
487 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
489 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
490 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
491 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
495 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -a > $testroot/stdout)
497 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
499 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/master" \
500 818c7501 2019-07-11 stsp > $testroot/stdout.expected
501 818c7501 2019-07-11 stsp echo 'R alpha' >> $testroot/stdout.expected
502 818c7501 2019-07-11 stsp echo "Rebase of refs/heads/newbranch aborted" \
503 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
505 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
507 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
508 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
509 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
513 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/content.expected
514 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
515 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
517 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
518 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
519 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
523 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l3 -c newbranch \
524 818c7501 2019-07-11 stsp | grep ^commit > $testroot/stdout)
525 818c7501 2019-07-11 stsp echo "commit $orig_commit1 (newbranch)" > $testroot/stdout.expected
526 818c7501 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
527 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
529 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
530 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
532 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
535 f6cae3ed 2020-09-13 naddy test_rebase_no_op_change() {
536 ff0d2220 2019-07-11 stsp local testroot=`test_init rebase_no_op_change`
537 ff0d2220 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
539 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
540 ff0d2220 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
541 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
542 ff0d2220 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
543 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
545 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
546 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
547 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
548 ff0d2220 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
550 ff0d2220 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
552 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
553 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
557 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
558 ff0d2220 2019-07-11 stsp 2> $testroot/stderr)
560 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
561 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
562 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
563 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
564 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
565 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
567 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
568 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
569 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
573 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
574 ff0d2220 2019-07-11 stsp > $testroot/stderr.expected
575 ff0d2220 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
577 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
578 ff0d2220 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
579 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
583 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
584 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
585 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
586 f69721c3 2019-10-21 stsp >> $testroot/content.expected
587 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
588 ff0d2220 2019-07-11 stsp echo "=======" >> $testroot/content.expected
589 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
590 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
591 54d5be07 2021-06-03 stsp >> $testroot/content.expected
592 ff0d2220 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
593 ff0d2220 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
595 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
596 ff0d2220 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
597 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
601 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
603 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
604 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
606 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
607 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
608 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
612 ff0d2220 2019-07-11 stsp # resolve the conflict
613 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/wt/alpha
615 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
617 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
618 ff0d2220 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
620 ff0d2220 2019-07-11 stsp echo -n "$short_orig_commit1 -> no-op change" \
621 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
622 ff0d2220 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
623 ff0d2220 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
624 ff0d2220 2019-07-11 stsp >> $testroot/stdout.expected
626 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
628 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
629 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
630 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
635 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
636 ff0d2220 2019-07-11 stsp echo "commit $master_commit (master, newbranch)" \
637 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
638 ff0d2220 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
639 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
641 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
642 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
644 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
647 f6cae3ed 2020-09-13 naddy test_rebase_in_progress() {
648 4ba9c4f6 2019-07-11 stsp local testroot=`test_init rebase_in_progress`
649 7d5807f4 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
651 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
652 7d5807f4 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
653 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
654 7d5807f4 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
655 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
657 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
658 7d5807f4 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
659 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
660 7d5807f4 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
662 7d5807f4 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
664 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
665 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
669 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
670 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
672 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
673 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
674 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
675 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
676 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
677 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
679 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
680 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
681 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
685 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
686 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
687 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
689 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
690 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
691 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
695 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
696 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
697 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
698 f69721c3 2019-10-21 stsp >> $testroot/content.expected
699 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
700 7d5807f4 2019-07-11 stsp echo "=======" >> $testroot/content.expected
701 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
702 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
703 54d5be07 2021-06-03 stsp >> $testroot/content.expected
704 7d5807f4 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
705 7d5807f4 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
707 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
708 7d5807f4 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
709 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
713 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
715 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
716 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
718 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
719 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
720 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
724 7d5807f4 2019-07-11 stsp for cmd in update commit; do
725 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got $cmd > $testroot/stdout \
726 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
728 7d5807f4 2019-07-11 stsp echo -n > $testroot/stdout.expected
729 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
731 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
732 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
733 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
737 7d5807f4 2019-07-11 stsp echo -n "got: a rebase operation is in progress in this " \
738 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
739 7d5807f4 2019-07-11 stsp echo "work tree and must be continued or aborted first" \
740 7d5807f4 2019-07-11 stsp >> $testroot/stderr.expected
741 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
743 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
744 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
745 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
750 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
753 f6cae3ed 2020-09-13 naddy test_rebase_path_prefix() {
754 64c6d990 2019-07-11 stsp local testroot=`test_init rebase_path_prefix`
756 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
757 64c6d990 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
758 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
760 64c6d990 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
761 64c6d990 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
763 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
764 64c6d990 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
765 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
766 64c6d990 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
768 64c6d990 2019-07-11 stsp got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
770 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
771 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
775 64c6d990 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch \
776 64c6d990 2019-07-11 stsp > $testroot/stdout 2> $testroot/stderr)
778 64c6d990 2019-07-11 stsp echo -n > $testroot/stdout.expected
779 64c6d990 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
781 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
782 64c6d990 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
783 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
787 64c6d990 2019-07-11 stsp echo -n "got: cannot rebase branch which contains changes outside " \
788 64c6d990 2019-07-11 stsp > $testroot/stderr.expected
789 64c6d990 2019-07-11 stsp echo "of this work tree's path prefix" >> $testroot/stderr.expected
790 787c8eb6 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
792 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
793 787c8eb6 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
794 f4a34a66 2022-04-16 thomas test_done "$testroot" "$ret"
798 f4a34a66 2022-04-16 thomas # rebase should succeed when using a complete work tree
799 f4a34a66 2022-04-16 thomas got checkout $testroot/repo $testroot/wt2 > /dev/null
801 f4a34a66 2022-04-16 thomas if [ $ret -ne 0 ]; then
802 f4a34a66 2022-04-16 thomas test_done "$testroot" "$ret"
806 f4a34a66 2022-04-16 thomas (cd $testroot/wt2 && got rebase newbranch \
807 f4a34a66 2022-04-16 thomas > $testroot/stdout 2> $testroot/stderr)
809 f4a34a66 2022-04-16 thomas (cd $testroot/repo && git checkout -q newbranch)
810 f4a34a66 2022-04-16 thomas local new_commit1=`git_show_parent_commit $testroot/repo`
811 f4a34a66 2022-04-16 thomas local new_commit2=`git_show_head $testroot/repo`
813 f4a34a66 2022-04-16 thomas local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
814 f4a34a66 2022-04-16 thomas local short_new_commit2=`trim_obj_id 28 $new_commit2`
816 f4a34a66 2022-04-16 thomas echo "G gamma/delta" > $testroot/stdout.expected
817 f4a34a66 2022-04-16 thomas echo -n "$short_orig_commit2 -> $short_new_commit2" \
818 f4a34a66 2022-04-16 thomas >> $testroot/stdout.expected
819 f4a34a66 2022-04-16 thomas echo ": committing to delta on newbranch" \
820 f4a34a66 2022-04-16 thomas >> $testroot/stdout.expected
821 f4a34a66 2022-04-16 thomas echo "Switching work tree to refs/heads/newbranch" \
822 f4a34a66 2022-04-16 thomas >> $testroot/stdout.expected
824 f4a34a66 2022-04-16 thomas cmp -s $testroot/stdout.expected $testroot/stdout
826 f4a34a66 2022-04-16 thomas if [ $ret -ne 0 ]; then
827 f4a34a66 2022-04-16 thomas diff -u $testroot/stdout.expected $testroot/stdout
828 f4a34a66 2022-04-16 thomas test_done "$testroot" "$ret"
832 f4a34a66 2022-04-16 thomas # the first work tree should remain usable
833 f4a34a66 2022-04-16 thomas (cd $testroot/wt && got update -b master \
834 f4a34a66 2022-04-16 thomas > $testroot/stdout 2> $testroot/stderr)
836 f4a34a66 2022-04-16 thomas if [ $ret -ne 0 ]; then
837 f4a34a66 2022-04-16 thomas echo "update failed unexpectedly" >&2
838 f4a34a66 2022-04-16 thomas test_done "$testroot" "1"
842 f4a34a66 2022-04-16 thomas echo 'Already up-to-date' > $testroot/stdout.expected
843 f4a34a66 2022-04-16 thomas cmp -s $testroot/stdout.expected $testroot/stdout
845 f4a34a66 2022-04-16 thomas if [ $ret -ne 0 ]; then
846 f4a34a66 2022-04-16 thomas diff -u $testroot/stdout.expected $testroot/stdout
848 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
851 f6cae3ed 2020-09-13 naddy test_rebase_preserves_logmsg() {
852 787c8eb6 2019-07-11 stsp local testroot=`test_init rebase_preserves_logmsg`
854 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
855 787c8eb6 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
856 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified delta on newbranch"
858 787c8eb6 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
859 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified alpha on newbranch"
861 787c8eb6 2019-07-11 stsp (cd $testroot/repo && got log -c newbranch -l2 | grep -v ^date: \
862 787c8eb6 2019-07-11 stsp > $testroot/log.expected)
864 787c8eb6 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
865 787c8eb6 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
867 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
868 787c8eb6 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
869 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
870 787c8eb6 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
872 787c8eb6 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
874 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
875 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
879 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > /dev/null \
880 787c8eb6 2019-07-11 stsp 2> $testroot/stderr)
882 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
883 787c8eb6 2019-07-11 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
884 787c8eb6 2019-07-11 stsp local new_commit2=`git_show_head $testroot/repo`
886 787c8eb6 2019-07-11 stsp echo -n > $testroot/stderr.expected
887 64c6d990 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
889 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
890 64c6d990 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
891 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
895 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got log -c newbranch -l2 | grep -v ^date: \
896 787c8eb6 2019-07-11 stsp > $testroot/log)
897 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit1/$new_commit1/" $testroot/log.expected
898 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit2/$new_commit2/" $testroot/log.expected
899 787c8eb6 2019-07-11 stsp cmp -s $testroot/log.expected $testroot/log
901 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
902 787c8eb6 2019-07-11 stsp diff -u $testroot/log.expected $testroot/log
905 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
908 f6cae3ed 2020-09-13 naddy test_rebase_no_commits_to_rebase() {
909 fc66b545 2019-08-12 stsp local testroot=`test_init rebase_no_commits_to_rebase`
911 fc66b545 2019-08-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
913 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
914 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
918 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n newbranch)
920 fc66b545 2019-08-12 stsp echo "modified alpha on master" > $testroot/wt/alpha
921 fc66b545 2019-08-12 stsp (cd $testroot/wt && got commit -m 'test rebase_no_commits_to_rebase' \
922 fc66b545 2019-08-12 stsp > /dev/null)
923 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > /dev/null)
925 fc66b545 2019-08-12 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
926 fc66b545 2019-08-12 stsp 2> $testroot/stderr)
928 fc66b545 2019-08-12 stsp echo "got: no commits to rebase" > $testroot/stderr.expected
929 fc66b545 2019-08-12 stsp cmp -s $testroot/stderr.expected $testroot/stderr
931 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
932 fc66b545 2019-08-12 stsp diff -u $testroot/stderr.expected $testroot/stderr
933 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
937 f4a34a66 2022-04-16 thomas echo -n > $testroot/stdout.expected
938 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
940 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
941 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
942 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
946 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
947 fc66b545 2019-08-12 stsp echo "Already up-to-date" > $testroot/stdout.expected
948 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
950 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
951 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
953 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
956 f6cae3ed 2020-09-13 naddy test_rebase_forward() {
957 38b0338b 2019-11-29 stsp local testroot=`test_init rebase_forward`
958 38b0338b 2019-11-29 stsp local commit0=`git_show_head $testroot/repo`
960 38b0338b 2019-11-29 stsp got checkout $testroot/repo $testroot/wt > /dev/null
962 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
963 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
967 38b0338b 2019-11-29 stsp echo "change alpha 1" > $testroot/wt/alpha
968 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
969 38b0338b 2019-11-29 stsp > /dev/null)
970 38b0338b 2019-11-29 stsp local commit1=`git_show_head $testroot/repo`
972 38b0338b 2019-11-29 stsp echo "change alpha 2" > $testroot/wt/alpha
973 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
974 38b0338b 2019-11-29 stsp > /dev/null)
975 38b0338b 2019-11-29 stsp local commit2=`git_show_head $testroot/repo`
977 b6b86fd1 2022-08-30 thomas # Simulate a situation where fast-forward is required.
978 38b0338b 2019-11-29 stsp # We want to fast-forward master to origin/master:
979 38b0338b 2019-11-29 stsp # commit 3907e11dceaae2ca7f8db79c2af31794673945ad (origin/master)
980 38b0338b 2019-11-29 stsp # commit ffcffcd102cf1af6572fbdbb4cf07a0f1fd2d840 (master)
981 38b0338b 2019-11-29 stsp # commit 87a6a8a2263a15b61c016ff1720b24741d455eb5
982 993f033b 2021-07-16 stsp (cd $testroot/repo && got ref -d master >/dev/null)
983 e31abbf2 2020-03-22 stsp (cd $testroot/repo && got ref -c $commit1 refs/heads/master)
984 e31abbf2 2020-03-22 stsp (cd $testroot/repo && got ref -c $commit2 refs/remotes/origin/master)
986 38b0338b 2019-11-29 stsp (cd $testroot/wt && got up -b origin/master > /dev/null)
988 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase master \
989 1996dd72 2022-09-21 thomas > $testroot/stdout 2> $testroot/stderr)
991 1996dd72 2022-09-21 thomas echo "Forwarding refs/heads/master to commit $commit2" \
992 1996dd72 2022-09-21 thomas > $testroot/stdout.expected
993 1996dd72 2022-09-21 thomas echo "Switching work tree to refs/heads/master" \
994 1996dd72 2022-09-21 thomas >> $testroot/stdout.expected
995 1996dd72 2022-09-21 thomas cmp -s $testroot/stdout.expected $testroot/stdout
997 1996dd72 2022-09-21 thomas if [ $ret -ne 0 ]; then
998 1996dd72 2022-09-21 thomas diff -u $testroot/stdout.expected $testroot/stdout
999 1996dd72 2022-09-21 thomas test_done "$testroot" "$ret"
1000 1996dd72 2022-09-21 thomas return 1
1003 1996dd72 2022-09-21 thomas # Ensure that rebase operation was completed correctly
1004 1996dd72 2022-09-21 thomas (cd $testroot/wt && got rebase -a \
1005 1996dd72 2022-09-21 thomas > $testroot/stdout 2> $testroot/stderr)
1006 1996dd72 2022-09-21 thomas echo -n "" > $testroot/stdout.expected
1007 1996dd72 2022-09-21 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1009 1996dd72 2022-09-21 thomas if [ $ret -ne 0 ]; then
1010 1996dd72 2022-09-21 thomas diff -u $testroot/stdout.expected $testroot/stdout
1011 1996dd72 2022-09-21 thomas test_done "$testroot" "$ret"
1012 1996dd72 2022-09-21 thomas return 1
1014 1996dd72 2022-09-21 thomas echo "got: rebase operation not in progress" > $testroot/stderr.expected
1015 1996dd72 2022-09-21 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1017 1996dd72 2022-09-21 thomas if [ $ret -ne 0 ]; then
1018 1996dd72 2022-09-21 thomas diff -u $testroot/stderr.expected $testroot/stderr
1019 1996dd72 2022-09-21 thomas test_done "$testroot" "$ret"
1020 1996dd72 2022-09-21 thomas return 1
1023 1996dd72 2022-09-21 thomas (cd $testroot/wt && got branch -n > $testroot/stdout)
1024 1996dd72 2022-09-21 thomas echo "master" > $testroot/stdout.expected
1025 1996dd72 2022-09-21 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1027 1996dd72 2022-09-21 thomas if [ $ret -ne 0 ]; then
1028 1996dd72 2022-09-21 thomas diff -u $testroot/stdout.expected $testroot/stdout
1029 1996dd72 2022-09-21 thomas test_done "$testroot" "$ret"
1030 1996dd72 2022-09-21 thomas return 1
1033 1996dd72 2022-09-21 thomas (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1034 1996dd72 2022-09-21 thomas echo "commit $commit2 (master, origin/master)" > $testroot/stdout.expected
1035 1996dd72 2022-09-21 thomas echo "commit $commit1" >> $testroot/stdout.expected
1036 1996dd72 2022-09-21 thomas echo "commit $commit0" >> $testroot/stdout.expected
1037 1996dd72 2022-09-21 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1039 1996dd72 2022-09-21 thomas if [ $ret -ne 0 ]; then
1040 1996dd72 2022-09-21 thomas diff -u $testroot/stdout.expected $testroot/stdout
1041 1996dd72 2022-09-21 thomas test_done "$testroot" "$ret"
1042 1996dd72 2022-09-21 thomas return 1
1045 1996dd72 2022-09-21 thomas # Forward-only rebase operations should not be backed up
1046 1996dd72 2022-09-21 thomas (cd $testroot/repo && got rebase -l > $testroot/stdout)
1047 1996dd72 2022-09-21 thomas echo -n > $testroot/stdout.expected
1048 1996dd72 2022-09-21 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1050 1996dd72 2022-09-21 thomas if [ $ret -ne 0 ]; then
1051 1996dd72 2022-09-21 thomas diff -u $testroot/stdout.expected $testroot/stdout
1053 1996dd72 2022-09-21 thomas test_done "$testroot" "$ret"
1056 1996dd72 2022-09-21 thomas test_rebase_forward_path_prefix() {
1057 1996dd72 2022-09-21 thomas local testroot=`test_init rebase_forward_path_prefix`
1058 1996dd72 2022-09-21 thomas local commit0=`git_show_head $testroot/repo`
1060 1996dd72 2022-09-21 thomas got checkout $testroot/repo $testroot/wt-full > /dev/null
1062 1996dd72 2022-09-21 thomas if [ $ret -ne 0 ]; then
1063 1996dd72 2022-09-21 thomas test_done "$testroot" "$ret"
1064 1996dd72 2022-09-21 thomas return 1
1067 1996dd72 2022-09-21 thomas echo "change alpha 1" > $testroot/wt-full/alpha
1068 1996dd72 2022-09-21 thomas (cd $testroot/wt-full && got commit -m 'test rebase_forward' \
1069 1996dd72 2022-09-21 thomas > /dev/null)
1070 1996dd72 2022-09-21 thomas local commit1=`git_show_head $testroot/repo`
1072 1996dd72 2022-09-21 thomas echo "change alpha 2" > $testroot/wt-full/alpha
1073 1996dd72 2022-09-21 thomas (cd $testroot/wt-full && got commit -m 'test rebase_forward' \
1074 1996dd72 2022-09-21 thomas > /dev/null)
1075 1996dd72 2022-09-21 thomas local commit2=`git_show_head $testroot/repo`
1077 1996dd72 2022-09-21 thomas # Simulate a situation where fast-forward is required.
1078 1996dd72 2022-09-21 thomas # We want to fast-forward master to origin/master:
1079 1996dd72 2022-09-21 thomas # commit 3907e11dceaae2ca7f8db79c2af31794673945ad (origin/master)
1080 1996dd72 2022-09-21 thomas # commit ffcffcd102cf1af6572fbdbb4cf07a0f1fd2d840 (master)
1081 1996dd72 2022-09-21 thomas # commit 87a6a8a2263a15b61c016ff1720b24741d455eb5
1082 1996dd72 2022-09-21 thomas (cd $testroot/repo && got ref -d master >/dev/null)
1083 1996dd72 2022-09-21 thomas (cd $testroot/repo && got ref -c $commit1 refs/heads/master)
1084 1996dd72 2022-09-21 thomas (cd $testroot/repo && got ref -c $commit2 refs/remotes/origin/master)
1086 1996dd72 2022-09-21 thomas # Work tree which uses a path-prefix and will be used for rebasing
1087 1996dd72 2022-09-21 thomas got checkout -p epsilon -b origin/master $testroot/repo $testroot/wt \
1088 1996dd72 2022-09-21 thomas > /dev/null
1090 1996dd72 2022-09-21 thomas if [ $ret -ne 0 ]; then
1091 1996dd72 2022-09-21 thomas test_done "$testroot" "$ret"
1092 1996dd72 2022-09-21 thomas return 1
1095 4f29e1f1 2022-10-24 thomas (cd $testroot/wt && got rebase master \
1096 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
1098 38b0338b 2019-11-29 stsp echo "Forwarding refs/heads/master to commit $commit2" \
1099 38b0338b 2019-11-29 stsp > $testroot/stdout.expected
1100 38b0338b 2019-11-29 stsp echo "Switching work tree to refs/heads/master" \
1101 38b0338b 2019-11-29 stsp >> $testroot/stdout.expected
1102 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1104 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1105 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
1106 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1110 38b0338b 2019-11-29 stsp # Ensure that rebase operation was completed correctly
1111 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase -a \
1112 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
1113 38b0338b 2019-11-29 stsp echo -n "" > $testroot/stdout.expected
1114 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1116 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1117 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
1118 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1121 38b0338b 2019-11-29 stsp echo "got: rebase operation not in progress" > $testroot/stderr.expected
1122 38b0338b 2019-11-29 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1124 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1125 38b0338b 2019-11-29 stsp diff -u $testroot/stderr.expected $testroot/stderr
1126 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1130 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n > $testroot/stdout)
1131 38b0338b 2019-11-29 stsp echo "master" > $testroot/stdout.expected
1132 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1134 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1135 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
1136 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1140 38b0338b 2019-11-29 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1141 38b0338b 2019-11-29 stsp echo "commit $commit2 (master, origin/master)" > $testroot/stdout.expected
1142 38b0338b 2019-11-29 stsp echo "commit $commit1" >> $testroot/stdout.expected
1143 38b0338b 2019-11-29 stsp echo "commit $commit0" >> $testroot/stdout.expected
1144 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1146 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1147 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
1148 e600f124 2021-03-21 stsp test_done "$testroot" "$ret"
1152 e600f124 2021-03-21 stsp # Forward-only rebase operations should not be backed up
1153 e600f124 2021-03-21 stsp (cd $testroot/repo && got rebase -l > $testroot/stdout)
1154 e600f124 2021-03-21 stsp echo -n > $testroot/stdout.expected
1155 e600f124 2021-03-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1157 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1158 e600f124 2021-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1160 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1163 f6cae3ed 2020-09-13 naddy test_rebase_out_of_date() {
1164 e51d7b55 2020-01-04 stsp local testroot=`test_init rebase_out_of_date`
1165 e51d7b55 2020-01-04 stsp local initial_commit=`git_show_head $testroot/repo`
1167 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1168 e51d7b55 2020-01-04 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1169 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1171 e51d7b55 2020-01-04 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1172 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git rm -q beta)
1173 e51d7b55 2020-01-04 stsp echo "new file on branch" > $testroot/repo/epsilon/new
1174 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git add epsilon/new)
1175 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
1177 e51d7b55 2020-01-04 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1178 e51d7b55 2020-01-04 stsp local orig_commit2=`git_show_head $testroot/repo`
1180 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
1181 e51d7b55 2020-01-04 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1182 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to zeta on master"
1183 e51d7b55 2020-01-04 stsp local master_commit1=`git_show_head $testroot/repo`
1185 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
1186 e51d7b55 2020-01-04 stsp echo "modified beta on master" > $testroot/repo/beta
1187 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to beta on master"
1188 e51d7b55 2020-01-04 stsp local master_commit2=`git_show_head $testroot/repo`
1190 e51d7b55 2020-01-04 stsp got checkout -c $master_commit1 $testroot/repo $testroot/wt \
1191 e51d7b55 2020-01-04 stsp > /dev/null
1193 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1194 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1198 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
1199 e51d7b55 2020-01-04 stsp 2> $testroot/stderr)
1201 e51d7b55 2020-01-04 stsp echo -n > $testroot/stdout.expected
1202 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1204 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1205 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
1206 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1210 e51d7b55 2020-01-04 stsp echo -n "got: work tree must be updated before it can be " \
1211 e51d7b55 2020-01-04 stsp > $testroot/stderr.expected
1212 e51d7b55 2020-01-04 stsp echo "used to rebase a branch" >> $testroot/stderr.expected
1213 e51d7b55 2020-01-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1215 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1216 e51d7b55 2020-01-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
1217 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1221 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1222 e51d7b55 2020-01-04 stsp echo "commit $master_commit2 (master)" > $testroot/stdout.expected
1223 e51d7b55 2020-01-04 stsp echo "commit $master_commit1" >> $testroot/stdout.expected
1224 e51d7b55 2020-01-04 stsp echo "commit $initial_commit" >> $testroot/stdout.expected
1225 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1227 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1228 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1230 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1233 f6cae3ed 2020-09-13 naddy test_rebase_trims_empty_dir() {
1234 1ae0a341 2020-02-14 stsp local testroot=`test_init rebase_trims_empty_dir`
1236 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1237 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1238 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1240 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git rm -q epsilon/zeta)
1241 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "removing zeta on newbranch"
1243 1ae0a341 2020-02-14 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1244 1ae0a341 2020-02-14 stsp local orig_commit2=`git_show_head $testroot/repo`
1246 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q master)
1247 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/repo/alpha
1248 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to alpha on master"
1249 1ae0a341 2020-02-14 stsp local master_commit=`git_show_head $testroot/repo`
1251 1ae0a341 2020-02-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1253 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1254 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1258 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1260 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q newbranch)
1261 1ae0a341 2020-02-14 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
1262 1ae0a341 2020-02-14 stsp local new_commit2=`git_show_head $testroot/repo`
1264 1ae0a341 2020-02-14 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1265 1ae0a341 2020-02-14 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1266 1ae0a341 2020-02-14 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1267 1ae0a341 2020-02-14 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1269 1ae0a341 2020-02-14 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1270 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1271 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1272 1ae0a341 2020-02-14 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1273 1ae0a341 2020-02-14 stsp echo "D epsilon/zeta" >> $testroot/stdout.expected
1274 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1275 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1276 1ae0a341 2020-02-14 stsp echo ": removing zeta on newbranch" \
1277 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1278 1ae0a341 2020-02-14 stsp echo "Switching work tree to refs/heads/newbranch" \
1279 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1281 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1283 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1284 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
1285 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1289 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/content.expected
1290 1ae0a341 2020-02-14 stsp cat $testroot/wt/gamma/delta > $testroot/content
1291 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1293 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1294 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1295 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1299 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/content.expected
1300 1ae0a341 2020-02-14 stsp cat $testroot/wt/alpha > $testroot/content
1301 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1303 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1304 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1305 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1309 1ae0a341 2020-02-14 stsp if [ -e $testroot/wt/epsilon ]; then
1310 1ae0a341 2020-02-14 stsp echo "parent of removed zeta still exists on disk" >&2
1311 1ae0a341 2020-02-14 stsp test_done "$testroot" "1"
1315 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got status > $testroot/stdout)
1317 1ae0a341 2020-02-14 stsp echo -n > $testroot/stdout.expected
1318 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1320 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1321 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1322 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1326 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1327 1ae0a341 2020-02-14 stsp echo "commit $new_commit2 (newbranch)" > $testroot/stdout.expected
1328 1ae0a341 2020-02-14 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1329 1ae0a341 2020-02-14 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1330 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1332 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1333 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1335 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1338 f6cae3ed 2020-09-13 naddy test_rebase_delete_missing_file() {
1339 ca6da77d 2020-03-22 stsp local testroot=`test_init rebase_delete_missing_file`
1341 ca6da77d 2020-03-22 stsp mkdir -p $testroot/repo/d/f/g
1342 ca6da77d 2020-03-22 stsp echo "new file" > $testroot/repo/d/f/g/new
1343 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git add d/f/g/new)
1344 ca6da77d 2020-03-22 stsp git_commit $testroot/repo -m "adding a subdir"
1345 ca6da77d 2020-03-22 stsp local commit0=`git_show_head $testroot/repo`
1347 a740a1b3 2020-03-22 stsp got br -r $testroot/repo -c master newbranch
1349 a740a1b3 2020-03-22 stsp got checkout -b newbranch $testroot/repo $testroot/wt > /dev/null
1351 a740a1b3 2020-03-22 stsp echo "modified delta on branch" > $testroot/wt/gamma/delta
1352 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1353 a740a1b3 2020-03-22 stsp -m "committing to delta on newbranch" > /dev/null)
1355 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1356 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1357 a740a1b3 2020-03-22 stsp -m "removing beta and d/f/g/new on newbranch" > /dev/null)
1359 a740a1b3 2020-03-22 stsp (cd $testroot/repo && git checkout -q newbranch)
1360 ca6da77d 2020-03-22 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1361 ca6da77d 2020-03-22 stsp local orig_commit2=`git_show_head $testroot/repo`
1363 bb494413 2021-09-28 thomas local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1364 bb494413 2021-09-28 thomas local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1366 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got update -b master > /dev/null)
1367 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1368 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1369 a740a1b3 2020-03-22 stsp -m "removing beta and d/f/g/new on master" > /dev/null)
1371 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git checkout -q master)
1372 ca6da77d 2020-03-22 stsp local master_commit=`git_show_head $testroot/repo`
1374 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got update -b master > /dev/null)
1375 bb494413 2021-09-28 thomas (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
1376 bb494413 2021-09-28 thomas 2> $testroot/stderr)
1378 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
1379 bb494413 2021-09-28 thomas echo "rebase succeeded unexpectedly" >&2
1380 bb494413 2021-09-28 thomas test_done "$testroot" "1"
1381 bb494413 2021-09-28 thomas return 1
1384 bb494413 2021-09-28 thomas local new_commit1=$(cd $testroot/wt && got info | \
1385 bb494413 2021-09-28 thomas grep '^work tree base commit: ' | cut -d: -f2 | tr -d ' ')
1387 ca6da77d 2020-03-22 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1388 ca6da77d 2020-03-22 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1390 ca6da77d 2020-03-22 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1391 ca6da77d 2020-03-22 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1392 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1393 ca6da77d 2020-03-22 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1394 ca6da77d 2020-03-22 stsp echo "! beta" >> $testroot/stdout.expected
1395 ca6da77d 2020-03-22 stsp echo "! d/f/g/new" >> $testroot/stdout.expected
1396 0ef68859 2021-09-28 thomas echo -n "Files which had incoming changes but could not be found " \
1397 0ef68859 2021-09-28 thomas >> $testroot/stdout.expected
1398 0ef68859 2021-09-28 thomas echo "in the work tree: 2" >> $testroot/stdout.expected
1399 bb494413 2021-09-28 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1401 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1402 bb494413 2021-09-28 thomas diff -u $testroot/stdout.expected $testroot/stdout
1403 bb494413 2021-09-28 thomas test_done "$testroot" "$ret"
1404 bb494413 2021-09-28 thomas return 1
1407 bb494413 2021-09-28 thomas echo -n "got: changes destined for some files were not yet merged " \
1408 bb494413 2021-09-28 thomas > $testroot/stderr.expected
1409 bb494413 2021-09-28 thomas echo -n "and should be merged manually if required before the " \
1410 bb494413 2021-09-28 thomas >> $testroot/stderr.expected
1411 bb494413 2021-09-28 thomas echo "rebase operation is continued" >> $testroot/stderr.expected
1412 bb494413 2021-09-28 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1414 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1415 bb494413 2021-09-28 thomas diff -u $testroot/stderr.expected $testroot/stderr
1416 bb494413 2021-09-28 thomas test_done "$testroot" "$ret"
1417 bb494413 2021-09-28 thomas return 1
1420 bb494413 2021-09-28 thomas # ignore the missing changes and continue
1421 bb494413 2021-09-28 thomas (cd $testroot/wt && got rebase -c > $testroot/stdout)
1423 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1424 bb494413 2021-09-28 thomas echo "rebase failed unexpectedly" >&2
1425 bb494413 2021-09-28 thomas test_done "$testroot" "1"
1426 bb494413 2021-09-28 thomas return 1
1428 ca6da77d 2020-03-22 stsp echo -n "$short_orig_commit2 -> no-op change" \
1429 bb494413 2021-09-28 thomas > $testroot/stdout.expected
1430 a740a1b3 2020-03-22 stsp echo ": removing beta and d/f/g/new on newbranch" \
1431 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1432 ca6da77d 2020-03-22 stsp echo "Switching work tree to refs/heads/newbranch" \
1433 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1435 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1437 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1438 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1439 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1443 ca6da77d 2020-03-22 stsp echo "modified delta on branch" > $testroot/content.expected
1444 ca6da77d 2020-03-22 stsp cat $testroot/wt/gamma/delta > $testroot/content
1445 ca6da77d 2020-03-22 stsp cmp -s $testroot/content.expected $testroot/content
1447 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1448 ca6da77d 2020-03-22 stsp diff -u $testroot/content.expected $testroot/content
1449 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1453 ca6da77d 2020-03-22 stsp if [ -e $testroot/wt/beta ]; then
1454 ca6da77d 2020-03-22 stsp echo "removed file beta still exists on disk" >&2
1455 ca6da77d 2020-03-22 stsp test_done "$testroot" "1"
1459 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got status > $testroot/stdout)
1461 ca6da77d 2020-03-22 stsp echo -n > $testroot/stdout.expected
1462 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1464 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1465 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1466 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1470 bb494413 2021-09-28 thomas (cd $testroot/repo && git checkout -q newbranch)
1471 bb494413 2021-09-28 thomas local new_commit1=`git_show_head $testroot/repo`
1472 bb494413 2021-09-28 thomas local short_new_commit1=`trim_obj_id 28 $new_commit1`
1474 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1475 ca6da77d 2020-03-22 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
1476 ca6da77d 2020-03-22 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1477 ca6da77d 2020-03-22 stsp echo "commit $commit0" >> $testroot/stdout.expected
1478 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1480 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1481 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1483 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1486 f6cae3ed 2020-09-13 naddy test_rebase_rm_add_rm_file() {
1487 70551d57 2020-04-24 stsp local testroot=`test_init rebase_rm_add_rm_file`
1489 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1490 70551d57 2020-04-24 stsp (cd $testroot/repo && git rm -q beta)
1491 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "removing beta from newbranch"
1492 70551d57 2020-04-24 stsp local orig_commit1=`git_show_head $testroot/repo`
1494 70551d57 2020-04-24 stsp echo 'restored beta' > $testroot/repo/beta
1495 70551d57 2020-04-24 stsp (cd $testroot/repo && git add beta)
1496 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "restoring beta on newbranch"
1497 70551d57 2020-04-24 stsp local orig_commit2=`git_show_head $testroot/repo`
1499 70551d57 2020-04-24 stsp (cd $testroot/repo && git rm -q beta)
1500 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "removing beta from newbranch again"
1501 70551d57 2020-04-24 stsp local orig_commit3=`git_show_head $testroot/repo`
1503 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q master)
1504 70551d57 2020-04-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1505 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
1506 70551d57 2020-04-24 stsp local master_commit=`git_show_head $testroot/repo`
1508 70551d57 2020-04-24 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1510 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1511 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1515 70551d57 2020-04-24 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1517 70551d57 2020-04-24 stsp # this would error out with 'got: file index is corrupt'
1518 70551d57 2020-04-24 stsp (cd $testroot/wt && got status > /dev/null)
1520 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1521 70551d57 2020-04-24 stsp echo "got status command failed unexpectedly" >&2
1522 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1526 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q newbranch)
1527 70551d57 2020-04-24 stsp local new_commit3=`git_show_head $testroot/repo`
1528 70551d57 2020-04-24 stsp local new_commit2=`git_show_parent_commit $testroot/repo`
1529 70551d57 2020-04-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo $new_commit2`
1531 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q newbranch)
1533 70551d57 2020-04-24 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1534 70551d57 2020-04-24 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1535 70551d57 2020-04-24 stsp local short_orig_commit3=`trim_obj_id 28 $orig_commit3`
1536 70551d57 2020-04-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1537 70551d57 2020-04-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1538 70551d57 2020-04-24 stsp local short_new_commit3=`trim_obj_id 28 $new_commit3`
1540 70551d57 2020-04-24 stsp echo "D beta" > $testroot/stdout.expected
1541 70551d57 2020-04-24 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1542 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1543 70551d57 2020-04-24 stsp echo ": removing beta from newbranch" >> $testroot/stdout.expected
1544 70551d57 2020-04-24 stsp echo "A beta" >> $testroot/stdout.expected
1545 70551d57 2020-04-24 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1546 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1547 70551d57 2020-04-24 stsp echo ": restoring beta on newbranch" >> $testroot/stdout.expected
1548 70551d57 2020-04-24 stsp echo "D beta" >> $testroot/stdout.expected
1549 70551d57 2020-04-24 stsp echo -n "$short_orig_commit3 -> $short_new_commit3" \
1550 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1551 70551d57 2020-04-24 stsp echo ": removing beta from newbranch again" >> $testroot/stdout.expected
1552 70551d57 2020-04-24 stsp echo "Switching work tree to refs/heads/newbranch" \
1553 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1555 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1557 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1558 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1559 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1563 70551d57 2020-04-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1565 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1566 70551d57 2020-04-24 stsp echo "got status command failed unexpectedly" >&2
1567 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1571 70551d57 2020-04-24 stsp echo -n > $testroot/stdout.expected
1572 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1574 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1575 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1576 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1580 70551d57 2020-04-24 stsp (cd $testroot/wt && got log -l4 | grep ^commit > $testroot/stdout)
1581 70551d57 2020-04-24 stsp echo "commit $new_commit3 (newbranch)" > $testroot/stdout.expected
1582 70551d57 2020-04-24 stsp echo "commit $new_commit2" >> $testroot/stdout.expected
1583 70551d57 2020-04-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1584 70551d57 2020-04-24 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1585 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1587 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
1588 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1590 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1593 150d7275 2022-07-22 thomas test_rebase_resets_committer() {
1594 150d7275 2022-07-22 thomas local testroot=`test_init rebase_resets_committer`
1595 150d7275 2022-07-22 thomas local commit0=`git_show_head $testroot/repo`
1596 150d7275 2022-07-22 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
1597 150d7275 2022-07-22 thomas local committer="Flan Luck <flan_luck@openbsd.org>"
1599 150d7275 2022-07-22 thomas (cd $testroot/repo && git checkout -q -b newbranch)
1600 150d7275 2022-07-22 thomas echo "modified delta on branch" > $testroot/repo/gamma/delta
1601 150d7275 2022-07-22 thomas git_commit $testroot/repo -m "committing to delta on newbranch"
1603 150d7275 2022-07-22 thomas echo "modified alpha on branch" > $testroot/repo/alpha
1604 150d7275 2022-07-22 thomas git_commit $testroot/repo -m "committing more changes on newbranch"
1606 150d7275 2022-07-22 thomas local orig_commit1=`git_show_parent_commit $testroot/repo`
1607 150d7275 2022-07-22 thomas local orig_commit2=`git_show_head $testroot/repo`
1608 150d7275 2022-07-22 thomas local orig_author_time2=`git_show_author_time $testroot/repo`
1610 150d7275 2022-07-22 thomas (cd $testroot/repo && git checkout -q master)
1611 150d7275 2022-07-22 thomas echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1612 150d7275 2022-07-22 thomas git_commit $testroot/repo -m "committing to zeta on master"
1613 150d7275 2022-07-22 thomas local master_commit=`git_show_head $testroot/repo`
1615 150d7275 2022-07-22 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1617 150d7275 2022-07-22 thomas if [ $ret -ne 0 ]; then
1618 150d7275 2022-07-22 thomas test_done "$testroot" "$ret"
1619 150d7275 2022-07-22 thomas return 1
1622 150d7275 2022-07-22 thomas (cd $testroot/wt && env GOT_AUTHOR="$committer" \
1623 150d7275 2022-07-22 thomas got rebase newbranch > $testroot/stdout)
1625 150d7275 2022-07-22 thomas (cd $testroot/repo && git checkout -q newbranch)
1626 150d7275 2022-07-22 thomas local new_commit1=`git_show_parent_commit $testroot/repo`
1627 150d7275 2022-07-22 thomas local new_commit2=`git_show_head $testroot/repo`
1628 150d7275 2022-07-22 thomas local new_author_time2=`git_show_author_time $testroot/repo`
1630 150d7275 2022-07-22 thomas local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1631 150d7275 2022-07-22 thomas local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1632 150d7275 2022-07-22 thomas local short_new_commit1=`trim_obj_id 28 $new_commit1`
1633 150d7275 2022-07-22 thomas local short_new_commit2=`trim_obj_id 28 $new_commit2`
1635 150d7275 2022-07-22 thomas echo "G gamma/delta" >> $testroot/stdout.expected
1636 150d7275 2022-07-22 thomas echo -n "$short_orig_commit1 -> $short_new_commit1" \
1637 150d7275 2022-07-22 thomas >> $testroot/stdout.expected
1638 150d7275 2022-07-22 thomas echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1639 150d7275 2022-07-22 thomas echo "G alpha" >> $testroot/stdout.expected
1640 150d7275 2022-07-22 thomas echo -n "$short_orig_commit2 -> $short_new_commit2" \
1641 150d7275 2022-07-22 thomas >> $testroot/stdout.expected
1642 150d7275 2022-07-22 thomas echo ": committing more changes on newbranch" \
1643 150d7275 2022-07-22 thomas >> $testroot/stdout.expected
1644 150d7275 2022-07-22 thomas echo "Switching work tree to refs/heads/newbranch" \
1645 150d7275 2022-07-22 thomas >> $testroot/stdout.expected
1647 150d7275 2022-07-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1649 150d7275 2022-07-22 thomas if [ $ret -ne 0 ]; then
1650 150d7275 2022-07-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1651 150d7275 2022-07-22 thomas test_done "$testroot" "$ret"
1652 150d7275 2022-07-22 thomas return 1
1655 150d7275 2022-07-22 thomas # Original commit only had one author
1656 150d7275 2022-07-22 thomas (cd $testroot/repo && got log -l1 -c $orig_commit2 | \
1657 150d7275 2022-07-22 thomas egrep '^(from|via):' > $testroot/stdout)
1658 150d7275 2022-07-22 thomas echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
1659 150d7275 2022-07-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1661 150d7275 2022-07-22 thomas if [ $ret -ne 0 ]; then
1662 150d7275 2022-07-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1663 150d7275 2022-07-22 thomas test_done "$testroot" "$ret"
1664 150d7275 2022-07-22 thomas return 1
1667 150d7275 2022-07-22 thomas # Rebased commit should have new committer name added
1668 150d7275 2022-07-22 thomas (cd $testroot/repo && got log -l1 -c $new_commit2 | \
1669 150d7275 2022-07-22 thomas egrep '^(from|via):' > $testroot/stdout)
1670 150d7275 2022-07-22 thomas echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
1671 150d7275 2022-07-22 thomas echo "via: $committer" >> $testroot/stdout.expected
1673 8db00f97 2022-07-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1675 8db00f97 2022-07-22 thomas if [ $ret -ne 0 ]; then
1676 8db00f97 2022-07-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1678 8db00f97 2022-07-22 thomas test_done "$testroot" "$ret"
1681 8db00f97 2022-07-22 thomas test_rebase_no_author_info() {
1682 8db00f97 2022-07-22 thomas local testroot=`test_init rebase_no_author_info`
1683 8db00f97 2022-07-22 thomas local commit0=`git_show_head $testroot/repo`
1684 8db00f97 2022-07-22 thomas local commit0_author_time=`git_show_author_time $testroot/repo`
1685 8db00f97 2022-07-22 thomas local committer="$GOT_AUTHOR"
1687 8db00f97 2022-07-22 thomas (cd $testroot/repo && git checkout -q -b newbranch)
1688 8db00f97 2022-07-22 thomas echo "modified delta on branch" > $testroot/repo/gamma/delta
1689 8db00f97 2022-07-22 thomas git_commit $testroot/repo -m "committing to delta on newbranch"
1691 8db00f97 2022-07-22 thomas echo "modified alpha on branch" > $testroot/repo/alpha
1692 8db00f97 2022-07-22 thomas git_commit $testroot/repo -m "committing more changes on newbranch"
1694 8db00f97 2022-07-22 thomas local orig_commit1=`git_show_parent_commit $testroot/repo`
1695 8db00f97 2022-07-22 thomas local orig_commit2=`git_show_head $testroot/repo`
1696 8db00f97 2022-07-22 thomas local orig_author_time2=`git_show_author_time $testroot/repo`
1698 8db00f97 2022-07-22 thomas (cd $testroot/repo && git checkout -q master)
1699 8db00f97 2022-07-22 thomas echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1700 8db00f97 2022-07-22 thomas git_commit $testroot/repo -m "committing to zeta on master"
1701 8db00f97 2022-07-22 thomas local master_commit=`git_show_head $testroot/repo`
1703 8db00f97 2022-07-22 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1705 8db00f97 2022-07-22 thomas if [ $ret -ne 0 ]; then
1706 8db00f97 2022-07-22 thomas test_done "$testroot" "$ret"
1707 8db00f97 2022-07-22 thomas return 1
1710 95ad1e7d 2022-07-24 thomas # unset in a subshell to avoid affecting our environment
1711 95ad1e7d 2022-07-24 thomas (unset GOT_AUTHOR && cd $testroot/wt && \
1712 95ad1e7d 2022-07-24 thomas got rebase newbranch > $testroot/stdout)
1714 8db00f97 2022-07-22 thomas (cd $testroot/repo && git checkout -q newbranch)
1715 8db00f97 2022-07-22 thomas local new_commit1=`git_show_parent_commit $testroot/repo`
1716 8db00f97 2022-07-22 thomas local new_commit2=`git_show_head $testroot/repo`
1717 8db00f97 2022-07-22 thomas local new_author_time2=`git_show_author_time $testroot/repo`
1719 8db00f97 2022-07-22 thomas local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1720 8db00f97 2022-07-22 thomas local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1721 8db00f97 2022-07-22 thomas local short_new_commit1=`trim_obj_id 28 $new_commit1`
1722 8db00f97 2022-07-22 thomas local short_new_commit2=`trim_obj_id 28 $new_commit2`
1724 8db00f97 2022-07-22 thomas echo "G gamma/delta" >> $testroot/stdout.expected
1725 8db00f97 2022-07-22 thomas echo -n "$short_orig_commit1 -> $short_new_commit1" \
1726 8db00f97 2022-07-22 thomas >> $testroot/stdout.expected
1727 8db00f97 2022-07-22 thomas echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1728 8db00f97 2022-07-22 thomas echo "G alpha" >> $testroot/stdout.expected
1729 8db00f97 2022-07-22 thomas echo -n "$short_orig_commit2 -> $short_new_commit2" \
1730 8db00f97 2022-07-22 thomas >> $testroot/stdout.expected
1731 8db00f97 2022-07-22 thomas echo ": committing more changes on newbranch" \
1732 8db00f97 2022-07-22 thomas >> $testroot/stdout.expected
1733 8db00f97 2022-07-22 thomas echo "Switching work tree to refs/heads/newbranch" \
1734 8db00f97 2022-07-22 thomas >> $testroot/stdout.expected
1736 150d7275 2022-07-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1738 150d7275 2022-07-22 thomas if [ $ret -ne 0 ]; then
1739 150d7275 2022-07-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1740 8db00f97 2022-07-22 thomas test_done "$testroot" "$ret"
1741 8db00f97 2022-07-22 thomas return 1
1744 8db00f97 2022-07-22 thomas # Original commit only had one author
1745 8db00f97 2022-07-22 thomas (cd $testroot/repo && got log -l1 -c $orig_commit2 | \
1746 8db00f97 2022-07-22 thomas egrep '^(from|via):' > $testroot/stdout)
1747 8db00f97 2022-07-22 thomas echo "from: $committer" > $testroot/stdout.expected
1748 8db00f97 2022-07-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1750 8db00f97 2022-07-22 thomas if [ $ret -ne 0 ]; then
1751 8db00f97 2022-07-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1752 8db00f97 2022-07-22 thomas test_done "$testroot" "$ret"
1753 8db00f97 2022-07-22 thomas return 1
1756 8db00f97 2022-07-22 thomas # Author info of rebased commit should match the original
1757 8db00f97 2022-07-22 thomas (cd $testroot/repo && got log -l1 -c $new_commit2 | \
1758 8db00f97 2022-07-22 thomas egrep '^(from|via):' > $testroot/stdout)
1759 8db00f97 2022-07-22 thomas echo "from: $committer" > $testroot/stdout.expected
1761 8db00f97 2022-07-22 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1763 8db00f97 2022-07-22 thomas if [ $ret -ne 0 ]; then
1764 8db00f97 2022-07-22 thomas diff -u $testroot/stdout.expected $testroot/stdout
1766 8dbcf388 2022-09-04 thomas test_done "$testroot" "$ret"
1769 8dbcf388 2022-09-04 thomas test_rebase_nonbranch() {
1770 8dbcf388 2022-09-04 thomas local testroot=`test_init rebase_nonbranch`
1772 8dbcf388 2022-09-04 thomas got ref -r $testroot/repo -c refs/heads/master \
1773 8dbcf388 2022-09-04 thomas refs/remotes/origin/master >/dev/null
1775 8dbcf388 2022-09-04 thomas got checkout -b master $testroot/repo $testroot/wt >/dev/null
1777 8dbcf388 2022-09-04 thomas (cd $testroot/wt && got rebase origin/master > $testroot/stdout \
1778 8dbcf388 2022-09-04 thomas 2> $testroot/stderr)
1780 8dbcf388 2022-09-04 thomas if [ $ret -eq 0 ]; then
1781 8dbcf388 2022-09-04 thomas echo "rebase succeeded unexpectedly" >&2
1782 8dbcf388 2022-09-04 thomas test_done "$testroot" "1"
1783 8dbcf388 2022-09-04 thomas return 1
1785 8dbcf388 2022-09-04 thomas echo -n "got: will not rebase a branch which lives outside the " \
1786 8dbcf388 2022-09-04 thomas > $testroot/stderr.expected
1787 8dbcf388 2022-09-04 thomas echo '"refs/heads/" reference namespace' >> $testroot/stderr.expected
1788 8dbcf388 2022-09-04 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1790 8dbcf388 2022-09-04 thomas if [ $ret -ne 0 ]; then
1791 8dbcf388 2022-09-04 thomas diff -u $testroot/stderr.expected $testroot/stderr
1793 150d7275 2022-07-22 thomas test_done "$testroot" "$ret"
1796 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1797 dcf44d04 2019-07-11 stsp run_test test_rebase_basic
1798 dcf44d04 2019-07-11 stsp run_test test_rebase_ancestry_check
1799 dcf44d04 2019-07-11 stsp run_test test_rebase_continue
1800 dcf44d04 2019-07-11 stsp run_test test_rebase_abort
1801 ff0d2220 2019-07-11 stsp run_test test_rebase_no_op_change
1802 7d5807f4 2019-07-11 stsp run_test test_rebase_in_progress
1803 64c6d990 2019-07-11 stsp run_test test_rebase_path_prefix
1804 787c8eb6 2019-07-11 stsp run_test test_rebase_preserves_logmsg
1805 fc66b545 2019-08-12 stsp run_test test_rebase_no_commits_to_rebase
1806 38b0338b 2019-11-29 stsp run_test test_rebase_forward
1807 1996dd72 2022-09-21 thomas run_test test_rebase_forward_path_prefix
1808 e51d7b55 2020-01-04 stsp run_test test_rebase_out_of_date
1809 1ae0a341 2020-02-14 stsp run_test test_rebase_trims_empty_dir
1810 ca6da77d 2020-03-22 stsp run_test test_rebase_delete_missing_file
1811 70551d57 2020-04-24 stsp run_test test_rebase_rm_add_rm_file
1812 150d7275 2022-07-22 thomas run_test test_rebase_resets_committer
1813 8db00f97 2022-07-22 thomas run_test test_rebase_no_author_info
1814 8dbcf388 2022-09-04 thomas run_test test_rebase_nonbranch