Blame


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