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