Blame


1 818c7501 2019-07-11 stsp #!/bin/sh
2 818c7501 2019-07-11 stsp #
3 5aa81393 2020-01-06 stsp # Copyright (c) 2019, 2020 Stefan Sperling <stsp@openbsd.org>
4 818c7501 2019-07-11 stsp #
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.
8 818c7501 2019-07-11 stsp #
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.
16 818c7501 2019-07-11 stsp
17 818c7501 2019-07-11 stsp . ./common.sh
18 818c7501 2019-07-11 stsp
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`
23 818c7501 2019-07-11 stsp
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"
27 818c7501 2019-07-11 stsp
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"
33 818c7501 2019-07-11 stsp
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`
37 818c7501 2019-07-11 stsp
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`
42 818c7501 2019-07-11 stsp
43 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
44 818c7501 2019-07-11 stsp ret="$?"
45 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
46 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
47 818c7501 2019-07-11 stsp return 1
48 818c7501 2019-07-11 stsp fi
49 818c7501 2019-07-11 stsp
50 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
51 818c7501 2019-07-11 stsp
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`
56 818c7501 2019-07-11 stsp
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`
61 818c7501 2019-07-11 stsp
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
75 818c7501 2019-07-11 stsp
76 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
77 818c7501 2019-07-11 stsp ret="$?"
78 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
79 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
80 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
81 818c7501 2019-07-11 stsp return 1
82 818c7501 2019-07-11 stsp fi
83 818c7501 2019-07-11 stsp
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
87 818c7501 2019-07-11 stsp ret="$?"
88 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
89 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
90 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
91 818c7501 2019-07-11 stsp return 1
92 818c7501 2019-07-11 stsp fi
93 818c7501 2019-07-11 stsp
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
97 818c7501 2019-07-11 stsp ret="$?"
98 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
99 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
100 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
101 818c7501 2019-07-11 stsp return 1
102 818c7501 2019-07-11 stsp fi
103 818c7501 2019-07-11 stsp
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"
107 818c7501 2019-07-11 stsp return 1
108 818c7501 2019-07-11 stsp fi
109 818c7501 2019-07-11 stsp
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
113 818c7501 2019-07-11 stsp ret="$?"
114 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
115 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
116 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
117 818c7501 2019-07-11 stsp return 1
118 818c7501 2019-07-11 stsp fi
119 818c7501 2019-07-11 stsp
120 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
121 818c7501 2019-07-11 stsp
122 818c7501 2019-07-11 stsp echo -n > $testroot/stdout.expected
123 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
124 818c7501 2019-07-11 stsp ret="$?"
125 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
126 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
127 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
128 818c7501 2019-07-11 stsp return 1
129 818c7501 2019-07-11 stsp fi
130 818c7501 2019-07-11 stsp
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
136 818c7501 2019-07-11 stsp ret="$?"
137 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
138 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
139 a615e0e7 2020-12-16 stsp test_done "$testroot" "$ret"
140 a615e0e7 2020-12-16 stsp return 1
141 818c7501 2019-07-11 stsp fi
142 a615e0e7 2020-12-16 stsp
143 a615e0e7 2020-12-16 stsp (cd $testroot/wt && got update > $testroot/stdout)
144 a615e0e7 2020-12-16 stsp
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
147 a615e0e7 2020-12-16 stsp ret="$?"
148 a615e0e7 2020-12-16 stsp if [ "$ret" != "0" ]; then
149 a615e0e7 2020-12-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
150 e600f124 2021-03-21 stsp test_done "$testroot" "$ret"
151 a9662115 2021-08-29 naddy return 1
152 a615e0e7 2020-12-16 stsp fi
153 e600f124 2021-03-21 stsp
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 180f111d 2021-09-21 thomas.ad d_orig2=`env LC_TIME=C date -u -d "@$orig_author_time2" +"%a %b %e %X %Y UTC"`
157 180f111d 2021-09-21 thomas.ad d_new2=`date -u -d "@$new_author_time2" +"%G-%m-%d"`
158 180f111d 2021-09-21 thomas.ad d_0=`date -u -d "@$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
164 e600f124 2021-03-21 stsp
165 e600f124 2021-03-21 stsp committing more changes on newbranch
166 e600f124 2021-03-21 stsp
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
171 e600f124 2021-03-21 stsp EOF
172 e600f124 2021-03-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
173 e600f124 2021-03-21 stsp ret="$?"
174 e600f124 2021-03-21 stsp if [ "$ret" != "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"
177 a9662115 2021-08-29 naddy return 1
178 e600f124 2021-03-21 stsp fi
179 9e822917 2021-03-23 stsp
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
187 9e822917 2021-03-23 stsp ret="$?"
188 9e822917 2021-03-23 stsp if [ "$ret" != "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"
191 643b85bc 2021-07-16 stsp return 1
192 9e822917 2021-03-23 stsp fi
193 9e822917 2021-03-23 stsp cmp -s $testroot/stderr.expected $testroot/stderr
194 9e822917 2021-03-23 stsp ret="$?"
195 9e822917 2021-03-23 stsp if [ "$ret" != "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"
198 643b85bc 2021-07-16 stsp return 1
199 9e822917 2021-03-23 stsp fi
200 643b85bc 2021-07-16 stsp
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
209 643b85bc 2021-07-16 stsp ret="$?"
210 643b85bc 2021-07-16 stsp if [ "$ret" != "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"
213 643b85bc 2021-07-16 stsp return 1
214 643b85bc 2021-07-16 stsp fi
215 643b85bc 2021-07-16 stsp cmp -s $testroot/stderr.expected $testroot/stderr
216 643b85bc 2021-07-16 stsp ret="$?"
217 643b85bc 2021-07-16 stsp if [ "$ret" != "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"
220 643b85bc 2021-07-16 stsp return 1
221 643b85bc 2021-07-16 stsp fi
222 643b85bc 2021-07-16 stsp
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
226 643b85bc 2021-07-16 stsp ret="$?"
227 643b85bc 2021-07-16 stsp if [ "$ret" != "0" ]; then
228 643b85bc 2021-07-16 stsp diff -u $testroot/stdout.expected $testroot/stdout
229 643b85bc 2021-07-16 stsp fi
230 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
231 818c7501 2019-07-11 stsp }
232 818c7501 2019-07-11 stsp
233 f6cae3ed 2020-09-13 naddy test_rebase_ancestry_check() {
234 818c7501 2019-07-11 stsp local testroot=`test_init rebase_ancestry_check`
235 818c7501 2019-07-11 stsp
236 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
237 818c7501 2019-07-11 stsp ret="$?"
238 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
239 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
240 818c7501 2019-07-11 stsp return 1
241 818c7501 2019-07-11 stsp fi
242 818c7501 2019-07-11 stsp
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 818c7501 2019-07-11 stsp
247 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
248 818c7501 2019-07-11 stsp 2> $testroot/stderr)
249 818c7501 2019-07-11 stsp
250 818c7501 2019-07-11 stsp echo -n > $testroot/stdout.expected
251 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
252 818c7501 2019-07-11 stsp ret="$?"
253 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
254 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
255 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
256 818c7501 2019-07-11 stsp return 1
257 818c7501 2019-07-11 stsp fi
258 818c7501 2019-07-11 stsp
259 df3ed485 2021-01-31 stsp echo "got: refs/heads/newbranch is already based on refs/heads/master" \
260 818c7501 2019-07-11 stsp > $testroot/stderr.expected
261 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
262 818c7501 2019-07-11 stsp ret="$?"
263 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
264 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
265 818c7501 2019-07-11 stsp fi
266 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
267 818c7501 2019-07-11 stsp }
268 818c7501 2019-07-11 stsp
269 f6cae3ed 2020-09-13 naddy test_rebase_continue() {
270 818c7501 2019-07-11 stsp local testroot=`test_init rebase_continue`
271 f69721c3 2019-10-21 stsp local init_commit=`git_show_head $testroot/repo`
272 818c7501 2019-07-11 stsp
273 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
274 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
275 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
276 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
277 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
278 818c7501 2019-07-11 stsp
279 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
280 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
281 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
282 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
283 818c7501 2019-07-11 stsp
284 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
285 818c7501 2019-07-11 stsp ret="$?"
286 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
287 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
288 818c7501 2019-07-11 stsp return 1
289 818c7501 2019-07-11 stsp fi
290 818c7501 2019-07-11 stsp
291 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
292 818c7501 2019-07-11 stsp 2> $testroot/stderr)
293 818c7501 2019-07-11 stsp
294 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
295 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
296 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
297 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
298 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
299 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
300 818c7501 2019-07-11 stsp ret="$?"
301 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
302 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
303 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
304 818c7501 2019-07-11 stsp return 1
305 818c7501 2019-07-11 stsp fi
306 818c7501 2019-07-11 stsp
307 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
308 818c7501 2019-07-11 stsp > $testroot/stderr.expected
309 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
310 818c7501 2019-07-11 stsp ret="$?"
311 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
312 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
313 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
314 818c7501 2019-07-11 stsp return 1
315 818c7501 2019-07-11 stsp fi
316 818c7501 2019-07-11 stsp
317 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
318 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
319 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
320 f69721c3 2019-10-21 stsp >> $testroot/content.expected
321 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
322 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
323 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
324 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
325 54d5be07 2021-06-03 stsp >> $testroot/content.expected
326 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
327 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
328 818c7501 2019-07-11 stsp ret="$?"
329 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
330 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
331 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
332 818c7501 2019-07-11 stsp return 1
333 818c7501 2019-07-11 stsp fi
334 818c7501 2019-07-11 stsp
335 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
336 818c7501 2019-07-11 stsp
337 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
338 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
339 818c7501 2019-07-11 stsp ret="$?"
340 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
341 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
342 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
343 818c7501 2019-07-11 stsp return 1
344 818c7501 2019-07-11 stsp fi
345 818c7501 2019-07-11 stsp
346 818c7501 2019-07-11 stsp # resolve the conflict
347 818c7501 2019-07-11 stsp echo "modified alpha on branch and master" > $testroot/wt/alpha
348 818c7501 2019-07-11 stsp
349 f032f1f7 2019-08-04 stsp # test interaction of 'got stage' and rebase -c
350 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got stage alpha > /dev/null)
351 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout \
352 f032f1f7 2019-08-04 stsp 2> $testroot/stderr)
353 f032f1f7 2019-08-04 stsp ret="$?"
354 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
355 f032f1f7 2019-08-04 stsp echo "rebase succeeded unexpectedly" >&2
356 f032f1f7 2019-08-04 stsp test_done "$testroot" "1"
357 f032f1f7 2019-08-04 stsp return 1
358 f032f1f7 2019-08-04 stsp fi
359 f032f1f7 2019-08-04 stsp echo -n "got: work tree contains files with staged changes; " \
360 f032f1f7 2019-08-04 stsp > $testroot/stderr.expected
361 f032f1f7 2019-08-04 stsp echo "these changes must be committed or unstaged first" \
362 f032f1f7 2019-08-04 stsp >> $testroot/stderr.expected
363 f032f1f7 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
364 f032f1f7 2019-08-04 stsp ret="$?"
365 f032f1f7 2019-08-04 stsp if [ "$ret" != "0" ]; then
366 f032f1f7 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
367 f032f1f7 2019-08-04 stsp test_done "$testroot" "$ret"
368 f032f1f7 2019-08-04 stsp return 1
369 f032f1f7 2019-08-04 stsp fi
370 f032f1f7 2019-08-04 stsp
371 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got unstage alpha > /dev/null)
372 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
373 818c7501 2019-07-11 stsp
374 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
375 818c7501 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
376 818c7501 2019-07-11 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
377 818c7501 2019-07-11 stsp
378 818c7501 2019-07-11 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
379 818c7501 2019-07-11 stsp > $testroot/stdout.expected
380 818c7501 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
381 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
382 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
383 818c7501 2019-07-11 stsp
384 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
385 818c7501 2019-07-11 stsp ret="$?"
386 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
387 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
388 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
389 818c7501 2019-07-11 stsp return 1
390 818c7501 2019-07-11 stsp fi
391 818c7501 2019-07-11 stsp
392 818c7501 2019-07-11 stsp
393 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
394 818c7501 2019-07-11 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
395 818c7501 2019-07-11 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
396 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
397 818c7501 2019-07-11 stsp ret="$?"
398 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
399 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
400 818c7501 2019-07-11 stsp fi
401 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
402 818c7501 2019-07-11 stsp }
403 818c7501 2019-07-11 stsp
404 f6cae3ed 2020-09-13 naddy test_rebase_abort() {
405 818c7501 2019-07-11 stsp local testroot=`test_init rebase_abort`
406 818c7501 2019-07-11 stsp
407 818c7501 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
408 818c7501 2019-07-11 stsp
409 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
410 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
411 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
412 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
413 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
414 818c7501 2019-07-11 stsp
415 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
416 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
417 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
418 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
419 818c7501 2019-07-11 stsp
420 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
421 818c7501 2019-07-11 stsp ret="$?"
422 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
423 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
424 818c7501 2019-07-11 stsp return 1
425 818c7501 2019-07-11 stsp fi
426 818c7501 2019-07-11 stsp
427 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
428 818c7501 2019-07-11 stsp 2> $testroot/stderr)
429 818c7501 2019-07-11 stsp
430 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
431 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
432 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
433 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
434 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
435 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
436 818c7501 2019-07-11 stsp ret="$?"
437 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
438 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
439 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
440 818c7501 2019-07-11 stsp return 1
441 818c7501 2019-07-11 stsp fi
442 818c7501 2019-07-11 stsp
443 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
444 818c7501 2019-07-11 stsp > $testroot/stderr.expected
445 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
446 818c7501 2019-07-11 stsp ret="$?"
447 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
448 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
449 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
450 818c7501 2019-07-11 stsp return 1
451 818c7501 2019-07-11 stsp fi
452 818c7501 2019-07-11 stsp
453 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
454 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
455 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
456 f69721c3 2019-10-21 stsp >> $testroot/content.expected
457 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
458 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
459 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
460 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
461 54d5be07 2021-06-03 stsp >> $testroot/content.expected
462 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
463 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
464 818c7501 2019-07-11 stsp ret="$?"
465 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
466 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
467 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
468 818c7501 2019-07-11 stsp return 1
469 818c7501 2019-07-11 stsp fi
470 818c7501 2019-07-11 stsp
471 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
472 818c7501 2019-07-11 stsp
473 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
474 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
475 818c7501 2019-07-11 stsp ret="$?"
476 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
477 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
478 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
479 818c7501 2019-07-11 stsp return 1
480 818c7501 2019-07-11 stsp fi
481 818c7501 2019-07-11 stsp
482 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -a > $testroot/stdout)
483 818c7501 2019-07-11 stsp
484 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
485 818c7501 2019-07-11 stsp
486 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/master" \
487 818c7501 2019-07-11 stsp > $testroot/stdout.expected
488 818c7501 2019-07-11 stsp echo 'R alpha' >> $testroot/stdout.expected
489 818c7501 2019-07-11 stsp echo "Rebase of refs/heads/newbranch aborted" \
490 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
491 818c7501 2019-07-11 stsp
492 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
493 818c7501 2019-07-11 stsp ret="$?"
494 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
495 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
496 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
497 818c7501 2019-07-11 stsp return 1
498 818c7501 2019-07-11 stsp fi
499 818c7501 2019-07-11 stsp
500 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/content.expected
501 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
502 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
503 818c7501 2019-07-11 stsp ret="$?"
504 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
505 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
506 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
507 818c7501 2019-07-11 stsp return 1
508 818c7501 2019-07-11 stsp fi
509 818c7501 2019-07-11 stsp
510 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l3 -c newbranch \
511 818c7501 2019-07-11 stsp | grep ^commit > $testroot/stdout)
512 818c7501 2019-07-11 stsp echo "commit $orig_commit1 (newbranch)" > $testroot/stdout.expected
513 818c7501 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
514 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
515 818c7501 2019-07-11 stsp ret="$?"
516 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
517 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
518 818c7501 2019-07-11 stsp fi
519 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
520 818c7501 2019-07-11 stsp }
521 818c7501 2019-07-11 stsp
522 f6cae3ed 2020-09-13 naddy test_rebase_no_op_change() {
523 ff0d2220 2019-07-11 stsp local testroot=`test_init rebase_no_op_change`
524 ff0d2220 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
525 ff0d2220 2019-07-11 stsp
526 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
527 ff0d2220 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
528 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
529 ff0d2220 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
530 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
531 ff0d2220 2019-07-11 stsp
532 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
533 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
534 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
535 ff0d2220 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
536 ff0d2220 2019-07-11 stsp
537 ff0d2220 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
538 ff0d2220 2019-07-11 stsp ret="$?"
539 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
540 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
541 ff0d2220 2019-07-11 stsp return 1
542 ff0d2220 2019-07-11 stsp fi
543 ff0d2220 2019-07-11 stsp
544 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
545 ff0d2220 2019-07-11 stsp 2> $testroot/stderr)
546 ff0d2220 2019-07-11 stsp
547 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
548 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
549 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
550 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
551 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
552 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
553 ff0d2220 2019-07-11 stsp ret="$?"
554 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
555 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
556 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
557 ff0d2220 2019-07-11 stsp return 1
558 ff0d2220 2019-07-11 stsp fi
559 ff0d2220 2019-07-11 stsp
560 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
561 ff0d2220 2019-07-11 stsp > $testroot/stderr.expected
562 ff0d2220 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
563 ff0d2220 2019-07-11 stsp ret="$?"
564 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
565 ff0d2220 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
566 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
567 ff0d2220 2019-07-11 stsp return 1
568 ff0d2220 2019-07-11 stsp fi
569 ff0d2220 2019-07-11 stsp
570 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
571 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
572 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
573 f69721c3 2019-10-21 stsp >> $testroot/content.expected
574 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
575 ff0d2220 2019-07-11 stsp echo "=======" >> $testroot/content.expected
576 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
577 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
578 54d5be07 2021-06-03 stsp >> $testroot/content.expected
579 ff0d2220 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
580 ff0d2220 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
581 ff0d2220 2019-07-11 stsp ret="$?"
582 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
583 ff0d2220 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
584 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
585 ff0d2220 2019-07-11 stsp return 1
586 ff0d2220 2019-07-11 stsp fi
587 ff0d2220 2019-07-11 stsp
588 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
589 ff0d2220 2019-07-11 stsp
590 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
591 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
592 ff0d2220 2019-07-11 stsp ret="$?"
593 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
594 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
595 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
596 ff0d2220 2019-07-11 stsp return 1
597 ff0d2220 2019-07-11 stsp fi
598 ff0d2220 2019-07-11 stsp
599 ff0d2220 2019-07-11 stsp # resolve the conflict
600 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/wt/alpha
601 ff0d2220 2019-07-11 stsp
602 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
603 ff0d2220 2019-07-11 stsp
604 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
605 ff0d2220 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
606 ff0d2220 2019-07-11 stsp
607 ff0d2220 2019-07-11 stsp echo -n "$short_orig_commit1 -> no-op change" \
608 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
609 ff0d2220 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
610 ff0d2220 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
611 ff0d2220 2019-07-11 stsp >> $testroot/stdout.expected
612 ff0d2220 2019-07-11 stsp
613 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
614 ff0d2220 2019-07-11 stsp ret="$?"
615 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
616 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
617 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
618 ff0d2220 2019-07-11 stsp return 1
619 ff0d2220 2019-07-11 stsp fi
620 ff0d2220 2019-07-11 stsp
621 ff0d2220 2019-07-11 stsp
622 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
623 ff0d2220 2019-07-11 stsp echo "commit $master_commit (master, newbranch)" \
624 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
625 ff0d2220 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
626 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
627 7d5807f4 2019-07-11 stsp ret="$?"
628 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
629 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
630 7d5807f4 2019-07-11 stsp fi
631 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
632 7d5807f4 2019-07-11 stsp }
633 7d5807f4 2019-07-11 stsp
634 f6cae3ed 2020-09-13 naddy test_rebase_in_progress() {
635 4ba9c4f6 2019-07-11 stsp local testroot=`test_init rebase_in_progress`
636 7d5807f4 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
637 7d5807f4 2019-07-11 stsp
638 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
639 7d5807f4 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
640 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
641 7d5807f4 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
642 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
643 7d5807f4 2019-07-11 stsp
644 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
645 7d5807f4 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
646 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
647 7d5807f4 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
648 7d5807f4 2019-07-11 stsp
649 7d5807f4 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
650 7d5807f4 2019-07-11 stsp ret="$?"
651 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
652 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
653 7d5807f4 2019-07-11 stsp return 1
654 7d5807f4 2019-07-11 stsp fi
655 7d5807f4 2019-07-11 stsp
656 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
657 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
658 7d5807f4 2019-07-11 stsp
659 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
660 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
661 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
662 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
663 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
664 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
665 7d5807f4 2019-07-11 stsp ret="$?"
666 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
667 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
668 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
669 7d5807f4 2019-07-11 stsp return 1
670 7d5807f4 2019-07-11 stsp fi
671 7d5807f4 2019-07-11 stsp
672 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
673 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
674 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
675 7d5807f4 2019-07-11 stsp ret="$?"
676 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
677 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
678 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
679 7d5807f4 2019-07-11 stsp return 1
680 7d5807f4 2019-07-11 stsp fi
681 7d5807f4 2019-07-11 stsp
682 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
683 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
684 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
685 f69721c3 2019-10-21 stsp >> $testroot/content.expected
686 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
687 7d5807f4 2019-07-11 stsp echo "=======" >> $testroot/content.expected
688 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
689 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
690 54d5be07 2021-06-03 stsp >> $testroot/content.expected
691 7d5807f4 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
692 7d5807f4 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
693 7d5807f4 2019-07-11 stsp ret="$?"
694 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
695 7d5807f4 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
696 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
697 7d5807f4 2019-07-11 stsp return 1
698 7d5807f4 2019-07-11 stsp fi
699 7d5807f4 2019-07-11 stsp
700 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
701 7d5807f4 2019-07-11 stsp
702 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
703 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
704 ff0d2220 2019-07-11 stsp ret="$?"
705 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
706 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
707 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
708 7d5807f4 2019-07-11 stsp return 1
709 ff0d2220 2019-07-11 stsp fi
710 7d5807f4 2019-07-11 stsp
711 7d5807f4 2019-07-11 stsp for cmd in update commit; do
712 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got $cmd > $testroot/stdout \
713 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
714 7d5807f4 2019-07-11 stsp
715 7d5807f4 2019-07-11 stsp echo -n > $testroot/stdout.expected
716 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
717 7d5807f4 2019-07-11 stsp ret="$?"
718 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
719 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
720 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
721 7d5807f4 2019-07-11 stsp return 1
722 7d5807f4 2019-07-11 stsp fi
723 7d5807f4 2019-07-11 stsp
724 7d5807f4 2019-07-11 stsp echo -n "got: a rebase operation is in progress in this " \
725 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
726 7d5807f4 2019-07-11 stsp echo "work tree and must be continued or aborted first" \
727 7d5807f4 2019-07-11 stsp >> $testroot/stderr.expected
728 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
729 7d5807f4 2019-07-11 stsp ret="$?"
730 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
731 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
732 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
733 7d5807f4 2019-07-11 stsp return 1
734 7d5807f4 2019-07-11 stsp fi
735 7d5807f4 2019-07-11 stsp done
736 64c6d990 2019-07-11 stsp
737 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
738 64c6d990 2019-07-11 stsp }
739 64c6d990 2019-07-11 stsp
740 f6cae3ed 2020-09-13 naddy test_rebase_path_prefix() {
741 64c6d990 2019-07-11 stsp local testroot=`test_init rebase_path_prefix`
742 64c6d990 2019-07-11 stsp
743 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
744 64c6d990 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
745 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
746 64c6d990 2019-07-11 stsp
747 64c6d990 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
748 64c6d990 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
749 64c6d990 2019-07-11 stsp
750 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
751 64c6d990 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
752 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
753 64c6d990 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
754 64c6d990 2019-07-11 stsp
755 64c6d990 2019-07-11 stsp got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
756 64c6d990 2019-07-11 stsp ret="$?"
757 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
758 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
759 64c6d990 2019-07-11 stsp return 1
760 64c6d990 2019-07-11 stsp fi
761 7d5807f4 2019-07-11 stsp
762 64c6d990 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch \
763 64c6d990 2019-07-11 stsp > $testroot/stdout 2> $testroot/stderr)
764 64c6d990 2019-07-11 stsp
765 64c6d990 2019-07-11 stsp echo -n > $testroot/stdout.expected
766 64c6d990 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
767 64c6d990 2019-07-11 stsp ret="$?"
768 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
769 64c6d990 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
770 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
771 64c6d990 2019-07-11 stsp return 1
772 64c6d990 2019-07-11 stsp fi
773 64c6d990 2019-07-11 stsp
774 64c6d990 2019-07-11 stsp echo -n "got: cannot rebase branch which contains changes outside " \
775 64c6d990 2019-07-11 stsp > $testroot/stderr.expected
776 64c6d990 2019-07-11 stsp echo "of this work tree's path prefix" >> $testroot/stderr.expected
777 787c8eb6 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
778 787c8eb6 2019-07-11 stsp ret="$?"
779 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
780 787c8eb6 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
781 787c8eb6 2019-07-11 stsp fi
782 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
783 787c8eb6 2019-07-11 stsp }
784 787c8eb6 2019-07-11 stsp
785 f6cae3ed 2020-09-13 naddy test_rebase_preserves_logmsg() {
786 787c8eb6 2019-07-11 stsp local testroot=`test_init rebase_preserves_logmsg`
787 787c8eb6 2019-07-11 stsp
788 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
789 787c8eb6 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
790 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified delta on newbranch"
791 787c8eb6 2019-07-11 stsp
792 787c8eb6 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
793 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified alpha on newbranch"
794 787c8eb6 2019-07-11 stsp
795 787c8eb6 2019-07-11 stsp (cd $testroot/repo && got log -c newbranch -l2 | grep -v ^date: \
796 787c8eb6 2019-07-11 stsp > $testroot/log.expected)
797 787c8eb6 2019-07-11 stsp
798 787c8eb6 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
799 787c8eb6 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
800 787c8eb6 2019-07-11 stsp
801 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
802 787c8eb6 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
803 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
804 787c8eb6 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
805 787c8eb6 2019-07-11 stsp
806 787c8eb6 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
807 787c8eb6 2019-07-11 stsp ret="$?"
808 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
809 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
810 787c8eb6 2019-07-11 stsp return 1
811 787c8eb6 2019-07-11 stsp fi
812 787c8eb6 2019-07-11 stsp
813 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > /dev/null \
814 787c8eb6 2019-07-11 stsp 2> $testroot/stderr)
815 787c8eb6 2019-07-11 stsp
816 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
817 787c8eb6 2019-07-11 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
818 787c8eb6 2019-07-11 stsp local new_commit2=`git_show_head $testroot/repo`
819 787c8eb6 2019-07-11 stsp
820 787c8eb6 2019-07-11 stsp echo -n > $testroot/stderr.expected
821 64c6d990 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
822 64c6d990 2019-07-11 stsp ret="$?"
823 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
824 64c6d990 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
825 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
826 787c8eb6 2019-07-11 stsp return 1
827 64c6d990 2019-07-11 stsp fi
828 787c8eb6 2019-07-11 stsp
829 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got log -c newbranch -l2 | grep -v ^date: \
830 787c8eb6 2019-07-11 stsp > $testroot/log)
831 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit1/$new_commit1/" $testroot/log.expected
832 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit2/$new_commit2/" $testroot/log.expected
833 787c8eb6 2019-07-11 stsp cmp -s $testroot/log.expected $testroot/log
834 787c8eb6 2019-07-11 stsp ret="$?"
835 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
836 787c8eb6 2019-07-11 stsp diff -u $testroot/log.expected $testroot/log
837 fc66b545 2019-08-12 stsp fi
838 fc66b545 2019-08-12 stsp
839 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
840 fc66b545 2019-08-12 stsp }
841 fc66b545 2019-08-12 stsp
842 f6cae3ed 2020-09-13 naddy test_rebase_no_commits_to_rebase() {
843 fc66b545 2019-08-12 stsp local testroot=`test_init rebase_no_commits_to_rebase`
844 fc66b545 2019-08-12 stsp
845 fc66b545 2019-08-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
846 fc66b545 2019-08-12 stsp ret="$?"
847 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
848 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
849 fc66b545 2019-08-12 stsp return 1
850 fc66b545 2019-08-12 stsp fi
851 fc66b545 2019-08-12 stsp
852 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n newbranch)
853 fc66b545 2019-08-12 stsp
854 fc66b545 2019-08-12 stsp echo "modified alpha on master" > $testroot/wt/alpha
855 fc66b545 2019-08-12 stsp (cd $testroot/wt && got commit -m 'test rebase_no_commits_to_rebase' \
856 fc66b545 2019-08-12 stsp > /dev/null)
857 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > /dev/null)
858 fc66b545 2019-08-12 stsp
859 fc66b545 2019-08-12 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
860 fc66b545 2019-08-12 stsp 2> $testroot/stderr)
861 fc66b545 2019-08-12 stsp
862 fc66b545 2019-08-12 stsp echo "got: no commits to rebase" > $testroot/stderr.expected
863 fc66b545 2019-08-12 stsp cmp -s $testroot/stderr.expected $testroot/stderr
864 fc66b545 2019-08-12 stsp ret="$?"
865 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
866 fc66b545 2019-08-12 stsp diff -u $testroot/stderr.expected $testroot/stderr
867 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
868 fc66b545 2019-08-12 stsp return 1
869 787c8eb6 2019-07-11 stsp fi
870 787c8eb6 2019-07-11 stsp
871 fc66b545 2019-08-12 stsp echo "Rebase of refs/heads/newbranch aborted" \
872 fc66b545 2019-08-12 stsp > $testroot/stdout.expected
873 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
874 fc66b545 2019-08-12 stsp ret="$?"
875 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
876 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
877 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
878 fc66b545 2019-08-12 stsp return 1
879 fc66b545 2019-08-12 stsp fi
880 fc66b545 2019-08-12 stsp
881 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
882 fc66b545 2019-08-12 stsp echo "Already up-to-date" > $testroot/stdout.expected
883 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
884 fc66b545 2019-08-12 stsp ret="$?"
885 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
886 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
887 fc66b545 2019-08-12 stsp fi
888 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
889 ff0d2220 2019-07-11 stsp }
890 38b0338b 2019-11-29 stsp
891 f6cae3ed 2020-09-13 naddy test_rebase_forward() {
892 38b0338b 2019-11-29 stsp local testroot=`test_init rebase_forward`
893 38b0338b 2019-11-29 stsp local commit0=`git_show_head $testroot/repo`
894 38b0338b 2019-11-29 stsp
895 38b0338b 2019-11-29 stsp got checkout $testroot/repo $testroot/wt > /dev/null
896 38b0338b 2019-11-29 stsp ret="$?"
897 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
898 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
899 38b0338b 2019-11-29 stsp return 1
900 38b0338b 2019-11-29 stsp fi
901 38b0338b 2019-11-29 stsp
902 38b0338b 2019-11-29 stsp echo "change alpha 1" > $testroot/wt/alpha
903 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
904 38b0338b 2019-11-29 stsp > /dev/null)
905 38b0338b 2019-11-29 stsp local commit1=`git_show_head $testroot/repo`
906 ff0d2220 2019-07-11 stsp
907 38b0338b 2019-11-29 stsp echo "change alpha 2" > $testroot/wt/alpha
908 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
909 38b0338b 2019-11-29 stsp > /dev/null)
910 38b0338b 2019-11-29 stsp local commit2=`git_show_head $testroot/repo`
911 38b0338b 2019-11-29 stsp
912 38b0338b 2019-11-29 stsp # Simulate a situation where fast-forward is required.
913 38b0338b 2019-11-29 stsp # We want to fast-forward master to origin/master:
914 38b0338b 2019-11-29 stsp # commit 3907e11dceaae2ca7f8db79c2af31794673945ad (origin/master)
915 38b0338b 2019-11-29 stsp # commit ffcffcd102cf1af6572fbdbb4cf07a0f1fd2d840 (master)
916 38b0338b 2019-11-29 stsp # commit 87a6a8a2263a15b61c016ff1720b24741d455eb5
917 993f033b 2021-07-16 stsp (cd $testroot/repo && got ref -d master >/dev/null)
918 e31abbf2 2020-03-22 stsp (cd $testroot/repo && got ref -c $commit1 refs/heads/master)
919 e31abbf2 2020-03-22 stsp (cd $testroot/repo && got ref -c $commit2 refs/remotes/origin/master)
920 38b0338b 2019-11-29 stsp
921 38b0338b 2019-11-29 stsp (cd $testroot/wt && got up -b origin/master > /dev/null)
922 38b0338b 2019-11-29 stsp
923 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase master \
924 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
925 38b0338b 2019-11-29 stsp
926 38b0338b 2019-11-29 stsp echo "Forwarding refs/heads/master to commit $commit2" \
927 38b0338b 2019-11-29 stsp > $testroot/stdout.expected
928 38b0338b 2019-11-29 stsp echo "Switching work tree to refs/heads/master" \
929 38b0338b 2019-11-29 stsp >> $testroot/stdout.expected
930 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
931 38b0338b 2019-11-29 stsp ret="$?"
932 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
933 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
934 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
935 38b0338b 2019-11-29 stsp return 1
936 38b0338b 2019-11-29 stsp fi
937 38b0338b 2019-11-29 stsp
938 38b0338b 2019-11-29 stsp # Ensure that rebase operation was completed correctly
939 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase -a \
940 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
941 38b0338b 2019-11-29 stsp echo -n "" > $testroot/stdout.expected
942 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
943 38b0338b 2019-11-29 stsp ret="$?"
944 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
945 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
946 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
947 38b0338b 2019-11-29 stsp return 1
948 38b0338b 2019-11-29 stsp fi
949 38b0338b 2019-11-29 stsp echo "got: rebase operation not in progress" > $testroot/stderr.expected
950 38b0338b 2019-11-29 stsp cmp -s $testroot/stderr.expected $testroot/stderr
951 38b0338b 2019-11-29 stsp ret="$?"
952 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
953 38b0338b 2019-11-29 stsp diff -u $testroot/stderr.expected $testroot/stderr
954 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
955 38b0338b 2019-11-29 stsp return 1
956 38b0338b 2019-11-29 stsp fi
957 38b0338b 2019-11-29 stsp
958 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n > $testroot/stdout)
959 38b0338b 2019-11-29 stsp echo "master" > $testroot/stdout.expected
960 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
961 38b0338b 2019-11-29 stsp ret="$?"
962 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
963 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
964 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
965 38b0338b 2019-11-29 stsp return 1
966 38b0338b 2019-11-29 stsp fi
967 38b0338b 2019-11-29 stsp
968 38b0338b 2019-11-29 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
969 38b0338b 2019-11-29 stsp echo "commit $commit2 (master, origin/master)" > $testroot/stdout.expected
970 38b0338b 2019-11-29 stsp echo "commit $commit1" >> $testroot/stdout.expected
971 38b0338b 2019-11-29 stsp echo "commit $commit0" >> $testroot/stdout.expected
972 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
973 38b0338b 2019-11-29 stsp ret="$?"
974 38b0338b 2019-11-29 stsp if [ "$ret" != "0" ]; then
975 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
976 e600f124 2021-03-21 stsp test_done "$testroot" "$ret"
977 a9662115 2021-08-29 naddy return 1
978 38b0338b 2019-11-29 stsp fi
979 e600f124 2021-03-21 stsp
980 e600f124 2021-03-21 stsp # Forward-only rebase operations should not be backed up
981 e600f124 2021-03-21 stsp (cd $testroot/repo && got rebase -l > $testroot/stdout)
982 e600f124 2021-03-21 stsp echo -n > $testroot/stdout.expected
983 e600f124 2021-03-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
984 e600f124 2021-03-21 stsp ret="$?"
985 e600f124 2021-03-21 stsp if [ "$ret" != "0" ]; then
986 e600f124 2021-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
987 e600f124 2021-03-21 stsp fi
988 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
989 38b0338b 2019-11-29 stsp }
990 e51d7b55 2020-01-04 stsp
991 f6cae3ed 2020-09-13 naddy test_rebase_out_of_date() {
992 e51d7b55 2020-01-04 stsp local testroot=`test_init rebase_out_of_date`
993 e51d7b55 2020-01-04 stsp local initial_commit=`git_show_head $testroot/repo`
994 e51d7b55 2020-01-04 stsp
995 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q -b newbranch)
996 e51d7b55 2020-01-04 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
997 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
998 38b0338b 2019-11-29 stsp
999 e51d7b55 2020-01-04 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1000 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git rm -q beta)
1001 e51d7b55 2020-01-04 stsp echo "new file on branch" > $testroot/repo/epsilon/new
1002 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git add epsilon/new)
1003 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
1004 e51d7b55 2020-01-04 stsp
1005 e51d7b55 2020-01-04 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1006 e51d7b55 2020-01-04 stsp local orig_commit2=`git_show_head $testroot/repo`
1007 e51d7b55 2020-01-04 stsp
1008 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
1009 e51d7b55 2020-01-04 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1010 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to zeta on master"
1011 e51d7b55 2020-01-04 stsp local master_commit1=`git_show_head $testroot/repo`
1012 e51d7b55 2020-01-04 stsp
1013 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
1014 e51d7b55 2020-01-04 stsp echo "modified beta on master" > $testroot/repo/beta
1015 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to beta on master"
1016 e51d7b55 2020-01-04 stsp local master_commit2=`git_show_head $testroot/repo`
1017 e51d7b55 2020-01-04 stsp
1018 e51d7b55 2020-01-04 stsp got checkout -c $master_commit1 $testroot/repo $testroot/wt \
1019 e51d7b55 2020-01-04 stsp > /dev/null
1020 e51d7b55 2020-01-04 stsp ret="$?"
1021 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
1022 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1023 e51d7b55 2020-01-04 stsp return 1
1024 e51d7b55 2020-01-04 stsp fi
1025 e51d7b55 2020-01-04 stsp
1026 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
1027 e51d7b55 2020-01-04 stsp 2> $testroot/stderr)
1028 e51d7b55 2020-01-04 stsp
1029 e51d7b55 2020-01-04 stsp echo -n > $testroot/stdout.expected
1030 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1031 e51d7b55 2020-01-04 stsp ret="$?"
1032 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
1033 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
1034 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1035 e51d7b55 2020-01-04 stsp return 1
1036 e51d7b55 2020-01-04 stsp fi
1037 e51d7b55 2020-01-04 stsp
1038 e51d7b55 2020-01-04 stsp echo -n "got: work tree must be updated before it can be " \
1039 e51d7b55 2020-01-04 stsp > $testroot/stderr.expected
1040 e51d7b55 2020-01-04 stsp echo "used to rebase a branch" >> $testroot/stderr.expected
1041 e51d7b55 2020-01-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1042 e51d7b55 2020-01-04 stsp ret="$?"
1043 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
1044 e51d7b55 2020-01-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
1045 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1046 e51d7b55 2020-01-04 stsp return 1
1047 e51d7b55 2020-01-04 stsp fi
1048 e51d7b55 2020-01-04 stsp
1049 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1050 e51d7b55 2020-01-04 stsp echo "commit $master_commit2 (master)" > $testroot/stdout.expected
1051 e51d7b55 2020-01-04 stsp echo "commit $master_commit1" >> $testroot/stdout.expected
1052 e51d7b55 2020-01-04 stsp echo "commit $initial_commit" >> $testroot/stdout.expected
1053 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1054 1ae0a341 2020-02-14 stsp ret="$?"
1055 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1056 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1057 1ae0a341 2020-02-14 stsp fi
1058 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1059 1ae0a341 2020-02-14 stsp }
1060 1ae0a341 2020-02-14 stsp
1061 f6cae3ed 2020-09-13 naddy test_rebase_trims_empty_dir() {
1062 1ae0a341 2020-02-14 stsp local testroot=`test_init rebase_trims_empty_dir`
1063 1ae0a341 2020-02-14 stsp
1064 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1065 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1066 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1067 1ae0a341 2020-02-14 stsp
1068 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git rm -q epsilon/zeta)
1069 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "removing zeta on newbranch"
1070 1ae0a341 2020-02-14 stsp
1071 1ae0a341 2020-02-14 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1072 1ae0a341 2020-02-14 stsp local orig_commit2=`git_show_head $testroot/repo`
1073 1ae0a341 2020-02-14 stsp
1074 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q master)
1075 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/repo/alpha
1076 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to alpha on master"
1077 1ae0a341 2020-02-14 stsp local master_commit=`git_show_head $testroot/repo`
1078 1ae0a341 2020-02-14 stsp
1079 1ae0a341 2020-02-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1080 1ae0a341 2020-02-14 stsp ret="$?"
1081 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1082 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1083 1ae0a341 2020-02-14 stsp return 1
1084 1ae0a341 2020-02-14 stsp fi
1085 1ae0a341 2020-02-14 stsp
1086 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1087 1ae0a341 2020-02-14 stsp
1088 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q newbranch)
1089 1ae0a341 2020-02-14 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
1090 1ae0a341 2020-02-14 stsp local new_commit2=`git_show_head $testroot/repo`
1091 1ae0a341 2020-02-14 stsp
1092 1ae0a341 2020-02-14 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1093 1ae0a341 2020-02-14 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1094 1ae0a341 2020-02-14 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1095 1ae0a341 2020-02-14 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1096 1ae0a341 2020-02-14 stsp
1097 1ae0a341 2020-02-14 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1098 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1099 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1100 1ae0a341 2020-02-14 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1101 1ae0a341 2020-02-14 stsp echo "D epsilon/zeta" >> $testroot/stdout.expected
1102 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1103 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1104 1ae0a341 2020-02-14 stsp echo ": removing zeta on newbranch" \
1105 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1106 1ae0a341 2020-02-14 stsp echo "Switching work tree to refs/heads/newbranch" \
1107 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1108 1ae0a341 2020-02-14 stsp
1109 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1110 e51d7b55 2020-01-04 stsp ret="$?"
1111 e51d7b55 2020-01-04 stsp if [ "$ret" != "0" ]; then
1112 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
1113 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1114 1ae0a341 2020-02-14 stsp return 1
1115 e51d7b55 2020-01-04 stsp fi
1116 1ae0a341 2020-02-14 stsp
1117 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/content.expected
1118 1ae0a341 2020-02-14 stsp cat $testroot/wt/gamma/delta > $testroot/content
1119 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1120 1ae0a341 2020-02-14 stsp ret="$?"
1121 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1122 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1123 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1124 1ae0a341 2020-02-14 stsp return 1
1125 1ae0a341 2020-02-14 stsp fi
1126 1ae0a341 2020-02-14 stsp
1127 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/content.expected
1128 1ae0a341 2020-02-14 stsp cat $testroot/wt/alpha > $testroot/content
1129 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1130 1ae0a341 2020-02-14 stsp ret="$?"
1131 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1132 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1133 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1134 1ae0a341 2020-02-14 stsp return 1
1135 1ae0a341 2020-02-14 stsp fi
1136 1ae0a341 2020-02-14 stsp
1137 1ae0a341 2020-02-14 stsp if [ -e $testroot/wt/epsilon ]; then
1138 1ae0a341 2020-02-14 stsp echo "parent of removed zeta still exists on disk" >&2
1139 1ae0a341 2020-02-14 stsp test_done "$testroot" "1"
1140 1ae0a341 2020-02-14 stsp return 1
1141 1ae0a341 2020-02-14 stsp fi
1142 1ae0a341 2020-02-14 stsp
1143 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got status > $testroot/stdout)
1144 1ae0a341 2020-02-14 stsp
1145 1ae0a341 2020-02-14 stsp echo -n > $testroot/stdout.expected
1146 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1147 1ae0a341 2020-02-14 stsp ret="$?"
1148 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1149 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1150 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1151 1ae0a341 2020-02-14 stsp return 1
1152 1ae0a341 2020-02-14 stsp fi
1153 1ae0a341 2020-02-14 stsp
1154 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1155 1ae0a341 2020-02-14 stsp echo "commit $new_commit2 (newbranch)" > $testroot/stdout.expected
1156 1ae0a341 2020-02-14 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1157 1ae0a341 2020-02-14 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1158 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1159 1ae0a341 2020-02-14 stsp ret="$?"
1160 1ae0a341 2020-02-14 stsp if [ "$ret" != "0" ]; then
1161 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1162 1ae0a341 2020-02-14 stsp fi
1163 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1164 e51d7b55 2020-01-04 stsp }
1165 ca6da77d 2020-03-22 stsp
1166 f6cae3ed 2020-09-13 naddy test_rebase_delete_missing_file() {
1167 ca6da77d 2020-03-22 stsp local testroot=`test_init rebase_delete_missing_file`
1168 ca6da77d 2020-03-22 stsp
1169 ca6da77d 2020-03-22 stsp mkdir -p $testroot/repo/d/f/g
1170 ca6da77d 2020-03-22 stsp echo "new file" > $testroot/repo/d/f/g/new
1171 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git add d/f/g/new)
1172 ca6da77d 2020-03-22 stsp git_commit $testroot/repo -m "adding a subdir"
1173 ca6da77d 2020-03-22 stsp local commit0=`git_show_head $testroot/repo`
1174 ca6da77d 2020-03-22 stsp
1175 a740a1b3 2020-03-22 stsp got br -r $testroot/repo -c master newbranch
1176 a740a1b3 2020-03-22 stsp
1177 a740a1b3 2020-03-22 stsp got checkout -b newbranch $testroot/repo $testroot/wt > /dev/null
1178 ca6da77d 2020-03-22 stsp
1179 a740a1b3 2020-03-22 stsp echo "modified delta on branch" > $testroot/wt/gamma/delta
1180 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1181 a740a1b3 2020-03-22 stsp -m "committing to delta on newbranch" > /dev/null)
1182 ca6da77d 2020-03-22 stsp
1183 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1184 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1185 a740a1b3 2020-03-22 stsp -m "removing beta and d/f/g/new on newbranch" > /dev/null)
1186 a740a1b3 2020-03-22 stsp
1187 a740a1b3 2020-03-22 stsp (cd $testroot/repo && git checkout -q newbranch)
1188 ca6da77d 2020-03-22 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1189 ca6da77d 2020-03-22 stsp local orig_commit2=`git_show_head $testroot/repo`
1190 bb494413 2021-09-28 thomas
1191 bb494413 2021-09-28 thomas local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1192 bb494413 2021-09-28 thomas local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1193 ca6da77d 2020-03-22 stsp
1194 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got update -b master > /dev/null)
1195 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1196 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1197 a740a1b3 2020-03-22 stsp -m "removing beta and d/f/g/new on master" > /dev/null)
1198 a740a1b3 2020-03-22 stsp
1199 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git checkout -q master)
1200 ca6da77d 2020-03-22 stsp local master_commit=`git_show_head $testroot/repo`
1201 ca6da77d 2020-03-22 stsp
1202 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got update -b master > /dev/null)
1203 bb494413 2021-09-28 thomas (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
1204 bb494413 2021-09-28 thomas 2> $testroot/stderr)
1205 bb494413 2021-09-28 thomas ret="$?"
1206 bb494413 2021-09-28 thomas if [ "$ret" = "0" ]; then
1207 bb494413 2021-09-28 thomas echo "rebase succeeded unexpectedly" >&2
1208 bb494413 2021-09-28 thomas test_done "$testroot" "1"
1209 bb494413 2021-09-28 thomas return 1
1210 bb494413 2021-09-28 thomas fi
1211 ca6da77d 2020-03-22 stsp
1212 bb494413 2021-09-28 thomas local new_commit1=$(cd $testroot/wt && got info | \
1213 bb494413 2021-09-28 thomas grep '^work tree base commit: ' | cut -d: -f2 | tr -d ' ')
1214 ca6da77d 2020-03-22 stsp
1215 ca6da77d 2020-03-22 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1216 ca6da77d 2020-03-22 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1217 ca6da77d 2020-03-22 stsp
1218 ca6da77d 2020-03-22 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1219 ca6da77d 2020-03-22 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1220 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1221 ca6da77d 2020-03-22 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1222 ca6da77d 2020-03-22 stsp echo "! beta" >> $testroot/stdout.expected
1223 ca6da77d 2020-03-22 stsp echo "! d/f/g/new" >> $testroot/stdout.expected
1224 0ef68859 2021-09-28 thomas echo -n "Files which had incoming changes but could not be found " \
1225 0ef68859 2021-09-28 thomas >> $testroot/stdout.expected
1226 0ef68859 2021-09-28 thomas echo "in the work tree: 2" >> $testroot/stdout.expected
1227 bb494413 2021-09-28 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1228 bb494413 2021-09-28 thomas ret="$?"
1229 bb494413 2021-09-28 thomas if [ "$ret" != "0" ]; then
1230 bb494413 2021-09-28 thomas diff -u $testroot/stdout.expected $testroot/stdout
1231 bb494413 2021-09-28 thomas test_done "$testroot" "$ret"
1232 bb494413 2021-09-28 thomas return 1
1233 bb494413 2021-09-28 thomas fi
1234 bb494413 2021-09-28 thomas
1235 bb494413 2021-09-28 thomas echo -n "got: changes destined for some files were not yet merged " \
1236 bb494413 2021-09-28 thomas > $testroot/stderr.expected
1237 bb494413 2021-09-28 thomas echo -n "and should be merged manually if required before the " \
1238 bb494413 2021-09-28 thomas >> $testroot/stderr.expected
1239 bb494413 2021-09-28 thomas echo "rebase operation is continued" >> $testroot/stderr.expected
1240 bb494413 2021-09-28 thomas cmp -s $testroot/stderr.expected $testroot/stderr
1241 bb494413 2021-09-28 thomas ret="$?"
1242 bb494413 2021-09-28 thomas if [ "$ret" != "0" ]; then
1243 bb494413 2021-09-28 thomas diff -u $testroot/stderr.expected $testroot/stderr
1244 bb494413 2021-09-28 thomas test_done "$testroot" "$ret"
1245 bb494413 2021-09-28 thomas return 1
1246 bb494413 2021-09-28 thomas fi
1247 bb494413 2021-09-28 thomas
1248 bb494413 2021-09-28 thomas # ignore the missing changes and continue
1249 bb494413 2021-09-28 thomas (cd $testroot/wt && got rebase -c > $testroot/stdout)
1250 bb494413 2021-09-28 thomas ret="$?"
1251 bb494413 2021-09-28 thomas if [ "$ret" != "0" ]; then
1252 bb494413 2021-09-28 thomas echo "rebase failed unexpectedly" >&2
1253 bb494413 2021-09-28 thomas test_done "$testroot" "1"
1254 bb494413 2021-09-28 thomas return 1
1255 bb494413 2021-09-28 thomas fi
1256 ca6da77d 2020-03-22 stsp echo -n "$short_orig_commit2 -> no-op change" \
1257 bb494413 2021-09-28 thomas > $testroot/stdout.expected
1258 a740a1b3 2020-03-22 stsp echo ": removing beta and d/f/g/new on newbranch" \
1259 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1260 ca6da77d 2020-03-22 stsp echo "Switching work tree to refs/heads/newbranch" \
1261 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1262 ca6da77d 2020-03-22 stsp
1263 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1264 ca6da77d 2020-03-22 stsp ret="$?"
1265 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1266 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1267 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1268 ca6da77d 2020-03-22 stsp return 1
1269 ca6da77d 2020-03-22 stsp fi
1270 ca6da77d 2020-03-22 stsp
1271 ca6da77d 2020-03-22 stsp echo "modified delta on branch" > $testroot/content.expected
1272 ca6da77d 2020-03-22 stsp cat $testroot/wt/gamma/delta > $testroot/content
1273 ca6da77d 2020-03-22 stsp cmp -s $testroot/content.expected $testroot/content
1274 ca6da77d 2020-03-22 stsp ret="$?"
1275 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1276 ca6da77d 2020-03-22 stsp diff -u $testroot/content.expected $testroot/content
1277 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1278 ca6da77d 2020-03-22 stsp return 1
1279 ca6da77d 2020-03-22 stsp fi
1280 ca6da77d 2020-03-22 stsp
1281 ca6da77d 2020-03-22 stsp if [ -e $testroot/wt/beta ]; then
1282 ca6da77d 2020-03-22 stsp echo "removed file beta still exists on disk" >&2
1283 ca6da77d 2020-03-22 stsp test_done "$testroot" "1"
1284 ca6da77d 2020-03-22 stsp return 1
1285 ca6da77d 2020-03-22 stsp fi
1286 ca6da77d 2020-03-22 stsp
1287 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got status > $testroot/stdout)
1288 ca6da77d 2020-03-22 stsp
1289 ca6da77d 2020-03-22 stsp echo -n > $testroot/stdout.expected
1290 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1291 ca6da77d 2020-03-22 stsp ret="$?"
1292 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1293 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1294 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1295 ca6da77d 2020-03-22 stsp return 1
1296 ca6da77d 2020-03-22 stsp fi
1297 ca6da77d 2020-03-22 stsp
1298 bb494413 2021-09-28 thomas (cd $testroot/repo && git checkout -q newbranch)
1299 bb494413 2021-09-28 thomas local new_commit1=`git_show_head $testroot/repo`
1300 bb494413 2021-09-28 thomas local short_new_commit1=`trim_obj_id 28 $new_commit1`
1301 bb494413 2021-09-28 thomas
1302 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1303 ca6da77d 2020-03-22 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
1304 ca6da77d 2020-03-22 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1305 ca6da77d 2020-03-22 stsp echo "commit $commit0" >> $testroot/stdout.expected
1306 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1307 70551d57 2020-04-24 stsp ret="$?"
1308 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1309 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1310 70551d57 2020-04-24 stsp fi
1311 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1312 70551d57 2020-04-24 stsp }
1313 70551d57 2020-04-24 stsp
1314 f6cae3ed 2020-09-13 naddy test_rebase_rm_add_rm_file() {
1315 70551d57 2020-04-24 stsp local testroot=`test_init rebase_rm_add_rm_file`
1316 70551d57 2020-04-24 stsp
1317 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1318 70551d57 2020-04-24 stsp (cd $testroot/repo && git rm -q beta)
1319 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "removing beta from newbranch"
1320 70551d57 2020-04-24 stsp local orig_commit1=`git_show_head $testroot/repo`
1321 70551d57 2020-04-24 stsp
1322 70551d57 2020-04-24 stsp echo 'restored beta' > $testroot/repo/beta
1323 70551d57 2020-04-24 stsp (cd $testroot/repo && git add beta)
1324 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "restoring beta on newbranch"
1325 70551d57 2020-04-24 stsp local orig_commit2=`git_show_head $testroot/repo`
1326 70551d57 2020-04-24 stsp
1327 70551d57 2020-04-24 stsp (cd $testroot/repo && git rm -q beta)
1328 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "removing beta from newbranch again"
1329 70551d57 2020-04-24 stsp local orig_commit3=`git_show_head $testroot/repo`
1330 70551d57 2020-04-24 stsp
1331 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q master)
1332 70551d57 2020-04-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1333 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
1334 70551d57 2020-04-24 stsp local master_commit=`git_show_head $testroot/repo`
1335 70551d57 2020-04-24 stsp
1336 70551d57 2020-04-24 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1337 70551d57 2020-04-24 stsp ret="$?"
1338 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1339 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1340 70551d57 2020-04-24 stsp return 1
1341 70551d57 2020-04-24 stsp fi
1342 70551d57 2020-04-24 stsp
1343 70551d57 2020-04-24 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1344 70551d57 2020-04-24 stsp
1345 70551d57 2020-04-24 stsp # this would error out with 'got: file index is corrupt'
1346 70551d57 2020-04-24 stsp (cd $testroot/wt && got status > /dev/null)
1347 70551d57 2020-04-24 stsp ret="$?"
1348 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1349 70551d57 2020-04-24 stsp echo "got status command failed unexpectedly" >&2
1350 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1351 70551d57 2020-04-24 stsp return 1
1352 70551d57 2020-04-24 stsp fi
1353 70551d57 2020-04-24 stsp
1354 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q newbranch)
1355 70551d57 2020-04-24 stsp local new_commit3=`git_show_head $testroot/repo`
1356 70551d57 2020-04-24 stsp local new_commit2=`git_show_parent_commit $testroot/repo`
1357 70551d57 2020-04-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo $new_commit2`
1358 70551d57 2020-04-24 stsp
1359 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q newbranch)
1360 70551d57 2020-04-24 stsp
1361 70551d57 2020-04-24 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1362 70551d57 2020-04-24 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1363 70551d57 2020-04-24 stsp local short_orig_commit3=`trim_obj_id 28 $orig_commit3`
1364 70551d57 2020-04-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1365 70551d57 2020-04-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1366 70551d57 2020-04-24 stsp local short_new_commit3=`trim_obj_id 28 $new_commit3`
1367 70551d57 2020-04-24 stsp
1368 70551d57 2020-04-24 stsp echo "D beta" > $testroot/stdout.expected
1369 70551d57 2020-04-24 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1370 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1371 70551d57 2020-04-24 stsp echo ": removing beta from newbranch" >> $testroot/stdout.expected
1372 70551d57 2020-04-24 stsp echo "A beta" >> $testroot/stdout.expected
1373 70551d57 2020-04-24 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1374 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1375 70551d57 2020-04-24 stsp echo ": restoring beta on newbranch" >> $testroot/stdout.expected
1376 70551d57 2020-04-24 stsp echo "D beta" >> $testroot/stdout.expected
1377 70551d57 2020-04-24 stsp echo -n "$short_orig_commit3 -> $short_new_commit3" \
1378 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1379 70551d57 2020-04-24 stsp echo ": removing beta from newbranch again" >> $testroot/stdout.expected
1380 70551d57 2020-04-24 stsp echo "Switching work tree to refs/heads/newbranch" \
1381 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1382 70551d57 2020-04-24 stsp
1383 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1384 ca6da77d 2020-03-22 stsp ret="$?"
1385 ca6da77d 2020-03-22 stsp if [ "$ret" != "0" ]; then
1386 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1387 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1388 70551d57 2020-04-24 stsp return 1
1389 ca6da77d 2020-03-22 stsp fi
1390 70551d57 2020-04-24 stsp
1391 70551d57 2020-04-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1392 70551d57 2020-04-24 stsp ret="$?"
1393 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1394 70551d57 2020-04-24 stsp echo "got status command failed unexpectedly" >&2
1395 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1396 70551d57 2020-04-24 stsp return 1
1397 70551d57 2020-04-24 stsp fi
1398 70551d57 2020-04-24 stsp
1399 70551d57 2020-04-24 stsp echo -n > $testroot/stdout.expected
1400 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1401 70551d57 2020-04-24 stsp ret="$?"
1402 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1403 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1404 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1405 70551d57 2020-04-24 stsp return 1
1406 70551d57 2020-04-24 stsp fi
1407 70551d57 2020-04-24 stsp
1408 70551d57 2020-04-24 stsp (cd $testroot/wt && got log -l4 | grep ^commit > $testroot/stdout)
1409 70551d57 2020-04-24 stsp echo "commit $new_commit3 (newbranch)" > $testroot/stdout.expected
1410 70551d57 2020-04-24 stsp echo "commit $new_commit2" >> $testroot/stdout.expected
1411 70551d57 2020-04-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1412 70551d57 2020-04-24 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1413 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1414 70551d57 2020-04-24 stsp ret="$?"
1415 70551d57 2020-04-24 stsp if [ "$ret" != "0" ]; then
1416 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1417 70551d57 2020-04-24 stsp fi
1418 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1419 ca6da77d 2020-03-22 stsp }
1420 ca6da77d 2020-03-22 stsp
1421 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1422 dcf44d04 2019-07-11 stsp run_test test_rebase_basic
1423 dcf44d04 2019-07-11 stsp run_test test_rebase_ancestry_check
1424 dcf44d04 2019-07-11 stsp run_test test_rebase_continue
1425 dcf44d04 2019-07-11 stsp run_test test_rebase_abort
1426 ff0d2220 2019-07-11 stsp run_test test_rebase_no_op_change
1427 7d5807f4 2019-07-11 stsp run_test test_rebase_in_progress
1428 64c6d990 2019-07-11 stsp run_test test_rebase_path_prefix
1429 787c8eb6 2019-07-11 stsp run_test test_rebase_preserves_logmsg
1430 fc66b545 2019-08-12 stsp run_test test_rebase_no_commits_to_rebase
1431 38b0338b 2019-11-29 stsp run_test test_rebase_forward
1432 e51d7b55 2020-01-04 stsp run_test test_rebase_out_of_date
1433 1ae0a341 2020-02-14 stsp run_test test_rebase_trims_empty_dir
1434 ca6da77d 2020-03-22 stsp run_test test_rebase_delete_missing_file
1435 70551d57 2020-04-24 stsp run_test test_rebase_rm_add_rm_file