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