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 49c543a6 2022-03-31 naddy ret=$?
45 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
78 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
88 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
98 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
114 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
125 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
137 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
148 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
174 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
188 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
195 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
210 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
217 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
227 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
238 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
260 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
269 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
292 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
307 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
317 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
335 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
346 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
360 49c543a6 2022-03-31 naddy if [ $ret -eq 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 49c543a6 2022-03-31 naddy ret=$?
371 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
392 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
404 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
428 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
446 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
456 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
474 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
486 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
504 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
514 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
526 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
549 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
564 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
574 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
592 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
603 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
625 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
638 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
661 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
676 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
686 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
704 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
715 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
728 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
740 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
767 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
778 49c543a6 2022-03-31 naddy if [ $ret -ne 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 49c543a6 2022-03-31 naddy ret=$?
789 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
790 787c8eb6 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
791 67ba6161 2022-04-08 stsp test_done "$testroot" "$ret"
792 67ba6161 2022-04-08 stsp return 1
793 67ba6161 2022-04-08 stsp fi
794 67ba6161 2022-04-08 stsp
795 67ba6161 2022-04-08 stsp # rebase should succeed when using a complete work tree
796 67ba6161 2022-04-08 stsp got checkout $testroot/repo $testroot/wt2 > /dev/null
797 67ba6161 2022-04-08 stsp ret=$?
798 67ba6161 2022-04-08 stsp if [ $ret -ne 0 ]; then
799 67ba6161 2022-04-08 stsp test_done "$testroot" "$ret"
800 67ba6161 2022-04-08 stsp return 1
801 67ba6161 2022-04-08 stsp fi
802 67ba6161 2022-04-08 stsp
803 67ba6161 2022-04-08 stsp (cd $testroot/wt2 && got rebase newbranch \
804 67ba6161 2022-04-08 stsp > $testroot/stdout 2> $testroot/stderr)
805 67ba6161 2022-04-08 stsp
806 67ba6161 2022-04-08 stsp (cd $testroot/repo && git checkout -q newbranch)
807 67ba6161 2022-04-08 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
808 67ba6161 2022-04-08 stsp local new_commit2=`git_show_head $testroot/repo`
809 67ba6161 2022-04-08 stsp
810 67ba6161 2022-04-08 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
811 67ba6161 2022-04-08 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
812 67ba6161 2022-04-08 stsp
813 67ba6161 2022-04-08 stsp echo "G gamma/delta" > $testroot/stdout.expected
814 67ba6161 2022-04-08 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
815 67ba6161 2022-04-08 stsp >> $testroot/stdout.expected
816 67ba6161 2022-04-08 stsp echo ": committing to delta on newbranch" \
817 67ba6161 2022-04-08 stsp >> $testroot/stdout.expected
818 67ba6161 2022-04-08 stsp echo "Switching work tree to refs/heads/newbranch" \
819 67ba6161 2022-04-08 stsp >> $testroot/stdout.expected
820 67ba6161 2022-04-08 stsp
821 67ba6161 2022-04-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
822 67ba6161 2022-04-08 stsp ret=$?
823 67ba6161 2022-04-08 stsp if [ $ret -ne 0 ]; then
824 67ba6161 2022-04-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
825 67ba6161 2022-04-08 stsp test_done "$testroot" "$ret"
826 67ba6161 2022-04-08 stsp return 1
827 787c8eb6 2019-07-11 stsp fi
828 67ba6161 2022-04-08 stsp
829 67ba6161 2022-04-08 stsp # the first work tree should remain usable
830 67ba6161 2022-04-08 stsp (cd $testroot/wt && got update -b master \
831 67ba6161 2022-04-08 stsp > $testroot/stdout 2> $testroot/stderr)
832 67ba6161 2022-04-08 stsp ret=$?
833 67ba6161 2022-04-08 stsp if [ $ret -ne 0 ]; then
834 67ba6161 2022-04-08 stsp echo "update failed unexpectedly" >&2
835 67ba6161 2022-04-08 stsp test_done "$testroot" "1"
836 67ba6161 2022-04-08 stsp return 1
837 67ba6161 2022-04-08 stsp fi
838 67ba6161 2022-04-08 stsp
839 67ba6161 2022-04-08 stsp echo 'Already up-to-date' > $testroot/stdout.expected
840 67ba6161 2022-04-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
841 67ba6161 2022-04-08 stsp ret=$?
842 67ba6161 2022-04-08 stsp if [ $ret -ne 0 ]; then
843 67ba6161 2022-04-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
844 67ba6161 2022-04-08 stsp fi
845 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
846 787c8eb6 2019-07-11 stsp }
847 787c8eb6 2019-07-11 stsp
848 f6cae3ed 2020-09-13 naddy test_rebase_preserves_logmsg() {
849 787c8eb6 2019-07-11 stsp local testroot=`test_init rebase_preserves_logmsg`
850 787c8eb6 2019-07-11 stsp
851 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
852 787c8eb6 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
853 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified delta on newbranch"
854 787c8eb6 2019-07-11 stsp
855 787c8eb6 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
856 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified alpha on newbranch"
857 787c8eb6 2019-07-11 stsp
858 787c8eb6 2019-07-11 stsp (cd $testroot/repo && got log -c newbranch -l2 | grep -v ^date: \
859 787c8eb6 2019-07-11 stsp > $testroot/log.expected)
860 787c8eb6 2019-07-11 stsp
861 787c8eb6 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
862 787c8eb6 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
863 787c8eb6 2019-07-11 stsp
864 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
865 787c8eb6 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
866 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
867 787c8eb6 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
868 787c8eb6 2019-07-11 stsp
869 787c8eb6 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
870 49c543a6 2022-03-31 naddy ret=$?
871 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
872 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
873 787c8eb6 2019-07-11 stsp return 1
874 787c8eb6 2019-07-11 stsp fi
875 787c8eb6 2019-07-11 stsp
876 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > /dev/null \
877 787c8eb6 2019-07-11 stsp 2> $testroot/stderr)
878 787c8eb6 2019-07-11 stsp
879 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
880 787c8eb6 2019-07-11 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
881 787c8eb6 2019-07-11 stsp local new_commit2=`git_show_head $testroot/repo`
882 787c8eb6 2019-07-11 stsp
883 787c8eb6 2019-07-11 stsp echo -n > $testroot/stderr.expected
884 64c6d990 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
885 49c543a6 2022-03-31 naddy ret=$?
886 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
887 64c6d990 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
888 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
889 787c8eb6 2019-07-11 stsp return 1
890 64c6d990 2019-07-11 stsp fi
891 787c8eb6 2019-07-11 stsp
892 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got log -c newbranch -l2 | grep -v ^date: \
893 787c8eb6 2019-07-11 stsp > $testroot/log)
894 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit1/$new_commit1/" $testroot/log.expected
895 787c8eb6 2019-07-11 stsp sed -i -e "s/$orig_commit2/$new_commit2/" $testroot/log.expected
896 787c8eb6 2019-07-11 stsp cmp -s $testroot/log.expected $testroot/log
897 49c543a6 2022-03-31 naddy ret=$?
898 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
899 787c8eb6 2019-07-11 stsp diff -u $testroot/log.expected $testroot/log
900 fc66b545 2019-08-12 stsp fi
901 fc66b545 2019-08-12 stsp
902 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
903 fc66b545 2019-08-12 stsp }
904 fc66b545 2019-08-12 stsp
905 f6cae3ed 2020-09-13 naddy test_rebase_no_commits_to_rebase() {
906 fc66b545 2019-08-12 stsp local testroot=`test_init rebase_no_commits_to_rebase`
907 fc66b545 2019-08-12 stsp
908 fc66b545 2019-08-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
909 49c543a6 2022-03-31 naddy ret=$?
910 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
911 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
912 fc66b545 2019-08-12 stsp return 1
913 fc66b545 2019-08-12 stsp fi
914 fc66b545 2019-08-12 stsp
915 980c6786 2023-01-31 stsp # Create an unrelated branch with 'got import'.
916 980c6786 2023-01-31 stsp mkdir -p $testroot/newtree
917 980c6786 2023-01-31 stsp echo "new file" > $testroot/newtree/newfile
918 980c6786 2023-01-31 stsp got import -m new -b newbranch -r $testroot/repo \
919 980c6786 2023-01-31 stsp $testroot/newtree > /dev/null
920 fc66b545 2019-08-12 stsp
921 fc66b545 2019-08-12 stsp echo "modified alpha on master" > $testroot/wt/alpha
922 fc66b545 2019-08-12 stsp (cd $testroot/wt && got commit -m 'test rebase_no_commits_to_rebase' \
923 fc66b545 2019-08-12 stsp > /dev/null)
924 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > /dev/null)
925 fc66b545 2019-08-12 stsp
926 fc66b545 2019-08-12 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
927 fc66b545 2019-08-12 stsp 2> $testroot/stderr)
928 fc66b545 2019-08-12 stsp
929 980c6786 2023-01-31 stsp echo -n "got: specified branch shares no common ancestry " \
930 980c6786 2023-01-31 stsp > $testroot/stderr.expected
931 980c6786 2023-01-31 stsp echo "with work tree's branch" >> $testroot/stderr.expected
932 fc66b545 2019-08-12 stsp cmp -s $testroot/stderr.expected $testroot/stderr
933 49c543a6 2022-03-31 naddy ret=$?
934 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
935 fc66b545 2019-08-12 stsp diff -u $testroot/stderr.expected $testroot/stderr
936 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
937 fc66b545 2019-08-12 stsp return 1
938 787c8eb6 2019-07-11 stsp fi
939 787c8eb6 2019-07-11 stsp
940 67ba6161 2022-04-08 stsp echo -n > $testroot/stdout.expected
941 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
942 49c543a6 2022-03-31 naddy ret=$?
943 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
944 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
945 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
946 fc66b545 2019-08-12 stsp return 1
947 fc66b545 2019-08-12 stsp fi
948 fc66b545 2019-08-12 stsp
949 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
950 fc66b545 2019-08-12 stsp echo "Already up-to-date" > $testroot/stdout.expected
951 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
952 49c543a6 2022-03-31 naddy ret=$?
953 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
954 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
955 fc66b545 2019-08-12 stsp fi
956 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
957 ff0d2220 2019-07-11 stsp }
958 38b0338b 2019-11-29 stsp
959 f6cae3ed 2020-09-13 naddy test_rebase_forward() {
960 38b0338b 2019-11-29 stsp local testroot=`test_init rebase_forward`
961 38b0338b 2019-11-29 stsp local commit0=`git_show_head $testroot/repo`
962 38b0338b 2019-11-29 stsp
963 38b0338b 2019-11-29 stsp got checkout $testroot/repo $testroot/wt > /dev/null
964 49c543a6 2022-03-31 naddy ret=$?
965 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
966 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
967 38b0338b 2019-11-29 stsp return 1
968 38b0338b 2019-11-29 stsp fi
969 38b0338b 2019-11-29 stsp
970 38b0338b 2019-11-29 stsp echo "change alpha 1" > $testroot/wt/alpha
971 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
972 38b0338b 2019-11-29 stsp > /dev/null)
973 38b0338b 2019-11-29 stsp local commit1=`git_show_head $testroot/repo`
974 ff0d2220 2019-07-11 stsp
975 38b0338b 2019-11-29 stsp echo "change alpha 2" > $testroot/wt/alpha
976 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
977 38b0338b 2019-11-29 stsp > /dev/null)
978 38b0338b 2019-11-29 stsp local commit2=`git_show_head $testroot/repo`
979 38b0338b 2019-11-29 stsp
980 5e91dae4 2022-08-30 stsp # Simulate a situation where fast-forward is required.
981 38b0338b 2019-11-29 stsp # We want to fast-forward master to origin/master:
982 38b0338b 2019-11-29 stsp # commit 3907e11dceaae2ca7f8db79c2af31794673945ad (origin/master)
983 38b0338b 2019-11-29 stsp # commit ffcffcd102cf1af6572fbdbb4cf07a0f1fd2d840 (master)
984 38b0338b 2019-11-29 stsp # commit 87a6a8a2263a15b61c016ff1720b24741d455eb5
985 993f033b 2021-07-16 stsp (cd $testroot/repo && got ref -d master >/dev/null)
986 e31abbf2 2020-03-22 stsp (cd $testroot/repo && got ref -c $commit1 refs/heads/master)
987 e31abbf2 2020-03-22 stsp (cd $testroot/repo && got ref -c $commit2 refs/remotes/origin/master)
988 38b0338b 2019-11-29 stsp
989 38b0338b 2019-11-29 stsp (cd $testroot/wt && got up -b origin/master > /dev/null)
990 38b0338b 2019-11-29 stsp
991 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase master \
992 0a706d22 2022-09-21 stsp > $testroot/stdout 2> $testroot/stderr)
993 0a706d22 2022-09-21 stsp
994 0a706d22 2022-09-21 stsp echo "Forwarding refs/heads/master to commit $commit2" \
995 0a706d22 2022-09-21 stsp > $testroot/stdout.expected
996 0a706d22 2022-09-21 stsp echo "Switching work tree to refs/heads/master" \
997 0a706d22 2022-09-21 stsp >> $testroot/stdout.expected
998 0a706d22 2022-09-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
999 0a706d22 2022-09-21 stsp ret=$?
1000 0a706d22 2022-09-21 stsp if [ $ret -ne 0 ]; then
1001 0a706d22 2022-09-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1002 0a706d22 2022-09-21 stsp test_done "$testroot" "$ret"
1003 0a706d22 2022-09-21 stsp return 1
1004 0a706d22 2022-09-21 stsp fi
1005 0a706d22 2022-09-21 stsp
1006 0a706d22 2022-09-21 stsp # Ensure that rebase operation was completed correctly
1007 0a706d22 2022-09-21 stsp (cd $testroot/wt && got rebase -a \
1008 0a706d22 2022-09-21 stsp > $testroot/stdout 2> $testroot/stderr)
1009 0a706d22 2022-09-21 stsp echo -n "" > $testroot/stdout.expected
1010 0a706d22 2022-09-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1011 0a706d22 2022-09-21 stsp ret=$?
1012 0a706d22 2022-09-21 stsp if [ $ret -ne 0 ]; then
1013 0a706d22 2022-09-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1014 0a706d22 2022-09-21 stsp test_done "$testroot" "$ret"
1015 0a706d22 2022-09-21 stsp return 1
1016 0a706d22 2022-09-21 stsp fi
1017 0a706d22 2022-09-21 stsp echo "got: rebase operation not in progress" > $testroot/stderr.expected
1018 0a706d22 2022-09-21 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1019 0a706d22 2022-09-21 stsp ret=$?
1020 0a706d22 2022-09-21 stsp if [ $ret -ne 0 ]; then
1021 0a706d22 2022-09-21 stsp diff -u $testroot/stderr.expected $testroot/stderr
1022 0a706d22 2022-09-21 stsp test_done "$testroot" "$ret"
1023 0a706d22 2022-09-21 stsp return 1
1024 0a706d22 2022-09-21 stsp fi
1025 0a706d22 2022-09-21 stsp
1026 0a706d22 2022-09-21 stsp (cd $testroot/wt && got branch -n > $testroot/stdout)
1027 0a706d22 2022-09-21 stsp echo "master" > $testroot/stdout.expected
1028 0a706d22 2022-09-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1029 0a706d22 2022-09-21 stsp ret=$?
1030 0a706d22 2022-09-21 stsp if [ $ret -ne 0 ]; then
1031 0a706d22 2022-09-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1032 0a706d22 2022-09-21 stsp test_done "$testroot" "$ret"
1033 0a706d22 2022-09-21 stsp return 1
1034 0a706d22 2022-09-21 stsp fi
1035 0a706d22 2022-09-21 stsp
1036 0a706d22 2022-09-21 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1037 0a706d22 2022-09-21 stsp echo "commit $commit2 (master, origin/master)" > $testroot/stdout.expected
1038 0a706d22 2022-09-21 stsp echo "commit $commit1" >> $testroot/stdout.expected
1039 0a706d22 2022-09-21 stsp echo "commit $commit0" >> $testroot/stdout.expected
1040 0a706d22 2022-09-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1041 0a706d22 2022-09-21 stsp ret=$?
1042 0a706d22 2022-09-21 stsp if [ $ret -ne 0 ]; then
1043 0a706d22 2022-09-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1044 0a706d22 2022-09-21 stsp test_done "$testroot" "$ret"
1045 0a706d22 2022-09-21 stsp return 1
1046 0a706d22 2022-09-21 stsp fi
1047 0a706d22 2022-09-21 stsp
1048 0a706d22 2022-09-21 stsp # Forward-only rebase operations should not be backed up
1049 0a706d22 2022-09-21 stsp (cd $testroot/repo && got rebase -l > $testroot/stdout)
1050 0a706d22 2022-09-21 stsp echo -n > $testroot/stdout.expected
1051 0a706d22 2022-09-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1052 0a706d22 2022-09-21 stsp ret=$?
1053 0a706d22 2022-09-21 stsp if [ $ret -ne 0 ]; then
1054 0a706d22 2022-09-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1055 0a706d22 2022-09-21 stsp fi
1056 0a706d22 2022-09-21 stsp test_done "$testroot" "$ret"
1057 0a706d22 2022-09-21 stsp }
1058 0a706d22 2022-09-21 stsp
1059 0a706d22 2022-09-21 stsp test_rebase_forward_path_prefix() {
1060 0a706d22 2022-09-21 stsp local testroot=`test_init rebase_forward_path_prefix`
1061 0a706d22 2022-09-21 stsp local commit0=`git_show_head $testroot/repo`
1062 0a706d22 2022-09-21 stsp
1063 0a706d22 2022-09-21 stsp got checkout $testroot/repo $testroot/wt-full > /dev/null
1064 0a706d22 2022-09-21 stsp ret=$?
1065 0a706d22 2022-09-21 stsp if [ $ret -ne 0 ]; then
1066 0a706d22 2022-09-21 stsp test_done "$testroot" "$ret"
1067 0a706d22 2022-09-21 stsp return 1
1068 0a706d22 2022-09-21 stsp fi
1069 0a706d22 2022-09-21 stsp
1070 0a706d22 2022-09-21 stsp echo "change alpha 1" > $testroot/wt-full/alpha
1071 0a706d22 2022-09-21 stsp (cd $testroot/wt-full && got commit -m 'test rebase_forward' \
1072 0a706d22 2022-09-21 stsp > /dev/null)
1073 0a706d22 2022-09-21 stsp local commit1=`git_show_head $testroot/repo`
1074 0a706d22 2022-09-21 stsp
1075 0a706d22 2022-09-21 stsp echo "change alpha 2" > $testroot/wt-full/alpha
1076 0a706d22 2022-09-21 stsp (cd $testroot/wt-full && got commit -m 'test rebase_forward' \
1077 0a706d22 2022-09-21 stsp > /dev/null)
1078 0a706d22 2022-09-21 stsp local commit2=`git_show_head $testroot/repo`
1079 0a706d22 2022-09-21 stsp
1080 0a706d22 2022-09-21 stsp # Simulate a situation where fast-forward is required.
1081 0a706d22 2022-09-21 stsp # We want to fast-forward master to origin/master:
1082 0a706d22 2022-09-21 stsp # commit 3907e11dceaae2ca7f8db79c2af31794673945ad (origin/master)
1083 0a706d22 2022-09-21 stsp # commit ffcffcd102cf1af6572fbdbb4cf07a0f1fd2d840 (master)
1084 0a706d22 2022-09-21 stsp # commit 87a6a8a2263a15b61c016ff1720b24741d455eb5
1085 0a706d22 2022-09-21 stsp (cd $testroot/repo && got ref -d master >/dev/null)
1086 0a706d22 2022-09-21 stsp (cd $testroot/repo && got ref -c $commit1 refs/heads/master)
1087 0a706d22 2022-09-21 stsp (cd $testroot/repo && got ref -c $commit2 refs/remotes/origin/master)
1088 0a706d22 2022-09-21 stsp
1089 0a706d22 2022-09-21 stsp # Work tree which uses a path-prefix and will be used for rebasing
1090 0a706d22 2022-09-21 stsp got checkout -p epsilon -b origin/master $testroot/repo $testroot/wt \
1091 0a706d22 2022-09-21 stsp > /dev/null
1092 0a706d22 2022-09-21 stsp ret=$?
1093 0a706d22 2022-09-21 stsp if [ $ret -ne 0 ]; then
1094 0a706d22 2022-09-21 stsp test_done "$testroot" "$ret"
1095 0a706d22 2022-09-21 stsp return 1
1096 0a706d22 2022-09-21 stsp fi
1097 0a706d22 2022-09-21 stsp
1098 2c75f174 2022-10-24 naddy (cd $testroot/wt && got rebase master \
1099 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
1100 38b0338b 2019-11-29 stsp
1101 38b0338b 2019-11-29 stsp echo "Forwarding refs/heads/master to commit $commit2" \
1102 38b0338b 2019-11-29 stsp > $testroot/stdout.expected
1103 38b0338b 2019-11-29 stsp echo "Switching work tree to refs/heads/master" \
1104 38b0338b 2019-11-29 stsp >> $testroot/stdout.expected
1105 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1106 49c543a6 2022-03-31 naddy ret=$?
1107 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1108 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
1109 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1110 38b0338b 2019-11-29 stsp return 1
1111 38b0338b 2019-11-29 stsp fi
1112 38b0338b 2019-11-29 stsp
1113 38b0338b 2019-11-29 stsp # Ensure that rebase operation was completed correctly
1114 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase -a \
1115 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
1116 38b0338b 2019-11-29 stsp echo -n "" > $testroot/stdout.expected
1117 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1118 49c543a6 2022-03-31 naddy ret=$?
1119 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1120 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
1121 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1122 38b0338b 2019-11-29 stsp return 1
1123 38b0338b 2019-11-29 stsp fi
1124 38b0338b 2019-11-29 stsp echo "got: rebase operation not in progress" > $testroot/stderr.expected
1125 38b0338b 2019-11-29 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1126 49c543a6 2022-03-31 naddy ret=$?
1127 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1128 38b0338b 2019-11-29 stsp diff -u $testroot/stderr.expected $testroot/stderr
1129 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1130 38b0338b 2019-11-29 stsp return 1
1131 38b0338b 2019-11-29 stsp fi
1132 38b0338b 2019-11-29 stsp
1133 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n > $testroot/stdout)
1134 38b0338b 2019-11-29 stsp echo "master" > $testroot/stdout.expected
1135 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1136 49c543a6 2022-03-31 naddy ret=$?
1137 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1138 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
1139 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1140 38b0338b 2019-11-29 stsp return 1
1141 38b0338b 2019-11-29 stsp fi
1142 38b0338b 2019-11-29 stsp
1143 38b0338b 2019-11-29 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1144 38b0338b 2019-11-29 stsp echo "commit $commit2 (master, origin/master)" > $testroot/stdout.expected
1145 38b0338b 2019-11-29 stsp echo "commit $commit1" >> $testroot/stdout.expected
1146 38b0338b 2019-11-29 stsp echo "commit $commit0" >> $testroot/stdout.expected
1147 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1148 49c543a6 2022-03-31 naddy ret=$?
1149 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1150 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
1151 e600f124 2021-03-21 stsp test_done "$testroot" "$ret"
1152 a9662115 2021-08-29 naddy return 1
1153 38b0338b 2019-11-29 stsp fi
1154 e600f124 2021-03-21 stsp
1155 e600f124 2021-03-21 stsp # Forward-only rebase operations should not be backed up
1156 e600f124 2021-03-21 stsp (cd $testroot/repo && got rebase -l > $testroot/stdout)
1157 e600f124 2021-03-21 stsp echo -n > $testroot/stdout.expected
1158 e600f124 2021-03-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1159 49c543a6 2022-03-31 naddy ret=$?
1160 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1161 e600f124 2021-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1162 e600f124 2021-03-21 stsp fi
1163 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1164 38b0338b 2019-11-29 stsp }
1165 e51d7b55 2020-01-04 stsp
1166 f6cae3ed 2020-09-13 naddy test_rebase_out_of_date() {
1167 e51d7b55 2020-01-04 stsp local testroot=`test_init rebase_out_of_date`
1168 e51d7b55 2020-01-04 stsp local initial_commit=`git_show_head $testroot/repo`
1169 e51d7b55 2020-01-04 stsp
1170 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1171 e51d7b55 2020-01-04 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1172 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1173 38b0338b 2019-11-29 stsp
1174 e51d7b55 2020-01-04 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1175 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git rm -q beta)
1176 e51d7b55 2020-01-04 stsp echo "new file on branch" > $testroot/repo/epsilon/new
1177 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git add epsilon/new)
1178 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
1179 e51d7b55 2020-01-04 stsp
1180 e51d7b55 2020-01-04 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1181 e51d7b55 2020-01-04 stsp local orig_commit2=`git_show_head $testroot/repo`
1182 e51d7b55 2020-01-04 stsp
1183 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
1184 e51d7b55 2020-01-04 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1185 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to zeta on master"
1186 e51d7b55 2020-01-04 stsp local master_commit1=`git_show_head $testroot/repo`
1187 e51d7b55 2020-01-04 stsp
1188 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
1189 e51d7b55 2020-01-04 stsp echo "modified beta on master" > $testroot/repo/beta
1190 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to beta on master"
1191 e51d7b55 2020-01-04 stsp local master_commit2=`git_show_head $testroot/repo`
1192 e51d7b55 2020-01-04 stsp
1193 e51d7b55 2020-01-04 stsp got checkout -c $master_commit1 $testroot/repo $testroot/wt \
1194 e51d7b55 2020-01-04 stsp > /dev/null
1195 49c543a6 2022-03-31 naddy ret=$?
1196 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1197 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1198 e51d7b55 2020-01-04 stsp return 1
1199 e51d7b55 2020-01-04 stsp fi
1200 e51d7b55 2020-01-04 stsp
1201 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
1202 e51d7b55 2020-01-04 stsp 2> $testroot/stderr)
1203 e51d7b55 2020-01-04 stsp
1204 e51d7b55 2020-01-04 stsp echo -n > $testroot/stdout.expected
1205 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1206 49c543a6 2022-03-31 naddy ret=$?
1207 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1208 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
1209 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1210 e51d7b55 2020-01-04 stsp return 1
1211 e51d7b55 2020-01-04 stsp fi
1212 e51d7b55 2020-01-04 stsp
1213 e51d7b55 2020-01-04 stsp echo -n "got: work tree must be updated before it can be " \
1214 e51d7b55 2020-01-04 stsp > $testroot/stderr.expected
1215 e51d7b55 2020-01-04 stsp echo "used to rebase a branch" >> $testroot/stderr.expected
1216 e51d7b55 2020-01-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1217 49c543a6 2022-03-31 naddy ret=$?
1218 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1219 e51d7b55 2020-01-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
1220 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1221 e51d7b55 2020-01-04 stsp return 1
1222 e51d7b55 2020-01-04 stsp fi
1223 e51d7b55 2020-01-04 stsp
1224 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1225 e51d7b55 2020-01-04 stsp echo "commit $master_commit2 (master)" > $testroot/stdout.expected
1226 e51d7b55 2020-01-04 stsp echo "commit $master_commit1" >> $testroot/stdout.expected
1227 e51d7b55 2020-01-04 stsp echo "commit $initial_commit" >> $testroot/stdout.expected
1228 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1229 49c543a6 2022-03-31 naddy ret=$?
1230 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1231 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1232 1ae0a341 2020-02-14 stsp fi
1233 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1234 1ae0a341 2020-02-14 stsp }
1235 1ae0a341 2020-02-14 stsp
1236 f6cae3ed 2020-09-13 naddy test_rebase_trims_empty_dir() {
1237 1ae0a341 2020-02-14 stsp local testroot=`test_init rebase_trims_empty_dir`
1238 1ae0a341 2020-02-14 stsp
1239 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1240 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1241 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1242 1ae0a341 2020-02-14 stsp
1243 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git rm -q epsilon/zeta)
1244 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "removing zeta on newbranch"
1245 1ae0a341 2020-02-14 stsp
1246 1ae0a341 2020-02-14 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1247 1ae0a341 2020-02-14 stsp local orig_commit2=`git_show_head $testroot/repo`
1248 1ae0a341 2020-02-14 stsp
1249 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q master)
1250 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/repo/alpha
1251 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to alpha on master"
1252 1ae0a341 2020-02-14 stsp local master_commit=`git_show_head $testroot/repo`
1253 1ae0a341 2020-02-14 stsp
1254 1ae0a341 2020-02-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1255 49c543a6 2022-03-31 naddy ret=$?
1256 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1257 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1258 1ae0a341 2020-02-14 stsp return 1
1259 1ae0a341 2020-02-14 stsp fi
1260 1ae0a341 2020-02-14 stsp
1261 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1262 1ae0a341 2020-02-14 stsp
1263 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q newbranch)
1264 1ae0a341 2020-02-14 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
1265 1ae0a341 2020-02-14 stsp local new_commit2=`git_show_head $testroot/repo`
1266 1ae0a341 2020-02-14 stsp
1267 1ae0a341 2020-02-14 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1268 1ae0a341 2020-02-14 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1269 1ae0a341 2020-02-14 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1270 1ae0a341 2020-02-14 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1271 1ae0a341 2020-02-14 stsp
1272 1ae0a341 2020-02-14 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1273 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1274 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1275 1ae0a341 2020-02-14 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1276 1ae0a341 2020-02-14 stsp echo "D epsilon/zeta" >> $testroot/stdout.expected
1277 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1278 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1279 1ae0a341 2020-02-14 stsp echo ": removing zeta on newbranch" \
1280 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1281 1ae0a341 2020-02-14 stsp echo "Switching work tree to refs/heads/newbranch" \
1282 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1283 1ae0a341 2020-02-14 stsp
1284 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1285 49c543a6 2022-03-31 naddy ret=$?
1286 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1287 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
1288 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1289 1ae0a341 2020-02-14 stsp return 1
1290 e51d7b55 2020-01-04 stsp fi
1291 1ae0a341 2020-02-14 stsp
1292 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/content.expected
1293 1ae0a341 2020-02-14 stsp cat $testroot/wt/gamma/delta > $testroot/content
1294 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1295 49c543a6 2022-03-31 naddy ret=$?
1296 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1297 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1298 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1299 1ae0a341 2020-02-14 stsp return 1
1300 1ae0a341 2020-02-14 stsp fi
1301 1ae0a341 2020-02-14 stsp
1302 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/content.expected
1303 1ae0a341 2020-02-14 stsp cat $testroot/wt/alpha > $testroot/content
1304 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1305 49c543a6 2022-03-31 naddy ret=$?
1306 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1307 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1308 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1309 1ae0a341 2020-02-14 stsp return 1
1310 1ae0a341 2020-02-14 stsp fi
1311 1ae0a341 2020-02-14 stsp
1312 1ae0a341 2020-02-14 stsp if [ -e $testroot/wt/epsilon ]; then
1313 1ae0a341 2020-02-14 stsp echo "parent of removed zeta still exists on disk" >&2
1314 1ae0a341 2020-02-14 stsp test_done "$testroot" "1"
1315 1ae0a341 2020-02-14 stsp return 1
1316 1ae0a341 2020-02-14 stsp fi
1317 1ae0a341 2020-02-14 stsp
1318 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got status > $testroot/stdout)
1319 1ae0a341 2020-02-14 stsp
1320 1ae0a341 2020-02-14 stsp echo -n > $testroot/stdout.expected
1321 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1322 49c543a6 2022-03-31 naddy ret=$?
1323 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1324 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1325 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1326 1ae0a341 2020-02-14 stsp return 1
1327 1ae0a341 2020-02-14 stsp fi
1328 1ae0a341 2020-02-14 stsp
1329 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1330 1ae0a341 2020-02-14 stsp echo "commit $new_commit2 (newbranch)" > $testroot/stdout.expected
1331 1ae0a341 2020-02-14 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1332 1ae0a341 2020-02-14 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1333 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1334 49c543a6 2022-03-31 naddy ret=$?
1335 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1336 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1337 1ae0a341 2020-02-14 stsp fi
1338 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1339 e51d7b55 2020-01-04 stsp }
1340 ca6da77d 2020-03-22 stsp
1341 f6cae3ed 2020-09-13 naddy test_rebase_delete_missing_file() {
1342 ca6da77d 2020-03-22 stsp local testroot=`test_init rebase_delete_missing_file`
1343 ca6da77d 2020-03-22 stsp
1344 ca6da77d 2020-03-22 stsp mkdir -p $testroot/repo/d/f/g
1345 ca6da77d 2020-03-22 stsp echo "new file" > $testroot/repo/d/f/g/new
1346 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git add d/f/g/new)
1347 ca6da77d 2020-03-22 stsp git_commit $testroot/repo -m "adding a subdir"
1348 ca6da77d 2020-03-22 stsp local commit0=`git_show_head $testroot/repo`
1349 ca6da77d 2020-03-22 stsp
1350 a740a1b3 2020-03-22 stsp got br -r $testroot/repo -c master newbranch
1351 a740a1b3 2020-03-22 stsp
1352 a740a1b3 2020-03-22 stsp got checkout -b newbranch $testroot/repo $testroot/wt > /dev/null
1353 ca6da77d 2020-03-22 stsp
1354 a740a1b3 2020-03-22 stsp echo "modified delta on branch" > $testroot/wt/gamma/delta
1355 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1356 a740a1b3 2020-03-22 stsp -m "committing to delta on newbranch" > /dev/null)
1357 ca6da77d 2020-03-22 stsp
1358 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1359 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1360 a740a1b3 2020-03-22 stsp -m "removing beta and d/f/g/new on newbranch" > /dev/null)
1361 a740a1b3 2020-03-22 stsp
1362 a740a1b3 2020-03-22 stsp (cd $testroot/repo && git checkout -q newbranch)
1363 ca6da77d 2020-03-22 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1364 ca6da77d 2020-03-22 stsp local orig_commit2=`git_show_head $testroot/repo`
1365 1fa49072 2021-09-28 stsp
1366 1fa49072 2021-09-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1367 1fa49072 2021-09-28 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1368 ca6da77d 2020-03-22 stsp
1369 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got update -b master > /dev/null)
1370 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1371 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1372 a740a1b3 2020-03-22 stsp -m "removing beta and d/f/g/new on master" > /dev/null)
1373 a740a1b3 2020-03-22 stsp
1374 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git checkout -q master)
1375 ca6da77d 2020-03-22 stsp local master_commit=`git_show_head $testroot/repo`
1376 ca6da77d 2020-03-22 stsp
1377 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got update -b master > /dev/null)
1378 1fa49072 2021-09-28 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
1379 1fa49072 2021-09-28 stsp 2> $testroot/stderr)
1380 49c543a6 2022-03-31 naddy ret=$?
1381 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1382 1fa49072 2021-09-28 stsp echo "rebase succeeded unexpectedly" >&2
1383 1fa49072 2021-09-28 stsp test_done "$testroot" "1"
1384 1fa49072 2021-09-28 stsp return 1
1385 1fa49072 2021-09-28 stsp fi
1386 ca6da77d 2020-03-22 stsp
1387 1fa49072 2021-09-28 stsp local new_commit1=$(cd $testroot/wt && got info | \
1388 1fa49072 2021-09-28 stsp grep '^work tree base commit: ' | cut -d: -f2 | tr -d ' ')
1389 ca6da77d 2020-03-22 stsp
1390 ca6da77d 2020-03-22 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1391 ca6da77d 2020-03-22 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1392 ca6da77d 2020-03-22 stsp
1393 ca6da77d 2020-03-22 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1394 ca6da77d 2020-03-22 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1395 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1396 ca6da77d 2020-03-22 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1397 ca6da77d 2020-03-22 stsp echo "! beta" >> $testroot/stdout.expected
1398 ca6da77d 2020-03-22 stsp echo "! d/f/g/new" >> $testroot/stdout.expected
1399 35ca1db7 2021-09-28 stsp echo -n "Files which had incoming changes but could not be found " \
1400 35ca1db7 2021-09-28 stsp >> $testroot/stdout.expected
1401 35ca1db7 2021-09-28 stsp echo "in the work tree: 2" >> $testroot/stdout.expected
1402 1fa49072 2021-09-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1403 49c543a6 2022-03-31 naddy ret=$?
1404 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1405 1fa49072 2021-09-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1406 1fa49072 2021-09-28 stsp test_done "$testroot" "$ret"
1407 1fa49072 2021-09-28 stsp return 1
1408 1fa49072 2021-09-28 stsp fi
1409 1fa49072 2021-09-28 stsp
1410 1fa49072 2021-09-28 stsp echo -n "got: changes destined for some files were not yet merged " \
1411 1fa49072 2021-09-28 stsp > $testroot/stderr.expected
1412 1fa49072 2021-09-28 stsp echo -n "and should be merged manually if required before the " \
1413 1fa49072 2021-09-28 stsp >> $testroot/stderr.expected
1414 1fa49072 2021-09-28 stsp echo "rebase operation is continued" >> $testroot/stderr.expected
1415 1fa49072 2021-09-28 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1416 49c543a6 2022-03-31 naddy ret=$?
1417 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1418 1fa49072 2021-09-28 stsp diff -u $testroot/stderr.expected $testroot/stderr
1419 1fa49072 2021-09-28 stsp test_done "$testroot" "$ret"
1420 1fa49072 2021-09-28 stsp return 1
1421 1fa49072 2021-09-28 stsp fi
1422 1fa49072 2021-09-28 stsp
1423 1fa49072 2021-09-28 stsp # ignore the missing changes and continue
1424 1fa49072 2021-09-28 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
1425 49c543a6 2022-03-31 naddy ret=$?
1426 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1427 1fa49072 2021-09-28 stsp echo "rebase failed unexpectedly" >&2
1428 1fa49072 2021-09-28 stsp test_done "$testroot" "1"
1429 1fa49072 2021-09-28 stsp return 1
1430 1fa49072 2021-09-28 stsp fi
1431 ca6da77d 2020-03-22 stsp echo -n "$short_orig_commit2 -> no-op change" \
1432 1fa49072 2021-09-28 stsp > $testroot/stdout.expected
1433 a740a1b3 2020-03-22 stsp echo ": removing beta and d/f/g/new on newbranch" \
1434 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1435 ca6da77d 2020-03-22 stsp echo "Switching work tree to refs/heads/newbranch" \
1436 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1437 ca6da77d 2020-03-22 stsp
1438 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1439 49c543a6 2022-03-31 naddy ret=$?
1440 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1441 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1442 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1443 ca6da77d 2020-03-22 stsp return 1
1444 ca6da77d 2020-03-22 stsp fi
1445 ca6da77d 2020-03-22 stsp
1446 ca6da77d 2020-03-22 stsp echo "modified delta on branch" > $testroot/content.expected
1447 ca6da77d 2020-03-22 stsp cat $testroot/wt/gamma/delta > $testroot/content
1448 ca6da77d 2020-03-22 stsp cmp -s $testroot/content.expected $testroot/content
1449 49c543a6 2022-03-31 naddy ret=$?
1450 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1451 ca6da77d 2020-03-22 stsp diff -u $testroot/content.expected $testroot/content
1452 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1453 ca6da77d 2020-03-22 stsp return 1
1454 ca6da77d 2020-03-22 stsp fi
1455 ca6da77d 2020-03-22 stsp
1456 ca6da77d 2020-03-22 stsp if [ -e $testroot/wt/beta ]; then
1457 ca6da77d 2020-03-22 stsp echo "removed file beta still exists on disk" >&2
1458 ca6da77d 2020-03-22 stsp test_done "$testroot" "1"
1459 ca6da77d 2020-03-22 stsp return 1
1460 ca6da77d 2020-03-22 stsp fi
1461 ca6da77d 2020-03-22 stsp
1462 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got status > $testroot/stdout)
1463 ca6da77d 2020-03-22 stsp
1464 ca6da77d 2020-03-22 stsp echo -n > $testroot/stdout.expected
1465 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1466 49c543a6 2022-03-31 naddy ret=$?
1467 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1468 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1469 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1470 ca6da77d 2020-03-22 stsp return 1
1471 ca6da77d 2020-03-22 stsp fi
1472 ca6da77d 2020-03-22 stsp
1473 1fa49072 2021-09-28 stsp (cd $testroot/repo && git checkout -q newbranch)
1474 1fa49072 2021-09-28 stsp local new_commit1=`git_show_head $testroot/repo`
1475 1fa49072 2021-09-28 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1476 1fa49072 2021-09-28 stsp
1477 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1478 ca6da77d 2020-03-22 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
1479 ca6da77d 2020-03-22 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1480 ca6da77d 2020-03-22 stsp echo "commit $commit0" >> $testroot/stdout.expected
1481 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1482 49c543a6 2022-03-31 naddy ret=$?
1483 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1484 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1485 70551d57 2020-04-24 stsp fi
1486 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1487 70551d57 2020-04-24 stsp }
1488 70551d57 2020-04-24 stsp
1489 f6cae3ed 2020-09-13 naddy test_rebase_rm_add_rm_file() {
1490 70551d57 2020-04-24 stsp local testroot=`test_init rebase_rm_add_rm_file`
1491 70551d57 2020-04-24 stsp
1492 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1493 70551d57 2020-04-24 stsp (cd $testroot/repo && git rm -q beta)
1494 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "removing beta from newbranch"
1495 70551d57 2020-04-24 stsp local orig_commit1=`git_show_head $testroot/repo`
1496 70551d57 2020-04-24 stsp
1497 70551d57 2020-04-24 stsp echo 'restored beta' > $testroot/repo/beta
1498 70551d57 2020-04-24 stsp (cd $testroot/repo && git add beta)
1499 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "restoring beta on newbranch"
1500 70551d57 2020-04-24 stsp local orig_commit2=`git_show_head $testroot/repo`
1501 70551d57 2020-04-24 stsp
1502 70551d57 2020-04-24 stsp (cd $testroot/repo && git rm -q beta)
1503 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "removing beta from newbranch again"
1504 70551d57 2020-04-24 stsp local orig_commit3=`git_show_head $testroot/repo`
1505 70551d57 2020-04-24 stsp
1506 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q master)
1507 70551d57 2020-04-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1508 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
1509 70551d57 2020-04-24 stsp local master_commit=`git_show_head $testroot/repo`
1510 70551d57 2020-04-24 stsp
1511 70551d57 2020-04-24 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1512 49c543a6 2022-03-31 naddy ret=$?
1513 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1514 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1515 70551d57 2020-04-24 stsp return 1
1516 70551d57 2020-04-24 stsp fi
1517 70551d57 2020-04-24 stsp
1518 70551d57 2020-04-24 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1519 70551d57 2020-04-24 stsp
1520 70551d57 2020-04-24 stsp # this would error out with 'got: file index is corrupt'
1521 70551d57 2020-04-24 stsp (cd $testroot/wt && got status > /dev/null)
1522 49c543a6 2022-03-31 naddy ret=$?
1523 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1524 70551d57 2020-04-24 stsp echo "got status command failed unexpectedly" >&2
1525 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1526 70551d57 2020-04-24 stsp return 1
1527 70551d57 2020-04-24 stsp fi
1528 70551d57 2020-04-24 stsp
1529 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q newbranch)
1530 70551d57 2020-04-24 stsp local new_commit3=`git_show_head $testroot/repo`
1531 70551d57 2020-04-24 stsp local new_commit2=`git_show_parent_commit $testroot/repo`
1532 70551d57 2020-04-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo $new_commit2`
1533 70551d57 2020-04-24 stsp
1534 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q newbranch)
1535 70551d57 2020-04-24 stsp
1536 70551d57 2020-04-24 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1537 70551d57 2020-04-24 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1538 70551d57 2020-04-24 stsp local short_orig_commit3=`trim_obj_id 28 $orig_commit3`
1539 70551d57 2020-04-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1540 70551d57 2020-04-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1541 70551d57 2020-04-24 stsp local short_new_commit3=`trim_obj_id 28 $new_commit3`
1542 70551d57 2020-04-24 stsp
1543 70551d57 2020-04-24 stsp echo "D beta" > $testroot/stdout.expected
1544 70551d57 2020-04-24 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1545 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1546 70551d57 2020-04-24 stsp echo ": removing beta from newbranch" >> $testroot/stdout.expected
1547 70551d57 2020-04-24 stsp echo "A beta" >> $testroot/stdout.expected
1548 70551d57 2020-04-24 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1549 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1550 70551d57 2020-04-24 stsp echo ": restoring beta on newbranch" >> $testroot/stdout.expected
1551 70551d57 2020-04-24 stsp echo "D beta" >> $testroot/stdout.expected
1552 70551d57 2020-04-24 stsp echo -n "$short_orig_commit3 -> $short_new_commit3" \
1553 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1554 70551d57 2020-04-24 stsp echo ": removing beta from newbranch again" >> $testroot/stdout.expected
1555 70551d57 2020-04-24 stsp echo "Switching work tree to refs/heads/newbranch" \
1556 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1557 70551d57 2020-04-24 stsp
1558 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1559 49c543a6 2022-03-31 naddy ret=$?
1560 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1561 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1562 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1563 70551d57 2020-04-24 stsp return 1
1564 ca6da77d 2020-03-22 stsp fi
1565 70551d57 2020-04-24 stsp
1566 70551d57 2020-04-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1567 49c543a6 2022-03-31 naddy ret=$?
1568 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1569 70551d57 2020-04-24 stsp echo "got status command failed unexpectedly" >&2
1570 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1571 70551d57 2020-04-24 stsp return 1
1572 70551d57 2020-04-24 stsp fi
1573 70551d57 2020-04-24 stsp
1574 70551d57 2020-04-24 stsp echo -n > $testroot/stdout.expected
1575 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1576 49c543a6 2022-03-31 naddy ret=$?
1577 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1578 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1579 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1580 70551d57 2020-04-24 stsp return 1
1581 70551d57 2020-04-24 stsp fi
1582 70551d57 2020-04-24 stsp
1583 70551d57 2020-04-24 stsp (cd $testroot/wt && got log -l4 | grep ^commit > $testroot/stdout)
1584 70551d57 2020-04-24 stsp echo "commit $new_commit3 (newbranch)" > $testroot/stdout.expected
1585 70551d57 2020-04-24 stsp echo "commit $new_commit2" >> $testroot/stdout.expected
1586 70551d57 2020-04-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1587 70551d57 2020-04-24 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1588 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1589 49c543a6 2022-03-31 naddy ret=$?
1590 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1591 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1592 70551d57 2020-04-24 stsp fi
1593 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1594 ca6da77d 2020-03-22 stsp }
1595 598eac43 2022-07-22 stsp
1596 598eac43 2022-07-22 stsp test_rebase_resets_committer() {
1597 598eac43 2022-07-22 stsp local testroot=`test_init rebase_resets_committer`
1598 598eac43 2022-07-22 stsp local commit0=`git_show_head $testroot/repo`
1599 598eac43 2022-07-22 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1600 598eac43 2022-07-22 stsp local committer="Flan Luck <flan_luck@openbsd.org>"
1601 598eac43 2022-07-22 stsp
1602 598eac43 2022-07-22 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1603 598eac43 2022-07-22 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1604 598eac43 2022-07-22 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1605 598eac43 2022-07-22 stsp
1606 598eac43 2022-07-22 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1607 598eac43 2022-07-22 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
1608 598eac43 2022-07-22 stsp
1609 598eac43 2022-07-22 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1610 598eac43 2022-07-22 stsp local orig_commit2=`git_show_head $testroot/repo`
1611 598eac43 2022-07-22 stsp local orig_author_time2=`git_show_author_time $testroot/repo`
1612 598eac43 2022-07-22 stsp
1613 598eac43 2022-07-22 stsp (cd $testroot/repo && git checkout -q master)
1614 598eac43 2022-07-22 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1615 598eac43 2022-07-22 stsp git_commit $testroot/repo -m "committing to zeta on master"
1616 598eac43 2022-07-22 stsp local master_commit=`git_show_head $testroot/repo`
1617 598eac43 2022-07-22 stsp
1618 598eac43 2022-07-22 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1619 598eac43 2022-07-22 stsp ret=$?
1620 598eac43 2022-07-22 stsp if [ $ret -ne 0 ]; then
1621 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
1622 598eac43 2022-07-22 stsp return 1
1623 598eac43 2022-07-22 stsp fi
1624 ca6da77d 2020-03-22 stsp
1625 598eac43 2022-07-22 stsp (cd $testroot/wt && env GOT_AUTHOR="$committer" \
1626 598eac43 2022-07-22 stsp got rebase newbranch > $testroot/stdout)
1627 598eac43 2022-07-22 stsp
1628 598eac43 2022-07-22 stsp (cd $testroot/repo && git checkout -q newbranch)
1629 598eac43 2022-07-22 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
1630 598eac43 2022-07-22 stsp local new_commit2=`git_show_head $testroot/repo`
1631 598eac43 2022-07-22 stsp local new_author_time2=`git_show_author_time $testroot/repo`
1632 598eac43 2022-07-22 stsp
1633 598eac43 2022-07-22 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1634 598eac43 2022-07-22 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1635 598eac43 2022-07-22 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1636 598eac43 2022-07-22 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1637 598eac43 2022-07-22 stsp
1638 598eac43 2022-07-22 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1639 598eac43 2022-07-22 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1640 598eac43 2022-07-22 stsp >> $testroot/stdout.expected
1641 598eac43 2022-07-22 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1642 598eac43 2022-07-22 stsp echo "G alpha" >> $testroot/stdout.expected
1643 598eac43 2022-07-22 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1644 598eac43 2022-07-22 stsp >> $testroot/stdout.expected
1645 598eac43 2022-07-22 stsp echo ": committing more changes on newbranch" \
1646 598eac43 2022-07-22 stsp >> $testroot/stdout.expected
1647 598eac43 2022-07-22 stsp echo "Switching work tree to refs/heads/newbranch" \
1648 598eac43 2022-07-22 stsp >> $testroot/stdout.expected
1649 598eac43 2022-07-22 stsp
1650 598eac43 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1651 598eac43 2022-07-22 stsp ret=$?
1652 598eac43 2022-07-22 stsp if [ $ret -ne 0 ]; then
1653 598eac43 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1654 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
1655 598eac43 2022-07-22 stsp return 1
1656 598eac43 2022-07-22 stsp fi
1657 598eac43 2022-07-22 stsp
1658 598eac43 2022-07-22 stsp # Original commit only had one author
1659 598eac43 2022-07-22 stsp (cd $testroot/repo && got log -l1 -c $orig_commit2 | \
1660 598eac43 2022-07-22 stsp egrep '^(from|via):' > $testroot/stdout)
1661 598eac43 2022-07-22 stsp echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
1662 598eac43 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1663 598eac43 2022-07-22 stsp ret=$?
1664 598eac43 2022-07-22 stsp if [ $ret -ne 0 ]; then
1665 598eac43 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1666 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
1667 598eac43 2022-07-22 stsp return 1
1668 598eac43 2022-07-22 stsp fi
1669 598eac43 2022-07-22 stsp
1670 598eac43 2022-07-22 stsp # Rebased commit should have new committer name added
1671 598eac43 2022-07-22 stsp (cd $testroot/repo && got log -l1 -c $new_commit2 | \
1672 598eac43 2022-07-22 stsp egrep '^(from|via):' > $testroot/stdout)
1673 598eac43 2022-07-22 stsp echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
1674 598eac43 2022-07-22 stsp echo "via: $committer" >> $testroot/stdout.expected
1675 50e7a649 2022-07-22 stsp
1676 50e7a649 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1677 50e7a649 2022-07-22 stsp ret=$?
1678 50e7a649 2022-07-22 stsp if [ $ret -ne 0 ]; then
1679 50e7a649 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1680 50e7a649 2022-07-22 stsp fi
1681 50e7a649 2022-07-22 stsp test_done "$testroot" "$ret"
1682 50e7a649 2022-07-22 stsp }
1683 50e7a649 2022-07-22 stsp
1684 50e7a649 2022-07-22 stsp test_rebase_no_author_info() {
1685 50e7a649 2022-07-22 stsp local testroot=`test_init rebase_no_author_info`
1686 50e7a649 2022-07-22 stsp local commit0=`git_show_head $testroot/repo`
1687 50e7a649 2022-07-22 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1688 50e7a649 2022-07-22 stsp local committer="$GOT_AUTHOR"
1689 50e7a649 2022-07-22 stsp
1690 50e7a649 2022-07-22 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1691 50e7a649 2022-07-22 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1692 50e7a649 2022-07-22 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1693 50e7a649 2022-07-22 stsp
1694 50e7a649 2022-07-22 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1695 50e7a649 2022-07-22 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
1696 50e7a649 2022-07-22 stsp
1697 50e7a649 2022-07-22 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1698 50e7a649 2022-07-22 stsp local orig_commit2=`git_show_head $testroot/repo`
1699 50e7a649 2022-07-22 stsp local orig_author_time2=`git_show_author_time $testroot/repo`
1700 50e7a649 2022-07-22 stsp
1701 50e7a649 2022-07-22 stsp (cd $testroot/repo && git checkout -q master)
1702 50e7a649 2022-07-22 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1703 50e7a649 2022-07-22 stsp git_commit $testroot/repo -m "committing to zeta on master"
1704 50e7a649 2022-07-22 stsp local master_commit=`git_show_head $testroot/repo`
1705 50e7a649 2022-07-22 stsp
1706 50e7a649 2022-07-22 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1707 50e7a649 2022-07-22 stsp ret=$?
1708 50e7a649 2022-07-22 stsp if [ $ret -ne 0 ]; then
1709 50e7a649 2022-07-22 stsp test_done "$testroot" "$ret"
1710 50e7a649 2022-07-22 stsp return 1
1711 50e7a649 2022-07-22 stsp fi
1712 50e7a649 2022-07-22 stsp
1713 1004841d 2022-07-24 op # unset in a subshell to avoid affecting our environment
1714 1004841d 2022-07-24 op (unset GOT_AUTHOR && cd $testroot/wt && \
1715 1004841d 2022-07-24 op got rebase newbranch > $testroot/stdout)
1716 50e7a649 2022-07-22 stsp
1717 50e7a649 2022-07-22 stsp (cd $testroot/repo && git checkout -q newbranch)
1718 50e7a649 2022-07-22 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
1719 50e7a649 2022-07-22 stsp local new_commit2=`git_show_head $testroot/repo`
1720 50e7a649 2022-07-22 stsp local new_author_time2=`git_show_author_time $testroot/repo`
1721 598eac43 2022-07-22 stsp
1722 50e7a649 2022-07-22 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1723 50e7a649 2022-07-22 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1724 50e7a649 2022-07-22 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1725 50e7a649 2022-07-22 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1726 50e7a649 2022-07-22 stsp
1727 50e7a649 2022-07-22 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1728 50e7a649 2022-07-22 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1729 50e7a649 2022-07-22 stsp >> $testroot/stdout.expected
1730 50e7a649 2022-07-22 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1731 50e7a649 2022-07-22 stsp echo "G alpha" >> $testroot/stdout.expected
1732 50e7a649 2022-07-22 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1733 50e7a649 2022-07-22 stsp >> $testroot/stdout.expected
1734 50e7a649 2022-07-22 stsp echo ": committing more changes on newbranch" \
1735 50e7a649 2022-07-22 stsp >> $testroot/stdout.expected
1736 50e7a649 2022-07-22 stsp echo "Switching work tree to refs/heads/newbranch" \
1737 50e7a649 2022-07-22 stsp >> $testroot/stdout.expected
1738 50e7a649 2022-07-22 stsp
1739 598eac43 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1740 598eac43 2022-07-22 stsp ret=$?
1741 598eac43 2022-07-22 stsp if [ $ret -ne 0 ]; then
1742 598eac43 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1743 50e7a649 2022-07-22 stsp test_done "$testroot" "$ret"
1744 50e7a649 2022-07-22 stsp return 1
1745 598eac43 2022-07-22 stsp fi
1746 50e7a649 2022-07-22 stsp
1747 50e7a649 2022-07-22 stsp # Original commit only had one author
1748 50e7a649 2022-07-22 stsp (cd $testroot/repo && got log -l1 -c $orig_commit2 | \
1749 50e7a649 2022-07-22 stsp egrep '^(from|via):' > $testroot/stdout)
1750 50e7a649 2022-07-22 stsp echo "from: $committer" > $testroot/stdout.expected
1751 50e7a649 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1752 50e7a649 2022-07-22 stsp ret=$?
1753 50e7a649 2022-07-22 stsp if [ $ret -ne 0 ]; then
1754 50e7a649 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1755 50e7a649 2022-07-22 stsp test_done "$testroot" "$ret"
1756 50e7a649 2022-07-22 stsp return 1
1757 50e7a649 2022-07-22 stsp fi
1758 50e7a649 2022-07-22 stsp
1759 50e7a649 2022-07-22 stsp # Author info of rebased commit should match the original
1760 50e7a649 2022-07-22 stsp (cd $testroot/repo && got log -l1 -c $new_commit2 | \
1761 50e7a649 2022-07-22 stsp egrep '^(from|via):' > $testroot/stdout)
1762 50e7a649 2022-07-22 stsp echo "from: $committer" > $testroot/stdout.expected
1763 50e7a649 2022-07-22 stsp
1764 50e7a649 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1765 50e7a649 2022-07-22 stsp ret=$?
1766 50e7a649 2022-07-22 stsp if [ $ret -ne 0 ]; then
1767 50e7a649 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1768 442ede73 2022-09-04 stsp fi
1769 442ede73 2022-09-04 stsp test_done "$testroot" "$ret"
1770 442ede73 2022-09-04 stsp }
1771 442ede73 2022-09-04 stsp
1772 442ede73 2022-09-04 stsp test_rebase_nonbranch() {
1773 442ede73 2022-09-04 stsp local testroot=`test_init rebase_nonbranch`
1774 442ede73 2022-09-04 stsp
1775 442ede73 2022-09-04 stsp got ref -r $testroot/repo -c refs/heads/master \
1776 442ede73 2022-09-04 stsp refs/remotes/origin/master >/dev/null
1777 442ede73 2022-09-04 stsp
1778 442ede73 2022-09-04 stsp got checkout -b master $testroot/repo $testroot/wt >/dev/null
1779 442ede73 2022-09-04 stsp
1780 442ede73 2022-09-04 stsp (cd $testroot/wt && got rebase origin/master > $testroot/stdout \
1781 442ede73 2022-09-04 stsp 2> $testroot/stderr)
1782 442ede73 2022-09-04 stsp ret=$?
1783 442ede73 2022-09-04 stsp if [ $ret -eq 0 ]; then
1784 442ede73 2022-09-04 stsp echo "rebase succeeded unexpectedly" >&2
1785 442ede73 2022-09-04 stsp test_done "$testroot" "1"
1786 442ede73 2022-09-04 stsp return 1
1787 50e7a649 2022-07-22 stsp fi
1788 442ede73 2022-09-04 stsp echo -n "got: will not rebase a branch which lives outside the " \
1789 442ede73 2022-09-04 stsp > $testroot/stderr.expected
1790 442ede73 2022-09-04 stsp echo '"refs/heads/" reference namespace' >> $testroot/stderr.expected
1791 442ede73 2022-09-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1792 442ede73 2022-09-04 stsp ret=$?
1793 442ede73 2022-09-04 stsp if [ $ret -ne 0 ]; then
1794 442ede73 2022-09-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
1795 442ede73 2022-09-04 stsp fi
1796 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
1797 598eac43 2022-07-22 stsp }
1798 b2b3fce1 2022-10-29 op
1799 b2b3fce1 2022-10-29 op test_rebase_umask() {
1800 b2b3fce1 2022-10-29 op local testroot=`test_init rebase_umask`
1801 b2b3fce1 2022-10-29 op local commit0=`git_show_head "$testroot/repo"`
1802 b2b3fce1 2022-10-29 op
1803 b2b3fce1 2022-10-29 op got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1804 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got branch newbranch) >/dev/null
1805 b2b3fce1 2022-10-29 op
1806 b2b3fce1 2022-10-29 op echo "modified alpha on branch" >$testroot/wt/alpha
1807 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got commit -m 'modified alpha on newbranch') \
1808 b2b3fce1 2022-10-29 op >/dev/null
1809 b2b3fce1 2022-10-29 op
1810 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got update -b master) >/dev/null
1811 b2b3fce1 2022-10-29 op ret=$?
1812 b2b3fce1 2022-10-29 op if [ $ret -ne 0 ]; then
1813 b2b3fce1 2022-10-29 op echo "got update failed!" >&2
1814 b2b3fce1 2022-10-29 op test_done "$testroot" $ret
1815 b2b3fce1 2022-10-29 op return 1
1816 b2b3fce1 2022-10-29 op fi
1817 598eac43 2022-07-22 stsp
1818 b2b3fce1 2022-10-29 op echo "modified beta on master" >$testroot/wt/beta
1819 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got commit -m 'modified beta on master') \
1820 b2b3fce1 2022-10-29 op >/dev/null
1821 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got update) >/dev/null
1822 b2b3fce1 2022-10-29 op
1823 b2b3fce1 2022-10-29 op # using a subshell to avoid clobbering global umask
1824 b2b3fce1 2022-10-29 op (umask 077 && cd "$testroot/wt" && got rebase newbranch) >/dev/null
1825 b2b3fce1 2022-10-29 op ret=$?
1826 b2b3fce1 2022-10-29 op if [ $ret -ne 0 ]; then
1827 b2b3fce1 2022-10-29 op echo "got rebase failed" >&2
1828 b2b3fce1 2022-10-29 op test_done "$testroot" $ret
1829 b2b3fce1 2022-10-29 op return 1
1830 b2b3fce1 2022-10-29 op fi
1831 b2b3fce1 2022-10-29 op
1832 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/alpha" | grep -q ^-rw-------
1833 b2b3fce1 2022-10-29 op if [ $? -ne 0 ]; then
1834 b2b3fce1 2022-10-29 op echo "alpha is not 0600 after rebase" >&2
1835 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/alpha" >&2
1836 b2b3fce1 2022-10-29 op test_done "$testroot" 1
1837 b2b3fce1 2022-10-29 op return 1
1838 b2b3fce1 2022-10-29 op fi
1839 b2b3fce1 2022-10-29 op
1840 b2b3fce1 2022-10-29 op test_done "$testroot" 0
1841 49a1ae4b 2023-01-08 stsp }
1842 49a1ae4b 2023-01-08 stsp
1843 49a1ae4b 2023-01-08 stsp test_rebase_out_of_date2() {
1844 49a1ae4b 2023-01-08 stsp local testroot=`test_init rebase_out_of_date2`
1845 49a1ae4b 2023-01-08 stsp local commit0=`git_show_head $testroot/repo`
1846 49a1ae4b 2023-01-08 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1847 49a1ae4b 2023-01-08 stsp
1848 49a1ae4b 2023-01-08 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1849 49a1ae4b 2023-01-08 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1850 49a1ae4b 2023-01-08 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1851 49a1ae4b 2023-01-08 stsp
1852 49a1ae4b 2023-01-08 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1853 49a1ae4b 2023-01-08 stsp local orig_commit2=`git_show_head $testroot/repo`
1854 49a1ae4b 2023-01-08 stsp local orig_author_time2=`git_show_author_time $testroot/repo`
1855 49a1ae4b 2023-01-08 stsp
1856 49a1ae4b 2023-01-08 stsp (cd $testroot/repo && git checkout -q master)
1857 49a1ae4b 2023-01-08 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1858 49a1ae4b 2023-01-08 stsp git_commit $testroot/repo -m "committing to zeta on master"
1859 49a1ae4b 2023-01-08 stsp local master_commit=`git_show_head $testroot/repo`
1860 49a1ae4b 2023-01-08 stsp
1861 49a1ae4b 2023-01-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1862 49a1ae4b 2023-01-08 stsp ret=$?
1863 49a1ae4b 2023-01-08 stsp if [ $ret -ne 0 ]; then
1864 49a1ae4b 2023-01-08 stsp test_done "$testroot" "$ret"
1865 49a1ae4b 2023-01-08 stsp return 1
1866 49a1ae4b 2023-01-08 stsp fi
1867 49a1ae4b 2023-01-08 stsp
1868 49a1ae4b 2023-01-08 stsp # Backdate the file alpha to an earlier version.
1869 49a1ae4b 2023-01-08 stsp # This sets the work tree's base commit ID back to $commit0,
1870 49a1ae4b 2023-01-08 stsp # which is out-of-date with respect to the master branch.
1871 49a1ae4b 2023-01-08 stsp (cd $testroot/wt && got update -c $commit0 alpha > /dev/null)
1872 49a1ae4b 2023-01-08 stsp
1873 49a1ae4b 2023-01-08 stsp # Rebase into an out-of-date work tree should be refused.
1874 49a1ae4b 2023-01-08 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
1875 49a1ae4b 2023-01-08 stsp 2> $testroot/stderr)
1876 49a1ae4b 2023-01-08 stsp ret=$?
1877 49a1ae4b 2023-01-08 stsp if [ $ret -eq 0 ]; then
1878 49a1ae4b 2023-01-08 stsp echo "rebase succeeded unexpectedly" >&2
1879 49a1ae4b 2023-01-08 stsp test_done "$testroot" "1"
1880 49a1ae4b 2023-01-08 stsp return 1
1881 49a1ae4b 2023-01-08 stsp fi
1882 49a1ae4b 2023-01-08 stsp echo -n > $testroot/stdout.expected
1883 49a1ae4b 2023-01-08 stsp echo -n "got: work tree must be updated before it can be used to " \
1884 49a1ae4b 2023-01-08 stsp > $testroot/stderr.expected
1885 49a1ae4b 2023-01-08 stsp echo "rebase a branch" >> $testroot/stderr.expected
1886 49a1ae4b 2023-01-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1887 49a1ae4b 2023-01-08 stsp ret=$?
1888 49a1ae4b 2023-01-08 stsp if [ $ret -ne 0 ]; then
1889 49a1ae4b 2023-01-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
1890 49a1ae4b 2023-01-08 stsp fi
1891 49a1ae4b 2023-01-08 stsp test_done "$testroot" "$ret"
1892 980c6786 2023-01-31 stsp }
1893 980c6786 2023-01-31 stsp
1894 980c6786 2023-01-31 stsp test_rebase_one_commit() {
1895 980c6786 2023-01-31 stsp local testroot=`test_init rebase_one_commit`
1896 980c6786 2023-01-31 stsp
1897 980c6786 2023-01-31 stsp if ! got checkout $testroot/repo $testroot/wt >/dev/null; then
1898 980c6786 2023-01-31 stsp test_done "$testroot" 1
1899 980c6786 2023-01-31 stsp return 1
1900 980c6786 2023-01-31 stsp fi
1901 980c6786 2023-01-31 stsp
1902 980c6786 2023-01-31 stsp (cd $testroot/wt && got branch newbranch) >/dev/null
1903 980c6786 2023-01-31 stsp
1904 980c6786 2023-01-31 stsp echo "modified alpha on newbranch" >$testroot/wt/alpha
1905 980c6786 2023-01-31 stsp (cd $testroot/wt && got commit -m 'edit alpha') >/dev/null
1906 980c6786 2023-01-31 stsp (cd $testroot/wt && got update) >/dev/null
1907 980c6786 2023-01-31 stsp local commit=`git_show_branch_head $testroot/repo newbranch`
1908 980c6786 2023-01-31 stsp
1909 980c6786 2023-01-31 stsp echo -n '' > $testroot/stderr.expected
1910 980c6786 2023-01-31 stsp
1911 980c6786 2023-01-31 stsp (cd $testroot/wt && got rebase master >$testroot/stdout \
1912 980c6786 2023-01-31 stsp 2> $testroot/stderr)
1913 980c6786 2023-01-31 stsp ret=$?
1914 980c6786 2023-01-31 stsp if [ $ret -ne 0 ]; then
1915 980c6786 2023-01-31 stsp echo "rebase comand failed unexpectedly" >&2
1916 980c6786 2023-01-31 stsp diff -u $testroot/stderr.expected $testroot/stderr
1917 980c6786 2023-01-31 stsp test_done "$testroot" "1"
1918 980c6786 2023-01-31 stsp return 1
1919 980c6786 2023-01-31 stsp fi
1920 980c6786 2023-01-31 stsp
1921 980c6786 2023-01-31 stsp echo "Forwarding refs/heads/master to commit $commit" \
1922 980c6786 2023-01-31 stsp >$testroot/stdout.expected
1923 980c6786 2023-01-31 stsp echo "Switching work tree to refs/heads/master" \
1924 980c6786 2023-01-31 stsp >> $testroot/stdout.expected
1925 980c6786 2023-01-31 stsp
1926 980c6786 2023-01-31 stsp if ! cmp -s $testroot/stdout.expected $testroot/stdout; then
1927 980c6786 2023-01-31 stsp diff -u $testroot/stdout.expected $testroot/stdout
1928 980c6786 2023-01-31 stsp test_done "$testroot" 1
1929 980c6786 2023-01-31 stsp return 1
1930 980c6786 2023-01-31 stsp fi
1931 980c6786 2023-01-31 stsp
1932 980c6786 2023-01-31 stsp test_done "$testroot" 0
1933 b2b3fce1 2022-10-29 op }
1934 b2b3fce1 2022-10-29 op
1935 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1936 dcf44d04 2019-07-11 stsp run_test test_rebase_basic
1937 dcf44d04 2019-07-11 stsp run_test test_rebase_ancestry_check
1938 dcf44d04 2019-07-11 stsp run_test test_rebase_continue
1939 dcf44d04 2019-07-11 stsp run_test test_rebase_abort
1940 ff0d2220 2019-07-11 stsp run_test test_rebase_no_op_change
1941 7d5807f4 2019-07-11 stsp run_test test_rebase_in_progress
1942 64c6d990 2019-07-11 stsp run_test test_rebase_path_prefix
1943 787c8eb6 2019-07-11 stsp run_test test_rebase_preserves_logmsg
1944 fc66b545 2019-08-12 stsp run_test test_rebase_no_commits_to_rebase
1945 38b0338b 2019-11-29 stsp run_test test_rebase_forward
1946 0a706d22 2022-09-21 stsp run_test test_rebase_forward_path_prefix
1947 e51d7b55 2020-01-04 stsp run_test test_rebase_out_of_date
1948 1ae0a341 2020-02-14 stsp run_test test_rebase_trims_empty_dir
1949 ca6da77d 2020-03-22 stsp run_test test_rebase_delete_missing_file
1950 70551d57 2020-04-24 stsp run_test test_rebase_rm_add_rm_file
1951 598eac43 2022-07-22 stsp run_test test_rebase_resets_committer
1952 50e7a649 2022-07-22 stsp run_test test_rebase_no_author_info
1953 442ede73 2022-09-04 stsp run_test test_rebase_nonbranch
1954 b2b3fce1 2022-10-29 op run_test test_rebase_umask
1955 49a1ae4b 2023-01-08 stsp run_test test_rebase_out_of_date2
1956 980c6786 2023-01-31 stsp run_test test_rebase_one_commit