Blame


1 818c7501 2019-07-11 stsp #!/bin/sh
2 818c7501 2019-07-11 stsp #
3 818c7501 2019-07-11 stsp # Copyright (c) 2019 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 818c7501 2019-07-11 stsp function 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 818c7501 2019-07-11 stsp fi
136 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
137 818c7501 2019-07-11 stsp }
138 818c7501 2019-07-11 stsp
139 818c7501 2019-07-11 stsp function test_rebase_ancestry_check {
140 818c7501 2019-07-11 stsp local testroot=`test_init rebase_ancestry_check`
141 818c7501 2019-07-11 stsp
142 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
143 818c7501 2019-07-11 stsp ret="$?"
144 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
145 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
146 818c7501 2019-07-11 stsp return 1
147 818c7501 2019-07-11 stsp fi
148 818c7501 2019-07-11 stsp
149 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
150 818c7501 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
151 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
152 818c7501 2019-07-11 stsp
153 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
154 818c7501 2019-07-11 stsp 2> $testroot/stderr)
155 818c7501 2019-07-11 stsp
156 818c7501 2019-07-11 stsp echo -n > $testroot/stdout.expected
157 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
158 818c7501 2019-07-11 stsp ret="$?"
159 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
160 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
161 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
162 818c7501 2019-07-11 stsp return 1
163 818c7501 2019-07-11 stsp fi
164 818c7501 2019-07-11 stsp
165 818c7501 2019-07-11 stsp echo -n "got: specified branch resolves to a commit " \
166 818c7501 2019-07-11 stsp > $testroot/stderr.expected
167 818c7501 2019-07-11 stsp echo "which is already contained in work tree's branch" \
168 818c7501 2019-07-11 stsp >> $testroot/stderr.expected
169 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
170 818c7501 2019-07-11 stsp ret="$?"
171 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
172 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
173 818c7501 2019-07-11 stsp fi
174 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
175 818c7501 2019-07-11 stsp }
176 818c7501 2019-07-11 stsp
177 818c7501 2019-07-11 stsp function test_rebase_continue {
178 818c7501 2019-07-11 stsp local testroot=`test_init rebase_continue`
179 818c7501 2019-07-11 stsp
180 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
181 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
182 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
183 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
184 818c7501 2019-07-11 stsp
185 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
186 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
187 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
188 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
189 818c7501 2019-07-11 stsp
190 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
191 818c7501 2019-07-11 stsp ret="$?"
192 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
193 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
194 818c7501 2019-07-11 stsp return 1
195 818c7501 2019-07-11 stsp fi
196 818c7501 2019-07-11 stsp
197 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
198 818c7501 2019-07-11 stsp 2> $testroot/stderr)
199 818c7501 2019-07-11 stsp
200 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
201 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
202 818c7501 2019-07-11 stsp ret="$?"
203 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
204 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
205 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
206 818c7501 2019-07-11 stsp return 1
207 818c7501 2019-07-11 stsp fi
208 818c7501 2019-07-11 stsp
209 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
210 818c7501 2019-07-11 stsp > $testroot/stderr.expected
211 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
212 818c7501 2019-07-11 stsp ret="$?"
213 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
214 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
215 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
216 818c7501 2019-07-11 stsp return 1
217 818c7501 2019-07-11 stsp fi
218 818c7501 2019-07-11 stsp
219 818c7501 2019-07-11 stsp echo "<<<<<<< commit $orig_commit1" > $testroot/content.expected
220 818c7501 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
221 d136cfcb 2019-10-12 stsp echo "|||||||" >> $testroot/content.expected
222 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
223 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
224 818c7501 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
225 818c7501 2019-07-11 stsp echo '>>>>>>> alpha' >> $testroot/content.expected
226 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
227 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
228 818c7501 2019-07-11 stsp ret="$?"
229 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
230 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
231 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
232 818c7501 2019-07-11 stsp return 1
233 818c7501 2019-07-11 stsp fi
234 818c7501 2019-07-11 stsp
235 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
236 818c7501 2019-07-11 stsp
237 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
238 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
239 818c7501 2019-07-11 stsp ret="$?"
240 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
241 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
242 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
243 818c7501 2019-07-11 stsp return 1
244 818c7501 2019-07-11 stsp fi
245 818c7501 2019-07-11 stsp
246 818c7501 2019-07-11 stsp # resolve the conflict
247 818c7501 2019-07-11 stsp echo "modified alpha on branch and master" > $testroot/wt/alpha
248 818c7501 2019-07-11 stsp
249 f032f1f7 2019-08-04 stsp # test interaction of 'got stage' and rebase -c
250 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got stage alpha > /dev/null)
251 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout \
252 f032f1f7 2019-08-04 stsp 2> $testroot/stderr)
253 f032f1f7 2019-08-04 stsp ret="$?"
254 f032f1f7 2019-08-04 stsp if [ "$ret" == "0" ]; then
255 f032f1f7 2019-08-04 stsp echo "rebase succeeded unexpectedly" >&2
256 f032f1f7 2019-08-04 stsp test_done "$testroot" "1"
257 f032f1f7 2019-08-04 stsp return 1
258 f032f1f7 2019-08-04 stsp fi
259 f032f1f7 2019-08-04 stsp echo -n "got: work tree contains files with staged changes; " \
260 f032f1f7 2019-08-04 stsp > $testroot/stderr.expected
261 f032f1f7 2019-08-04 stsp echo "these changes must be committed or unstaged first" \
262 f032f1f7 2019-08-04 stsp >> $testroot/stderr.expected
263 f032f1f7 2019-08-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
264 f032f1f7 2019-08-04 stsp ret="$?"
265 f032f1f7 2019-08-04 stsp if [ "$ret" != "0" ]; then
266 f032f1f7 2019-08-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
267 f032f1f7 2019-08-04 stsp test_done "$testroot" "$ret"
268 f032f1f7 2019-08-04 stsp return 1
269 f032f1f7 2019-08-04 stsp fi
270 f032f1f7 2019-08-04 stsp
271 f032f1f7 2019-08-04 stsp (cd $testroot/wt && got unstage alpha > /dev/null)
272 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
273 818c7501 2019-07-11 stsp
274 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
275 818c7501 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
276 818c7501 2019-07-11 stsp
277 818c7501 2019-07-11 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
278 818c7501 2019-07-11 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
279 818c7501 2019-07-11 stsp
280 818c7501 2019-07-11 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
281 818c7501 2019-07-11 stsp > $testroot/stdout.expected
282 818c7501 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
283 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
284 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
285 818c7501 2019-07-11 stsp
286 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
287 818c7501 2019-07-11 stsp ret="$?"
288 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
289 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
290 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
291 818c7501 2019-07-11 stsp return 1
292 818c7501 2019-07-11 stsp fi
293 818c7501 2019-07-11 stsp
294 818c7501 2019-07-11 stsp
295 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
296 818c7501 2019-07-11 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
297 818c7501 2019-07-11 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
298 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
299 818c7501 2019-07-11 stsp ret="$?"
300 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
301 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
302 818c7501 2019-07-11 stsp fi
303 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
304 818c7501 2019-07-11 stsp }
305 818c7501 2019-07-11 stsp
306 818c7501 2019-07-11 stsp function test_rebase_abort {
307 818c7501 2019-07-11 stsp local testroot=`test_init rebase_abort`
308 818c7501 2019-07-11 stsp
309 818c7501 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
310 818c7501 2019-07-11 stsp
311 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
312 818c7501 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
313 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
314 818c7501 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
315 818c7501 2019-07-11 stsp
316 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
317 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
318 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
319 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
320 818c7501 2019-07-11 stsp
321 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
322 818c7501 2019-07-11 stsp ret="$?"
323 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
324 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
325 818c7501 2019-07-11 stsp return 1
326 818c7501 2019-07-11 stsp fi
327 818c7501 2019-07-11 stsp
328 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
329 818c7501 2019-07-11 stsp 2> $testroot/stderr)
330 818c7501 2019-07-11 stsp
331 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
332 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
333 818c7501 2019-07-11 stsp ret="$?"
334 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
335 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
336 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
337 818c7501 2019-07-11 stsp return 1
338 818c7501 2019-07-11 stsp fi
339 818c7501 2019-07-11 stsp
340 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
341 818c7501 2019-07-11 stsp > $testroot/stderr.expected
342 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
343 818c7501 2019-07-11 stsp ret="$?"
344 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
345 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
346 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
347 818c7501 2019-07-11 stsp return 1
348 818c7501 2019-07-11 stsp fi
349 818c7501 2019-07-11 stsp
350 818c7501 2019-07-11 stsp echo "<<<<<<< commit $orig_commit1" > $testroot/content.expected
351 818c7501 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
352 d136cfcb 2019-10-12 stsp echo "|||||||" >> $testroot/content.expected
353 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
354 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
355 818c7501 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
356 818c7501 2019-07-11 stsp echo '>>>>>>> alpha' >> $testroot/content.expected
357 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
358 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
359 818c7501 2019-07-11 stsp ret="$?"
360 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
361 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
362 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
363 818c7501 2019-07-11 stsp return 1
364 818c7501 2019-07-11 stsp fi
365 818c7501 2019-07-11 stsp
366 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
367 818c7501 2019-07-11 stsp
368 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
369 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
370 818c7501 2019-07-11 stsp ret="$?"
371 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
372 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
373 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
374 818c7501 2019-07-11 stsp return 1
375 818c7501 2019-07-11 stsp fi
376 818c7501 2019-07-11 stsp
377 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -a > $testroot/stdout)
378 818c7501 2019-07-11 stsp
379 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
380 818c7501 2019-07-11 stsp
381 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/master" \
382 818c7501 2019-07-11 stsp > $testroot/stdout.expected
383 818c7501 2019-07-11 stsp echo 'R alpha' >> $testroot/stdout.expected
384 818c7501 2019-07-11 stsp echo "Rebase of refs/heads/newbranch aborted" \
385 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
386 818c7501 2019-07-11 stsp
387 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
388 818c7501 2019-07-11 stsp ret="$?"
389 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
390 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
391 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
392 818c7501 2019-07-11 stsp return 1
393 818c7501 2019-07-11 stsp fi
394 818c7501 2019-07-11 stsp
395 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/content.expected
396 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
397 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
398 818c7501 2019-07-11 stsp ret="$?"
399 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
400 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
401 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
402 818c7501 2019-07-11 stsp return 1
403 818c7501 2019-07-11 stsp fi
404 818c7501 2019-07-11 stsp
405 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l3 -c newbranch \
406 818c7501 2019-07-11 stsp | grep ^commit > $testroot/stdout)
407 818c7501 2019-07-11 stsp echo "commit $orig_commit1 (newbranch)" > $testroot/stdout.expected
408 818c7501 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
409 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
410 818c7501 2019-07-11 stsp ret="$?"
411 818c7501 2019-07-11 stsp if [ "$ret" != "0" ]; then
412 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
413 818c7501 2019-07-11 stsp fi
414 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
415 818c7501 2019-07-11 stsp }
416 818c7501 2019-07-11 stsp
417 ff0d2220 2019-07-11 stsp function test_rebase_no_op_change {
418 ff0d2220 2019-07-11 stsp local testroot=`test_init rebase_no_op_change`
419 ff0d2220 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
420 ff0d2220 2019-07-11 stsp
421 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
422 ff0d2220 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
423 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
424 ff0d2220 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
425 ff0d2220 2019-07-11 stsp
426 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
427 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
428 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
429 ff0d2220 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
430 ff0d2220 2019-07-11 stsp
431 ff0d2220 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
432 ff0d2220 2019-07-11 stsp ret="$?"
433 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
434 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
435 ff0d2220 2019-07-11 stsp return 1
436 ff0d2220 2019-07-11 stsp fi
437 ff0d2220 2019-07-11 stsp
438 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
439 ff0d2220 2019-07-11 stsp 2> $testroot/stderr)
440 ff0d2220 2019-07-11 stsp
441 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
442 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
443 ff0d2220 2019-07-11 stsp ret="$?"
444 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
445 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
446 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
447 ff0d2220 2019-07-11 stsp return 1
448 ff0d2220 2019-07-11 stsp fi
449 ff0d2220 2019-07-11 stsp
450 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
451 ff0d2220 2019-07-11 stsp > $testroot/stderr.expected
452 ff0d2220 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
453 ff0d2220 2019-07-11 stsp ret="$?"
454 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
455 ff0d2220 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
456 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
457 ff0d2220 2019-07-11 stsp return 1
458 ff0d2220 2019-07-11 stsp fi
459 ff0d2220 2019-07-11 stsp
460 ff0d2220 2019-07-11 stsp echo "<<<<<<< commit $orig_commit1" > $testroot/content.expected
461 ff0d2220 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
462 d136cfcb 2019-10-12 stsp echo "|||||||" >> $testroot/content.expected
463 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
464 ff0d2220 2019-07-11 stsp echo "=======" >> $testroot/content.expected
465 ff0d2220 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
466 ff0d2220 2019-07-11 stsp echo '>>>>>>> alpha' >> $testroot/content.expected
467 ff0d2220 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
468 ff0d2220 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
469 ff0d2220 2019-07-11 stsp ret="$?"
470 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
471 ff0d2220 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
472 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
473 ff0d2220 2019-07-11 stsp return 1
474 ff0d2220 2019-07-11 stsp fi
475 ff0d2220 2019-07-11 stsp
476 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
477 ff0d2220 2019-07-11 stsp
478 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
479 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
480 ff0d2220 2019-07-11 stsp ret="$?"
481 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
482 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
483 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
484 ff0d2220 2019-07-11 stsp return 1
485 ff0d2220 2019-07-11 stsp fi
486 ff0d2220 2019-07-11 stsp
487 ff0d2220 2019-07-11 stsp # resolve the conflict
488 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/wt/alpha
489 ff0d2220 2019-07-11 stsp
490 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
491 ff0d2220 2019-07-11 stsp
492 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
493 ff0d2220 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
494 ff0d2220 2019-07-11 stsp
495 ff0d2220 2019-07-11 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
496 ff0d2220 2019-07-11 stsp
497 ff0d2220 2019-07-11 stsp echo -n "$short_orig_commit1 -> no-op change" \
498 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
499 ff0d2220 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
500 ff0d2220 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
501 ff0d2220 2019-07-11 stsp >> $testroot/stdout.expected
502 ff0d2220 2019-07-11 stsp
503 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
504 ff0d2220 2019-07-11 stsp ret="$?"
505 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
506 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
507 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
508 ff0d2220 2019-07-11 stsp return 1
509 ff0d2220 2019-07-11 stsp fi
510 ff0d2220 2019-07-11 stsp
511 ff0d2220 2019-07-11 stsp
512 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
513 ff0d2220 2019-07-11 stsp echo "commit $master_commit (master, newbranch)" \
514 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
515 ff0d2220 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
516 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
517 7d5807f4 2019-07-11 stsp ret="$?"
518 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
519 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
520 7d5807f4 2019-07-11 stsp fi
521 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
522 7d5807f4 2019-07-11 stsp }
523 7d5807f4 2019-07-11 stsp
524 7d5807f4 2019-07-11 stsp function test_rebase_in_progress {
525 4ba9c4f6 2019-07-11 stsp local testroot=`test_init rebase_in_progress`
526 7d5807f4 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
527 7d5807f4 2019-07-11 stsp
528 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
529 7d5807f4 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
530 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
531 7d5807f4 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
532 7d5807f4 2019-07-11 stsp
533 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
534 7d5807f4 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
535 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
536 7d5807f4 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
537 7d5807f4 2019-07-11 stsp
538 7d5807f4 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
539 7d5807f4 2019-07-11 stsp ret="$?"
540 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
541 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
542 7d5807f4 2019-07-11 stsp return 1
543 7d5807f4 2019-07-11 stsp fi
544 7d5807f4 2019-07-11 stsp
545 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
546 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
547 7d5807f4 2019-07-11 stsp
548 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
549 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
550 7d5807f4 2019-07-11 stsp ret="$?"
551 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
552 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
553 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
554 7d5807f4 2019-07-11 stsp return 1
555 7d5807f4 2019-07-11 stsp fi
556 7d5807f4 2019-07-11 stsp
557 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
558 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
559 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
560 7d5807f4 2019-07-11 stsp ret="$?"
561 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
562 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
563 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
564 7d5807f4 2019-07-11 stsp return 1
565 7d5807f4 2019-07-11 stsp fi
566 7d5807f4 2019-07-11 stsp
567 7d5807f4 2019-07-11 stsp echo "<<<<<<< commit $orig_commit1" > $testroot/content.expected
568 7d5807f4 2019-07-11 stsp echo "modified alpha on branch" >> $testroot/content.expected
569 d136cfcb 2019-10-12 stsp echo "|||||||" >> $testroot/content.expected
570 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
571 7d5807f4 2019-07-11 stsp echo "=======" >> $testroot/content.expected
572 7d5807f4 2019-07-11 stsp echo "modified alpha on master" >> $testroot/content.expected
573 7d5807f4 2019-07-11 stsp echo '>>>>>>> alpha' >> $testroot/content.expected
574 7d5807f4 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
575 7d5807f4 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
576 7d5807f4 2019-07-11 stsp ret="$?"
577 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
578 7d5807f4 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
579 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
580 7d5807f4 2019-07-11 stsp return 1
581 7d5807f4 2019-07-11 stsp fi
582 7d5807f4 2019-07-11 stsp
583 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
584 7d5807f4 2019-07-11 stsp
585 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
586 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
587 ff0d2220 2019-07-11 stsp ret="$?"
588 ff0d2220 2019-07-11 stsp if [ "$ret" != "0" ]; then
589 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
590 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
591 7d5807f4 2019-07-11 stsp return 1
592 ff0d2220 2019-07-11 stsp fi
593 7d5807f4 2019-07-11 stsp
594 7d5807f4 2019-07-11 stsp for cmd in update commit; do
595 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got $cmd > $testroot/stdout \
596 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
597 7d5807f4 2019-07-11 stsp
598 7d5807f4 2019-07-11 stsp echo -n > $testroot/stdout.expected
599 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
600 7d5807f4 2019-07-11 stsp ret="$?"
601 7d5807f4 2019-07-11 stsp if [ "$ret" != "0" ]; then
602 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
603 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
604 7d5807f4 2019-07-11 stsp return 1
605 7d5807f4 2019-07-11 stsp fi
606 7d5807f4 2019-07-11 stsp
607 7d5807f4 2019-07-11 stsp echo -n "got: a rebase operation is in progress in this " \
608 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
609 7d5807f4 2019-07-11 stsp echo "work tree and must be continued or aborted first" \
610 7d5807f4 2019-07-11 stsp >> $testroot/stderr.expected
611 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
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/stderr.expected $testroot/stderr
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 done
619 64c6d990 2019-07-11 stsp
620 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
621 64c6d990 2019-07-11 stsp }
622 64c6d990 2019-07-11 stsp
623 64c6d990 2019-07-11 stsp function test_rebase_path_prefix {
624 64c6d990 2019-07-11 stsp local testroot=`test_init rebase_path_prefix`
625 64c6d990 2019-07-11 stsp
626 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
627 64c6d990 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
628 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
629 64c6d990 2019-07-11 stsp
630 64c6d990 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
631 64c6d990 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
632 64c6d990 2019-07-11 stsp
633 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
634 64c6d990 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
635 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
636 64c6d990 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
637 64c6d990 2019-07-11 stsp
638 64c6d990 2019-07-11 stsp got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
639 64c6d990 2019-07-11 stsp ret="$?"
640 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
641 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
642 64c6d990 2019-07-11 stsp return 1
643 64c6d990 2019-07-11 stsp fi
644 7d5807f4 2019-07-11 stsp
645 64c6d990 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch \
646 64c6d990 2019-07-11 stsp > $testroot/stdout 2> $testroot/stderr)
647 64c6d990 2019-07-11 stsp
648 64c6d990 2019-07-11 stsp echo -n > $testroot/stdout.expected
649 64c6d990 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
650 64c6d990 2019-07-11 stsp ret="$?"
651 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
652 64c6d990 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
653 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
654 64c6d990 2019-07-11 stsp return 1
655 64c6d990 2019-07-11 stsp fi
656 64c6d990 2019-07-11 stsp
657 64c6d990 2019-07-11 stsp echo -n "got: cannot rebase branch which contains changes outside " \
658 64c6d990 2019-07-11 stsp > $testroot/stderr.expected
659 64c6d990 2019-07-11 stsp echo "of this work tree's path prefix" >> $testroot/stderr.expected
660 787c8eb6 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
661 787c8eb6 2019-07-11 stsp ret="$?"
662 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
663 787c8eb6 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
664 787c8eb6 2019-07-11 stsp fi
665 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
666 787c8eb6 2019-07-11 stsp }
667 787c8eb6 2019-07-11 stsp
668 787c8eb6 2019-07-11 stsp function test_rebase_preserves_logmsg {
669 787c8eb6 2019-07-11 stsp local testroot=`test_init rebase_preserves_logmsg`
670 787c8eb6 2019-07-11 stsp
671 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
672 787c8eb6 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
673 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified delta on newbranch"
674 787c8eb6 2019-07-11 stsp
675 787c8eb6 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
676 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified alpha on newbranch"
677 787c8eb6 2019-07-11 stsp
678 787c8eb6 2019-07-11 stsp (cd $testroot/repo && got log -c newbranch -l2 | grep -v ^date: \
679 787c8eb6 2019-07-11 stsp > $testroot/log.expected)
680 787c8eb6 2019-07-11 stsp
681 787c8eb6 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
682 787c8eb6 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
683 787c8eb6 2019-07-11 stsp
684 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
685 787c8eb6 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
686 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
687 787c8eb6 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
688 787c8eb6 2019-07-11 stsp
689 787c8eb6 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
690 787c8eb6 2019-07-11 stsp ret="$?"
691 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
692 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
693 787c8eb6 2019-07-11 stsp return 1
694 787c8eb6 2019-07-11 stsp fi
695 787c8eb6 2019-07-11 stsp
696 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > /dev/null \
697 787c8eb6 2019-07-11 stsp 2> $testroot/stderr)
698 787c8eb6 2019-07-11 stsp
699 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
700 787c8eb6 2019-07-11 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
701 787c8eb6 2019-07-11 stsp local new_commit2=`git_show_head $testroot/repo`
702 787c8eb6 2019-07-11 stsp
703 787c8eb6 2019-07-11 stsp echo -n > $testroot/stderr.expected
704 64c6d990 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
705 64c6d990 2019-07-11 stsp ret="$?"
706 64c6d990 2019-07-11 stsp if [ "$ret" != "0" ]; then
707 64c6d990 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
708 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
709 787c8eb6 2019-07-11 stsp return 1
710 64c6d990 2019-07-11 stsp fi
711 787c8eb6 2019-07-11 stsp
712 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got log -c newbranch -l2 | grep -v ^date: \
713 787c8eb6 2019-07-11 stsp > $testroot/log)
714 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit1/$new_commit1/" $testroot/log.expected
715 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit2/$new_commit2/" $testroot/log.expected
716 787c8eb6 2019-07-11 stsp cmp -s $testroot/log.expected $testroot/log
717 787c8eb6 2019-07-11 stsp ret="$?"
718 787c8eb6 2019-07-11 stsp if [ "$ret" != "0" ]; then
719 787c8eb6 2019-07-11 stsp diff -u $testroot/log.expected $testroot/log
720 fc66b545 2019-08-12 stsp fi
721 fc66b545 2019-08-12 stsp
722 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
723 fc66b545 2019-08-12 stsp }
724 fc66b545 2019-08-12 stsp
725 fc66b545 2019-08-12 stsp function test_rebase_no_commits_to_rebase {
726 fc66b545 2019-08-12 stsp local testroot=`test_init rebase_no_commits_to_rebase`
727 fc66b545 2019-08-12 stsp
728 fc66b545 2019-08-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
729 fc66b545 2019-08-12 stsp ret="$?"
730 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
731 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
732 fc66b545 2019-08-12 stsp return 1
733 fc66b545 2019-08-12 stsp fi
734 fc66b545 2019-08-12 stsp
735 fc66b545 2019-08-12 stsp (cd $testroot/wt && got branch newbranch)
736 fc66b545 2019-08-12 stsp
737 fc66b545 2019-08-12 stsp echo "modified alpha on master" > $testroot/wt/alpha
738 fc66b545 2019-08-12 stsp (cd $testroot/wt && got commit -m 'test rebase_no_commits_to_rebase' \
739 fc66b545 2019-08-12 stsp > /dev/null)
740 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > /dev/null)
741 fc66b545 2019-08-12 stsp
742 fc66b545 2019-08-12 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
743 fc66b545 2019-08-12 stsp 2> $testroot/stderr)
744 fc66b545 2019-08-12 stsp
745 fc66b545 2019-08-12 stsp echo "got: no commits to rebase" > $testroot/stderr.expected
746 fc66b545 2019-08-12 stsp cmp -s $testroot/stderr.expected $testroot/stderr
747 fc66b545 2019-08-12 stsp ret="$?"
748 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
749 fc66b545 2019-08-12 stsp diff -u $testroot/stderr.expected $testroot/stderr
750 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
751 fc66b545 2019-08-12 stsp return 1
752 787c8eb6 2019-07-11 stsp fi
753 787c8eb6 2019-07-11 stsp
754 fc66b545 2019-08-12 stsp echo "Rebase of refs/heads/newbranch aborted" \
755 fc66b545 2019-08-12 stsp > $testroot/stdout.expected
756 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
757 fc66b545 2019-08-12 stsp ret="$?"
758 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
759 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
760 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
761 fc66b545 2019-08-12 stsp return 1
762 fc66b545 2019-08-12 stsp fi
763 fc66b545 2019-08-12 stsp
764 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
765 fc66b545 2019-08-12 stsp echo "Already up-to-date" > $testroot/stdout.expected
766 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
767 fc66b545 2019-08-12 stsp ret="$?"
768 fc66b545 2019-08-12 stsp if [ "$ret" != "0" ]; then
769 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
770 fc66b545 2019-08-12 stsp fi
771 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
772 ff0d2220 2019-07-11 stsp }
773 ff0d2220 2019-07-11 stsp
774 dcf44d04 2019-07-11 stsp run_test test_rebase_basic
775 dcf44d04 2019-07-11 stsp run_test test_rebase_ancestry_check
776 dcf44d04 2019-07-11 stsp run_test test_rebase_continue
777 dcf44d04 2019-07-11 stsp run_test test_rebase_abort
778 ff0d2220 2019-07-11 stsp run_test test_rebase_no_op_change
779 7d5807f4 2019-07-11 stsp run_test test_rebase_in_progress
780 64c6d990 2019-07-11 stsp run_test test_rebase_path_prefix
781 787c8eb6 2019-07-11 stsp run_test test_rebase_preserves_logmsg
782 fc66b545 2019-08-12 stsp run_test test_rebase_no_commits_to_rebase