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 1b093d84 2023-04-12 stsp echo "modified beta on branch" > $testroot/repo/beta
417 1b093d84 2023-04-12 stsp git_commit $testroot/repo -m "committing to beta 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 1b093d84 2023-04-12 stsp echo "modified alpha on branch" > $testroot/repo/alpha
422 1b093d84 2023-04-12 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
423 1b093d84 2023-04-12 stsp local orig_commit2=`git_show_head $testroot/repo`
424 1b093d84 2023-04-12 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
425 1b093d84 2023-04-12 stsp
426 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
427 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
428 818c7501 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
429 818c7501 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
430 818c7501 2019-07-11 stsp
431 818c7501 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
432 49c543a6 2022-03-31 naddy ret=$?
433 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
434 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
435 818c7501 2019-07-11 stsp return 1
436 818c7501 2019-07-11 stsp fi
437 41f061b2 2021-10-05 stsp
438 41f061b2 2021-10-05 stsp # unrelated unversioned file in work tree
439 41f061b2 2021-10-05 stsp touch $testroot/wt/unversioned-file
440 818c7501 2019-07-11 stsp
441 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
442 818c7501 2019-07-11 stsp 2> $testroot/stderr)
443 818c7501 2019-07-11 stsp
444 1b093d84 2023-04-12 stsp new_commit1=$(cd $testroot/wt && got info beta | \
445 1b093d84 2023-04-12 stsp grep '^based on commit:' | cut -d' ' -f4)
446 1b093d84 2023-04-12 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
447 1b093d84 2023-04-12 stsp
448 1b093d84 2023-04-12 stsp echo "G beta" > $testroot/stdout.expected
449 1b093d84 2023-04-12 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
450 1b093d84 2023-04-12 stsp >> $testroot/stdout.expected
451 1b093d84 2023-04-12 stsp echo ": committing to beta on newbranch" >> $testroot/stdout.expected
452 1b093d84 2023-04-12 stsp echo "C alpha" >> $testroot/stdout.expected
453 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
454 1b093d84 2023-04-12 stsp echo -n "$short_orig_commit2 -> merge conflict" \
455 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
456 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
457 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
458 49c543a6 2022-03-31 naddy ret=$?
459 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
460 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
461 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
462 818c7501 2019-07-11 stsp return 1
463 818c7501 2019-07-11 stsp fi
464 818c7501 2019-07-11 stsp
465 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
466 818c7501 2019-07-11 stsp > $testroot/stderr.expected
467 818c7501 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
468 49c543a6 2022-03-31 naddy ret=$?
469 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
470 818c7501 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
471 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
472 818c7501 2019-07-11 stsp return 1
473 818c7501 2019-07-11 stsp fi
474 818c7501 2019-07-11 stsp
475 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
476 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
477 1b093d84 2023-04-12 stsp echo "||||||| 3-way merge base: commit $orig_commit1" \
478 f69721c3 2019-10-21 stsp >> $testroot/content.expected
479 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
480 818c7501 2019-07-11 stsp echo "=======" >> $testroot/content.expected
481 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
482 1b093d84 2023-04-12 stsp echo ">>>>>>> merged change: commit $orig_commit2" \
483 54d5be07 2021-06-03 stsp >> $testroot/content.expected
484 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
485 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
486 49c543a6 2022-03-31 naddy ret=$?
487 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
488 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
489 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
490 818c7501 2019-07-11 stsp return 1
491 818c7501 2019-07-11 stsp fi
492 818c7501 2019-07-11 stsp
493 818c7501 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
494 818c7501 2019-07-11 stsp
495 818c7501 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
496 41f061b2 2021-10-05 stsp echo "? unversioned-file" >> $testroot/stdout.expected
497 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
498 49c543a6 2022-03-31 naddy ret=$?
499 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
500 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
501 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
502 818c7501 2019-07-11 stsp return 1
503 818c7501 2019-07-11 stsp fi
504 818c7501 2019-07-11 stsp
505 818c7501 2019-07-11 stsp (cd $testroot/wt && got rebase -a > $testroot/stdout)
506 818c7501 2019-07-11 stsp
507 818c7501 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
508 818c7501 2019-07-11 stsp
509 818c7501 2019-07-11 stsp echo "Switching work tree to refs/heads/master" \
510 818c7501 2019-07-11 stsp > $testroot/stdout.expected
511 818c7501 2019-07-11 stsp echo 'R alpha' >> $testroot/stdout.expected
512 1b093d84 2023-04-12 stsp echo 'U beta' >> $testroot/stdout.expected
513 818c7501 2019-07-11 stsp echo "Rebase of refs/heads/newbranch aborted" \
514 818c7501 2019-07-11 stsp >> $testroot/stdout.expected
515 818c7501 2019-07-11 stsp
516 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
517 49c543a6 2022-03-31 naddy ret=$?
518 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
519 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
520 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
521 818c7501 2019-07-11 stsp return 1
522 818c7501 2019-07-11 stsp fi
523 818c7501 2019-07-11 stsp
524 818c7501 2019-07-11 stsp echo "modified alpha on master" > $testroot/content.expected
525 818c7501 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
526 818c7501 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
527 49c543a6 2022-03-31 naddy ret=$?
528 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
529 818c7501 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
530 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
531 818c7501 2019-07-11 stsp return 1
532 818c7501 2019-07-11 stsp fi
533 818c7501 2019-07-11 stsp
534 818c7501 2019-07-11 stsp (cd $testroot/wt && got log -l3 -c newbranch \
535 818c7501 2019-07-11 stsp | grep ^commit > $testroot/stdout)
536 1b093d84 2023-04-12 stsp echo "commit $orig_commit2 (newbranch)" > $testroot/stdout.expected
537 1b093d84 2023-04-12 stsp echo "commit $orig_commit1" >> $testroot/stdout.expected
538 818c7501 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
539 818c7501 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
540 49c543a6 2022-03-31 naddy ret=$?
541 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
542 818c7501 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
543 1b093d84 2023-04-12 stsp test_done "$testroot" "$ret"
544 1b093d84 2023-04-12 stsp return 1
545 818c7501 2019-07-11 stsp fi
546 1b093d84 2023-04-12 stsp
547 1b093d84 2023-04-12 stsp (cd $testroot/wt && got info .| \
548 1b093d84 2023-04-12 stsp grep '^based on commit:' | sort | uniq > $testroot/stdout)
549 1b093d84 2023-04-12 stsp echo "based on commit: $master_commit" > $testroot/stdout.expected
550 1b093d84 2023-04-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
551 1b093d84 2023-04-12 stsp ret=$?
552 1b093d84 2023-04-12 stsp if [ $ret -ne 0 ]; then
553 1b093d84 2023-04-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
554 1b093d84 2023-04-12 stsp test_done "$testroot" "$ret"
555 1b093d84 2023-04-12 stsp return 1
556 1b093d84 2023-04-12 stsp fi
557 1b093d84 2023-04-12 stsp
558 1b093d84 2023-04-12 stsp (cd $testroot/wt && got status > $testroot/stdout)
559 1b093d84 2023-04-12 stsp echo "? unversioned-file" > $testroot/stdout.expected
560 1b093d84 2023-04-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
561 1b093d84 2023-04-12 stsp ret=$?
562 1b093d84 2023-04-12 stsp if [ $ret -ne 0 ]; then
563 1b093d84 2023-04-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
564 1b093d84 2023-04-12 stsp test_done "$testroot" "$ret"
565 1b093d84 2023-04-12 stsp return 1
566 1b093d84 2023-04-12 stsp fi
567 1b093d84 2023-04-12 stsp
568 1b093d84 2023-04-12 stsp cat $testroot/wt/beta > $testroot/content
569 1b093d84 2023-04-12 stsp echo 'beta' > $testroot/content.expected
570 1b093d84 2023-04-12 stsp cmp -s $testroot/content.expected $testroot/content
571 1b093d84 2023-04-12 stsp ret=$?
572 1b093d84 2023-04-12 stsp if [ $ret -ne 0 ]; then
573 1b093d84 2023-04-12 stsp diff -u $testroot/content.expected $testroot/content
574 1b093d84 2023-04-12 stsp test_done "$testroot" "$ret"
575 1b093d84 2023-04-12 stsp return 1
576 1b093d84 2023-04-12 stsp fi
577 1b093d84 2023-04-12 stsp
578 1b093d84 2023-04-12 stsp # A subsequent update should be a no-op.
579 1b093d84 2023-04-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
580 1b093d84 2023-04-12 stsp echo 'Already up-to-date' > $testroot/stdout.expected
581 1b093d84 2023-04-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
582 1b093d84 2023-04-12 stsp ret=$?
583 1b093d84 2023-04-12 stsp if [ $ret -ne 0 ]; then
584 1b093d84 2023-04-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
585 1b093d84 2023-04-12 stsp fi
586 818c7501 2019-07-11 stsp test_done "$testroot" "$ret"
587 818c7501 2019-07-11 stsp }
588 818c7501 2019-07-11 stsp
589 f6cae3ed 2020-09-13 naddy test_rebase_no_op_change() {
590 ff0d2220 2019-07-11 stsp local testroot=`test_init rebase_no_op_change`
591 ff0d2220 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
592 ff0d2220 2019-07-11 stsp
593 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
594 ff0d2220 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
595 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
596 ff0d2220 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
597 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
598 ff0d2220 2019-07-11 stsp
599 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
600 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
601 ff0d2220 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
602 ff0d2220 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
603 ff0d2220 2019-07-11 stsp
604 ff0d2220 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
605 49c543a6 2022-03-31 naddy ret=$?
606 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
607 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
608 ff0d2220 2019-07-11 stsp return 1
609 ff0d2220 2019-07-11 stsp fi
610 ff0d2220 2019-07-11 stsp
611 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
612 ff0d2220 2019-07-11 stsp 2> $testroot/stderr)
613 ff0d2220 2019-07-11 stsp
614 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
615 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
616 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
617 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
618 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
619 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
620 49c543a6 2022-03-31 naddy ret=$?
621 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
622 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
623 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
624 ff0d2220 2019-07-11 stsp return 1
625 ff0d2220 2019-07-11 stsp fi
626 ff0d2220 2019-07-11 stsp
627 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
628 ff0d2220 2019-07-11 stsp > $testroot/stderr.expected
629 ff0d2220 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
630 49c543a6 2022-03-31 naddy ret=$?
631 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
632 ff0d2220 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
633 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
634 ff0d2220 2019-07-11 stsp return 1
635 ff0d2220 2019-07-11 stsp fi
636 ff0d2220 2019-07-11 stsp
637 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
638 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
639 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
640 f69721c3 2019-10-21 stsp >> $testroot/content.expected
641 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
642 ff0d2220 2019-07-11 stsp echo "=======" >> $testroot/content.expected
643 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
644 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
645 54d5be07 2021-06-03 stsp >> $testroot/content.expected
646 ff0d2220 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
647 ff0d2220 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
648 49c543a6 2022-03-31 naddy ret=$?
649 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
650 ff0d2220 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
651 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
652 ff0d2220 2019-07-11 stsp return 1
653 ff0d2220 2019-07-11 stsp fi
654 ff0d2220 2019-07-11 stsp
655 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
656 ff0d2220 2019-07-11 stsp
657 ff0d2220 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
658 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
659 49c543a6 2022-03-31 naddy ret=$?
660 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
661 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
662 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
663 ff0d2220 2019-07-11 stsp return 1
664 ff0d2220 2019-07-11 stsp fi
665 ff0d2220 2019-07-11 stsp
666 ff0d2220 2019-07-11 stsp # resolve the conflict
667 ff0d2220 2019-07-11 stsp echo "modified alpha on master" > $testroot/wt/alpha
668 ff0d2220 2019-07-11 stsp
669 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
670 ff0d2220 2019-07-11 stsp
671 ff0d2220 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
672 ff0d2220 2019-07-11 stsp local new_commit1=`git_show_head $testroot/repo`
673 ff0d2220 2019-07-11 stsp
674 ff0d2220 2019-07-11 stsp echo -n "$short_orig_commit1 -> no-op change" \
675 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
676 ff0d2220 2019-07-11 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
677 ff0d2220 2019-07-11 stsp echo "Switching work tree to refs/heads/newbranch" \
678 ff0d2220 2019-07-11 stsp >> $testroot/stdout.expected
679 ff0d2220 2019-07-11 stsp
680 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
681 49c543a6 2022-03-31 naddy ret=$?
682 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
683 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
684 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
685 ff0d2220 2019-07-11 stsp return 1
686 ff0d2220 2019-07-11 stsp fi
687 ff0d2220 2019-07-11 stsp
688 ff0d2220 2019-07-11 stsp
689 ff0d2220 2019-07-11 stsp (cd $testroot/wt && got log -l2 | grep ^commit > $testroot/stdout)
690 ff0d2220 2019-07-11 stsp echo "commit $master_commit (master, newbranch)" \
691 ff0d2220 2019-07-11 stsp > $testroot/stdout.expected
692 ff0d2220 2019-07-11 stsp echo "commit $init_commit" >> $testroot/stdout.expected
693 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
694 49c543a6 2022-03-31 naddy ret=$?
695 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
696 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
697 7d5807f4 2019-07-11 stsp fi
698 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
699 7d5807f4 2019-07-11 stsp }
700 7d5807f4 2019-07-11 stsp
701 f6cae3ed 2020-09-13 naddy test_rebase_in_progress() {
702 4ba9c4f6 2019-07-11 stsp local testroot=`test_init rebase_in_progress`
703 7d5807f4 2019-07-11 stsp local init_commit=`git_show_head $testroot/repo`
704 7d5807f4 2019-07-11 stsp
705 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
706 7d5807f4 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
707 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on newbranch"
708 7d5807f4 2019-07-11 stsp local orig_commit1=`git_show_head $testroot/repo`
709 a0ea4fc0 2020-02-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
710 7d5807f4 2019-07-11 stsp
711 7d5807f4 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
712 7d5807f4 2019-07-11 stsp echo "modified alpha on master" > $testroot/repo/alpha
713 7d5807f4 2019-07-11 stsp git_commit $testroot/repo -m "committing to alpha on master"
714 7d5807f4 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
715 7d5807f4 2019-07-11 stsp
716 7d5807f4 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
717 49c543a6 2022-03-31 naddy ret=$?
718 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
719 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
720 7d5807f4 2019-07-11 stsp return 1
721 7d5807f4 2019-07-11 stsp fi
722 7d5807f4 2019-07-11 stsp
723 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
724 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
725 7d5807f4 2019-07-11 stsp
726 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
727 9627c110 2020-04-18 stsp echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
728 a0ea4fc0 2020-02-28 stsp echo -n "$short_orig_commit1 -> merge conflict" \
729 a0ea4fc0 2020-02-28 stsp >> $testroot/stdout.expected
730 a0ea4fc0 2020-02-28 stsp echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
731 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
732 49c543a6 2022-03-31 naddy ret=$?
733 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
734 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
735 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
736 7d5807f4 2019-07-11 stsp return 1
737 7d5807f4 2019-07-11 stsp fi
738 7d5807f4 2019-07-11 stsp
739 11495e04 2019-07-12 stsp echo "got: conflicts must be resolved before rebasing can continue" \
740 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
741 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
742 49c543a6 2022-03-31 naddy ret=$?
743 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
744 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
745 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
746 7d5807f4 2019-07-11 stsp return 1
747 7d5807f4 2019-07-11 stsp fi
748 7d5807f4 2019-07-11 stsp
749 54d5be07 2021-06-03 stsp echo '<<<<<<<' > $testroot/content.expected
750 54d5be07 2021-06-03 stsp echo "modified alpha on master" >> $testroot/content.expected
751 f69721c3 2019-10-21 stsp echo "||||||| 3-way merge base: commit $init_commit" \
752 f69721c3 2019-10-21 stsp >> $testroot/content.expected
753 d136cfcb 2019-10-12 stsp echo "alpha" >> $testroot/content.expected
754 7d5807f4 2019-07-11 stsp echo "=======" >> $testroot/content.expected
755 54d5be07 2021-06-03 stsp echo "modified alpha on branch" >> $testroot/content.expected
756 54d5be07 2021-06-03 stsp echo ">>>>>>> merged change: commit $orig_commit1" \
757 54d5be07 2021-06-03 stsp >> $testroot/content.expected
758 7d5807f4 2019-07-11 stsp cat $testroot/wt/alpha > $testroot/content
759 7d5807f4 2019-07-11 stsp cmp -s $testroot/content.expected $testroot/content
760 49c543a6 2022-03-31 naddy ret=$?
761 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
762 7d5807f4 2019-07-11 stsp diff -u $testroot/content.expected $testroot/content
763 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
764 7d5807f4 2019-07-11 stsp return 1
765 7d5807f4 2019-07-11 stsp fi
766 7d5807f4 2019-07-11 stsp
767 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got status > $testroot/stdout)
768 7d5807f4 2019-07-11 stsp
769 7d5807f4 2019-07-11 stsp echo "C alpha" > $testroot/stdout.expected
770 ff0d2220 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
771 49c543a6 2022-03-31 naddy ret=$?
772 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
773 ff0d2220 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
774 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
775 7d5807f4 2019-07-11 stsp return 1
776 ff0d2220 2019-07-11 stsp fi
777 7d5807f4 2019-07-11 stsp
778 7d5807f4 2019-07-11 stsp for cmd in update commit; do
779 7d5807f4 2019-07-11 stsp (cd $testroot/wt && got $cmd > $testroot/stdout \
780 7d5807f4 2019-07-11 stsp 2> $testroot/stderr)
781 7d5807f4 2019-07-11 stsp
782 7d5807f4 2019-07-11 stsp echo -n > $testroot/stdout.expected
783 7d5807f4 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
784 49c543a6 2022-03-31 naddy ret=$?
785 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
786 7d5807f4 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
787 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
788 7d5807f4 2019-07-11 stsp return 1
789 7d5807f4 2019-07-11 stsp fi
790 7d5807f4 2019-07-11 stsp
791 7d5807f4 2019-07-11 stsp echo -n "got: a rebase operation is in progress in this " \
792 7d5807f4 2019-07-11 stsp > $testroot/stderr.expected
793 7d5807f4 2019-07-11 stsp echo "work tree and must be continued or aborted first" \
794 7d5807f4 2019-07-11 stsp >> $testroot/stderr.expected
795 7d5807f4 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
796 49c543a6 2022-03-31 naddy ret=$?
797 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
798 7d5807f4 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
799 7d5807f4 2019-07-11 stsp test_done "$testroot" "$ret"
800 7d5807f4 2019-07-11 stsp return 1
801 7d5807f4 2019-07-11 stsp fi
802 7d5807f4 2019-07-11 stsp done
803 64c6d990 2019-07-11 stsp
804 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
805 64c6d990 2019-07-11 stsp }
806 64c6d990 2019-07-11 stsp
807 f6cae3ed 2020-09-13 naddy test_rebase_path_prefix() {
808 64c6d990 2019-07-11 stsp local testroot=`test_init rebase_path_prefix`
809 64c6d990 2019-07-11 stsp
810 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
811 64c6d990 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
812 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
813 64c6d990 2019-07-11 stsp
814 64c6d990 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
815 64c6d990 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
816 64c6d990 2019-07-11 stsp
817 64c6d990 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
818 64c6d990 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
819 64c6d990 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
820 64c6d990 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
821 64c6d990 2019-07-11 stsp
822 64c6d990 2019-07-11 stsp got checkout -p epsilon $testroot/repo $testroot/wt > /dev/null
823 49c543a6 2022-03-31 naddy ret=$?
824 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
825 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
826 64c6d990 2019-07-11 stsp return 1
827 64c6d990 2019-07-11 stsp fi
828 7d5807f4 2019-07-11 stsp
829 64c6d990 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch \
830 64c6d990 2019-07-11 stsp > $testroot/stdout 2> $testroot/stderr)
831 64c6d990 2019-07-11 stsp
832 64c6d990 2019-07-11 stsp echo -n > $testroot/stdout.expected
833 64c6d990 2019-07-11 stsp cmp -s $testroot/stdout.expected $testroot/stdout
834 49c543a6 2022-03-31 naddy ret=$?
835 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
836 64c6d990 2019-07-11 stsp diff -u $testroot/stdout.expected $testroot/stdout
837 64c6d990 2019-07-11 stsp test_done "$testroot" "$ret"
838 64c6d990 2019-07-11 stsp return 1
839 64c6d990 2019-07-11 stsp fi
840 64c6d990 2019-07-11 stsp
841 64c6d990 2019-07-11 stsp echo -n "got: cannot rebase branch which contains changes outside " \
842 64c6d990 2019-07-11 stsp > $testroot/stderr.expected
843 64c6d990 2019-07-11 stsp echo "of this work tree's path prefix" >> $testroot/stderr.expected
844 787c8eb6 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
845 49c543a6 2022-03-31 naddy ret=$?
846 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
847 787c8eb6 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
848 67ba6161 2022-04-08 stsp test_done "$testroot" "$ret"
849 67ba6161 2022-04-08 stsp return 1
850 67ba6161 2022-04-08 stsp fi
851 67ba6161 2022-04-08 stsp
852 67ba6161 2022-04-08 stsp # rebase should succeed when using a complete work tree
853 67ba6161 2022-04-08 stsp got checkout $testroot/repo $testroot/wt2 > /dev/null
854 67ba6161 2022-04-08 stsp ret=$?
855 67ba6161 2022-04-08 stsp if [ $ret -ne 0 ]; then
856 67ba6161 2022-04-08 stsp test_done "$testroot" "$ret"
857 67ba6161 2022-04-08 stsp return 1
858 67ba6161 2022-04-08 stsp fi
859 67ba6161 2022-04-08 stsp
860 67ba6161 2022-04-08 stsp (cd $testroot/wt2 && got rebase newbranch \
861 67ba6161 2022-04-08 stsp > $testroot/stdout 2> $testroot/stderr)
862 67ba6161 2022-04-08 stsp
863 67ba6161 2022-04-08 stsp (cd $testroot/repo && git checkout -q newbranch)
864 67ba6161 2022-04-08 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
865 67ba6161 2022-04-08 stsp local new_commit2=`git_show_head $testroot/repo`
866 67ba6161 2022-04-08 stsp
867 67ba6161 2022-04-08 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
868 67ba6161 2022-04-08 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
869 67ba6161 2022-04-08 stsp
870 67ba6161 2022-04-08 stsp echo "G gamma/delta" > $testroot/stdout.expected
871 67ba6161 2022-04-08 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
872 67ba6161 2022-04-08 stsp >> $testroot/stdout.expected
873 67ba6161 2022-04-08 stsp echo ": committing to delta on newbranch" \
874 67ba6161 2022-04-08 stsp >> $testroot/stdout.expected
875 67ba6161 2022-04-08 stsp echo "Switching work tree to refs/heads/newbranch" \
876 67ba6161 2022-04-08 stsp >> $testroot/stdout.expected
877 67ba6161 2022-04-08 stsp
878 67ba6161 2022-04-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
879 67ba6161 2022-04-08 stsp ret=$?
880 67ba6161 2022-04-08 stsp if [ $ret -ne 0 ]; then
881 67ba6161 2022-04-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
882 67ba6161 2022-04-08 stsp test_done "$testroot" "$ret"
883 67ba6161 2022-04-08 stsp return 1
884 787c8eb6 2019-07-11 stsp fi
885 67ba6161 2022-04-08 stsp
886 67ba6161 2022-04-08 stsp # the first work tree should remain usable
887 67ba6161 2022-04-08 stsp (cd $testroot/wt && got update -b master \
888 67ba6161 2022-04-08 stsp > $testroot/stdout 2> $testroot/stderr)
889 67ba6161 2022-04-08 stsp ret=$?
890 67ba6161 2022-04-08 stsp if [ $ret -ne 0 ]; then
891 67ba6161 2022-04-08 stsp echo "update failed unexpectedly" >&2
892 67ba6161 2022-04-08 stsp test_done "$testroot" "1"
893 67ba6161 2022-04-08 stsp return 1
894 67ba6161 2022-04-08 stsp fi
895 67ba6161 2022-04-08 stsp
896 67ba6161 2022-04-08 stsp echo 'Already up-to-date' > $testroot/stdout.expected
897 67ba6161 2022-04-08 stsp cmp -s $testroot/stdout.expected $testroot/stdout
898 67ba6161 2022-04-08 stsp ret=$?
899 67ba6161 2022-04-08 stsp if [ $ret -ne 0 ]; then
900 67ba6161 2022-04-08 stsp diff -u $testroot/stdout.expected $testroot/stdout
901 67ba6161 2022-04-08 stsp fi
902 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
903 787c8eb6 2019-07-11 stsp }
904 787c8eb6 2019-07-11 stsp
905 f6cae3ed 2020-09-13 naddy test_rebase_preserves_logmsg() {
906 787c8eb6 2019-07-11 stsp local testroot=`test_init rebase_preserves_logmsg`
907 787c8eb6 2019-07-11 stsp
908 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q -b newbranch)
909 787c8eb6 2019-07-11 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
910 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified delta on newbranch"
911 787c8eb6 2019-07-11 stsp
912 787c8eb6 2019-07-11 stsp echo "modified alpha on branch" > $testroot/repo/alpha
913 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "modified alpha on newbranch"
914 787c8eb6 2019-07-11 stsp
915 787c8eb6 2019-07-11 stsp (cd $testroot/repo && got log -c newbranch -l2 | grep -v ^date: \
916 787c8eb6 2019-07-11 stsp > $testroot/log.expected)
917 787c8eb6 2019-07-11 stsp
918 787c8eb6 2019-07-11 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
919 787c8eb6 2019-07-11 stsp local orig_commit2=`git_show_head $testroot/repo`
920 787c8eb6 2019-07-11 stsp
921 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q master)
922 787c8eb6 2019-07-11 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
923 787c8eb6 2019-07-11 stsp git_commit $testroot/repo -m "committing to zeta on master"
924 787c8eb6 2019-07-11 stsp local master_commit=`git_show_head $testroot/repo`
925 787c8eb6 2019-07-11 stsp
926 787c8eb6 2019-07-11 stsp got checkout $testroot/repo $testroot/wt > /dev/null
927 49c543a6 2022-03-31 naddy ret=$?
928 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
929 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
930 787c8eb6 2019-07-11 stsp return 1
931 787c8eb6 2019-07-11 stsp fi
932 787c8eb6 2019-07-11 stsp
933 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got rebase newbranch > /dev/null \
934 787c8eb6 2019-07-11 stsp 2> $testroot/stderr)
935 787c8eb6 2019-07-11 stsp
936 787c8eb6 2019-07-11 stsp (cd $testroot/repo && git checkout -q newbranch)
937 787c8eb6 2019-07-11 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
938 787c8eb6 2019-07-11 stsp local new_commit2=`git_show_head $testroot/repo`
939 787c8eb6 2019-07-11 stsp
940 787c8eb6 2019-07-11 stsp echo -n > $testroot/stderr.expected
941 64c6d990 2019-07-11 stsp cmp -s $testroot/stderr.expected $testroot/stderr
942 49c543a6 2022-03-31 naddy ret=$?
943 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
944 64c6d990 2019-07-11 stsp diff -u $testroot/stderr.expected $testroot/stderr
945 787c8eb6 2019-07-11 stsp test_done "$testroot" "$ret"
946 787c8eb6 2019-07-11 stsp return 1
947 64c6d990 2019-07-11 stsp fi
948 787c8eb6 2019-07-11 stsp
949 787c8eb6 2019-07-11 stsp (cd $testroot/wt && got log -c newbranch -l2 | grep -v ^date: \
950 787c8eb6 2019-07-11 stsp > $testroot/log)
951 885e96df 2023-03-06 naddy ed -s $testroot/log.expected <<-EOF
952 885e96df 2023-03-06 naddy ,s/$orig_commit1/$new_commit1/
953 885e96df 2023-03-06 naddy ,s/$orig_commit2/$new_commit2/
954 885e96df 2023-03-06 naddy w
955 885e96df 2023-03-06 naddy EOF
956 787c8eb6 2019-07-11 stsp cmp -s $testroot/log.expected $testroot/log
957 49c543a6 2022-03-31 naddy ret=$?
958 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
959 787c8eb6 2019-07-11 stsp diff -u $testroot/log.expected $testroot/log
960 fc66b545 2019-08-12 stsp fi
961 fc66b545 2019-08-12 stsp
962 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
963 fc66b545 2019-08-12 stsp }
964 fc66b545 2019-08-12 stsp
965 f6cae3ed 2020-09-13 naddy test_rebase_no_commits_to_rebase() {
966 fc66b545 2019-08-12 stsp local testroot=`test_init rebase_no_commits_to_rebase`
967 fc66b545 2019-08-12 stsp
968 fc66b545 2019-08-12 stsp got checkout $testroot/repo $testroot/wt > /dev/null
969 49c543a6 2022-03-31 naddy ret=$?
970 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
971 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
972 fc66b545 2019-08-12 stsp return 1
973 fc66b545 2019-08-12 stsp fi
974 fc66b545 2019-08-12 stsp
975 980c6786 2023-01-31 stsp # Create an unrelated branch with 'got import'.
976 980c6786 2023-01-31 stsp mkdir -p $testroot/newtree
977 980c6786 2023-01-31 stsp echo "new file" > $testroot/newtree/newfile
978 980c6786 2023-01-31 stsp got import -m new -b newbranch -r $testroot/repo \
979 980c6786 2023-01-31 stsp $testroot/newtree > /dev/null
980 fc66b545 2019-08-12 stsp
981 fc66b545 2019-08-12 stsp echo "modified alpha on master" > $testroot/wt/alpha
982 fc66b545 2019-08-12 stsp (cd $testroot/wt && got commit -m 'test rebase_no_commits_to_rebase' \
983 fc66b545 2019-08-12 stsp > /dev/null)
984 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > /dev/null)
985 fc66b545 2019-08-12 stsp
986 fc66b545 2019-08-12 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
987 fc66b545 2019-08-12 stsp 2> $testroot/stderr)
988 fc66b545 2019-08-12 stsp
989 980c6786 2023-01-31 stsp echo -n "got: specified branch shares no common ancestry " \
990 980c6786 2023-01-31 stsp > $testroot/stderr.expected
991 980c6786 2023-01-31 stsp echo "with work tree's branch" >> $testroot/stderr.expected
992 fc66b545 2019-08-12 stsp cmp -s $testroot/stderr.expected $testroot/stderr
993 49c543a6 2022-03-31 naddy ret=$?
994 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
995 fc66b545 2019-08-12 stsp diff -u $testroot/stderr.expected $testroot/stderr
996 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
997 fc66b545 2019-08-12 stsp return 1
998 787c8eb6 2019-07-11 stsp fi
999 787c8eb6 2019-07-11 stsp
1000 67ba6161 2022-04-08 stsp echo -n > $testroot/stdout.expected
1001 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1002 49c543a6 2022-03-31 naddy ret=$?
1003 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1004 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
1005 fc66b545 2019-08-12 stsp test_done "$testroot" "$ret"
1006 fc66b545 2019-08-12 stsp return 1
1007 fc66b545 2019-08-12 stsp fi
1008 fc66b545 2019-08-12 stsp
1009 fc66b545 2019-08-12 stsp (cd $testroot/wt && got update > $testroot/stdout)
1010 fc66b545 2019-08-12 stsp echo "Already up-to-date" > $testroot/stdout.expected
1011 fc66b545 2019-08-12 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1012 49c543a6 2022-03-31 naddy ret=$?
1013 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1014 fc66b545 2019-08-12 stsp diff -u $testroot/stdout.expected $testroot/stdout
1015 fc66b545 2019-08-12 stsp fi
1016 ff0d2220 2019-07-11 stsp test_done "$testroot" "$ret"
1017 ff0d2220 2019-07-11 stsp }
1018 38b0338b 2019-11-29 stsp
1019 f6cae3ed 2020-09-13 naddy test_rebase_forward() {
1020 38b0338b 2019-11-29 stsp local testroot=`test_init rebase_forward`
1021 38b0338b 2019-11-29 stsp local commit0=`git_show_head $testroot/repo`
1022 38b0338b 2019-11-29 stsp
1023 38b0338b 2019-11-29 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1024 49c543a6 2022-03-31 naddy ret=$?
1025 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1026 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1027 38b0338b 2019-11-29 stsp return 1
1028 38b0338b 2019-11-29 stsp fi
1029 38b0338b 2019-11-29 stsp
1030 38b0338b 2019-11-29 stsp echo "change alpha 1" > $testroot/wt/alpha
1031 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
1032 38b0338b 2019-11-29 stsp > /dev/null)
1033 38b0338b 2019-11-29 stsp local commit1=`git_show_head $testroot/repo`
1034 ff0d2220 2019-07-11 stsp
1035 38b0338b 2019-11-29 stsp echo "change alpha 2" > $testroot/wt/alpha
1036 38b0338b 2019-11-29 stsp (cd $testroot/wt && got commit -m 'test rebase_forward' \
1037 38b0338b 2019-11-29 stsp > /dev/null)
1038 38b0338b 2019-11-29 stsp local commit2=`git_show_head $testroot/repo`
1039 38b0338b 2019-11-29 stsp
1040 5e91dae4 2022-08-30 stsp # Simulate a situation where fast-forward is required.
1041 38b0338b 2019-11-29 stsp # We want to fast-forward master to origin/master:
1042 38b0338b 2019-11-29 stsp # commit 3907e11dceaae2ca7f8db79c2af31794673945ad (origin/master)
1043 38b0338b 2019-11-29 stsp # commit ffcffcd102cf1af6572fbdbb4cf07a0f1fd2d840 (master)
1044 38b0338b 2019-11-29 stsp # commit 87a6a8a2263a15b61c016ff1720b24741d455eb5
1045 993f033b 2021-07-16 stsp (cd $testroot/repo && got ref -d master >/dev/null)
1046 e31abbf2 2020-03-22 stsp (cd $testroot/repo && got ref -c $commit1 refs/heads/master)
1047 e31abbf2 2020-03-22 stsp (cd $testroot/repo && got ref -c $commit2 refs/remotes/origin/master)
1048 38b0338b 2019-11-29 stsp
1049 38b0338b 2019-11-29 stsp (cd $testroot/wt && got up -b origin/master > /dev/null)
1050 38b0338b 2019-11-29 stsp
1051 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase master \
1052 0a706d22 2022-09-21 stsp > $testroot/stdout 2> $testroot/stderr)
1053 0a706d22 2022-09-21 stsp
1054 0a706d22 2022-09-21 stsp echo "Forwarding refs/heads/master to commit $commit2" \
1055 0a706d22 2022-09-21 stsp > $testroot/stdout.expected
1056 0a706d22 2022-09-21 stsp echo "Switching work tree to refs/heads/master" \
1057 0a706d22 2022-09-21 stsp >> $testroot/stdout.expected
1058 0a706d22 2022-09-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1059 0a706d22 2022-09-21 stsp ret=$?
1060 0a706d22 2022-09-21 stsp if [ $ret -ne 0 ]; then
1061 0a706d22 2022-09-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1062 0a706d22 2022-09-21 stsp test_done "$testroot" "$ret"
1063 0a706d22 2022-09-21 stsp return 1
1064 0a706d22 2022-09-21 stsp fi
1065 0a706d22 2022-09-21 stsp
1066 0a706d22 2022-09-21 stsp # Ensure that rebase operation was completed correctly
1067 0a706d22 2022-09-21 stsp (cd $testroot/wt && got rebase -a \
1068 0a706d22 2022-09-21 stsp > $testroot/stdout 2> $testroot/stderr)
1069 0a706d22 2022-09-21 stsp echo -n "" > $testroot/stdout.expected
1070 0a706d22 2022-09-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1071 0a706d22 2022-09-21 stsp ret=$?
1072 0a706d22 2022-09-21 stsp if [ $ret -ne 0 ]; then
1073 0a706d22 2022-09-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1074 0a706d22 2022-09-21 stsp test_done "$testroot" "$ret"
1075 0a706d22 2022-09-21 stsp return 1
1076 0a706d22 2022-09-21 stsp fi
1077 0a706d22 2022-09-21 stsp echo "got: rebase operation not in progress" > $testroot/stderr.expected
1078 0a706d22 2022-09-21 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1079 0a706d22 2022-09-21 stsp ret=$?
1080 0a706d22 2022-09-21 stsp if [ $ret -ne 0 ]; then
1081 0a706d22 2022-09-21 stsp diff -u $testroot/stderr.expected $testroot/stderr
1082 0a706d22 2022-09-21 stsp test_done "$testroot" "$ret"
1083 0a706d22 2022-09-21 stsp return 1
1084 0a706d22 2022-09-21 stsp fi
1085 0a706d22 2022-09-21 stsp
1086 0a706d22 2022-09-21 stsp (cd $testroot/wt && got branch -n > $testroot/stdout)
1087 0a706d22 2022-09-21 stsp echo "master" > $testroot/stdout.expected
1088 0a706d22 2022-09-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1089 0a706d22 2022-09-21 stsp ret=$?
1090 0a706d22 2022-09-21 stsp if [ $ret -ne 0 ]; then
1091 0a706d22 2022-09-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1092 0a706d22 2022-09-21 stsp test_done "$testroot" "$ret"
1093 0a706d22 2022-09-21 stsp return 1
1094 0a706d22 2022-09-21 stsp fi
1095 0a706d22 2022-09-21 stsp
1096 0a706d22 2022-09-21 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1097 0a706d22 2022-09-21 stsp echo "commit $commit2 (master, origin/master)" > $testroot/stdout.expected
1098 0a706d22 2022-09-21 stsp echo "commit $commit1" >> $testroot/stdout.expected
1099 0a706d22 2022-09-21 stsp echo "commit $commit0" >> $testroot/stdout.expected
1100 0a706d22 2022-09-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1101 0a706d22 2022-09-21 stsp ret=$?
1102 0a706d22 2022-09-21 stsp if [ $ret -ne 0 ]; then
1103 0a706d22 2022-09-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1104 0a706d22 2022-09-21 stsp test_done "$testroot" "$ret"
1105 0a706d22 2022-09-21 stsp return 1
1106 0a706d22 2022-09-21 stsp fi
1107 0a706d22 2022-09-21 stsp
1108 0a706d22 2022-09-21 stsp # Forward-only rebase operations should not be backed up
1109 0a706d22 2022-09-21 stsp (cd $testroot/repo && got rebase -l > $testroot/stdout)
1110 0a706d22 2022-09-21 stsp echo -n > $testroot/stdout.expected
1111 0a706d22 2022-09-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1112 0a706d22 2022-09-21 stsp ret=$?
1113 0a706d22 2022-09-21 stsp if [ $ret -ne 0 ]; then
1114 0a706d22 2022-09-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1115 0a706d22 2022-09-21 stsp fi
1116 0a706d22 2022-09-21 stsp test_done "$testroot" "$ret"
1117 0a706d22 2022-09-21 stsp }
1118 0a706d22 2022-09-21 stsp
1119 0a706d22 2022-09-21 stsp test_rebase_forward_path_prefix() {
1120 0a706d22 2022-09-21 stsp local testroot=`test_init rebase_forward_path_prefix`
1121 0a706d22 2022-09-21 stsp local commit0=`git_show_head $testroot/repo`
1122 0a706d22 2022-09-21 stsp
1123 0a706d22 2022-09-21 stsp got checkout $testroot/repo $testroot/wt-full > /dev/null
1124 0a706d22 2022-09-21 stsp ret=$?
1125 0a706d22 2022-09-21 stsp if [ $ret -ne 0 ]; then
1126 0a706d22 2022-09-21 stsp test_done "$testroot" "$ret"
1127 0a706d22 2022-09-21 stsp return 1
1128 0a706d22 2022-09-21 stsp fi
1129 0a706d22 2022-09-21 stsp
1130 0a706d22 2022-09-21 stsp echo "change alpha 1" > $testroot/wt-full/alpha
1131 0a706d22 2022-09-21 stsp (cd $testroot/wt-full && got commit -m 'test rebase_forward' \
1132 0a706d22 2022-09-21 stsp > /dev/null)
1133 0a706d22 2022-09-21 stsp local commit1=`git_show_head $testroot/repo`
1134 0a706d22 2022-09-21 stsp
1135 0a706d22 2022-09-21 stsp echo "change alpha 2" > $testroot/wt-full/alpha
1136 0a706d22 2022-09-21 stsp (cd $testroot/wt-full && got commit -m 'test rebase_forward' \
1137 0a706d22 2022-09-21 stsp > /dev/null)
1138 0a706d22 2022-09-21 stsp local commit2=`git_show_head $testroot/repo`
1139 0a706d22 2022-09-21 stsp
1140 0a706d22 2022-09-21 stsp # Simulate a situation where fast-forward is required.
1141 0a706d22 2022-09-21 stsp # We want to fast-forward master to origin/master:
1142 0a706d22 2022-09-21 stsp # commit 3907e11dceaae2ca7f8db79c2af31794673945ad (origin/master)
1143 0a706d22 2022-09-21 stsp # commit ffcffcd102cf1af6572fbdbb4cf07a0f1fd2d840 (master)
1144 0a706d22 2022-09-21 stsp # commit 87a6a8a2263a15b61c016ff1720b24741d455eb5
1145 0a706d22 2022-09-21 stsp (cd $testroot/repo && got ref -d master >/dev/null)
1146 0a706d22 2022-09-21 stsp (cd $testroot/repo && got ref -c $commit1 refs/heads/master)
1147 0a706d22 2022-09-21 stsp (cd $testroot/repo && got ref -c $commit2 refs/remotes/origin/master)
1148 0a706d22 2022-09-21 stsp
1149 0a706d22 2022-09-21 stsp # Work tree which uses a path-prefix and will be used for rebasing
1150 0a706d22 2022-09-21 stsp got checkout -p epsilon -b origin/master $testroot/repo $testroot/wt \
1151 0a706d22 2022-09-21 stsp > /dev/null
1152 0a706d22 2022-09-21 stsp ret=$?
1153 0a706d22 2022-09-21 stsp if [ $ret -ne 0 ]; then
1154 0a706d22 2022-09-21 stsp test_done "$testroot" "$ret"
1155 0a706d22 2022-09-21 stsp return 1
1156 0a706d22 2022-09-21 stsp fi
1157 0a706d22 2022-09-21 stsp
1158 2c75f174 2022-10-24 naddy (cd $testroot/wt && got rebase master \
1159 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
1160 38b0338b 2019-11-29 stsp
1161 38b0338b 2019-11-29 stsp echo "Forwarding refs/heads/master to commit $commit2" \
1162 38b0338b 2019-11-29 stsp > $testroot/stdout.expected
1163 38b0338b 2019-11-29 stsp echo "Switching work tree to refs/heads/master" \
1164 38b0338b 2019-11-29 stsp >> $testroot/stdout.expected
1165 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1166 49c543a6 2022-03-31 naddy ret=$?
1167 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1168 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
1169 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1170 38b0338b 2019-11-29 stsp return 1
1171 38b0338b 2019-11-29 stsp fi
1172 38b0338b 2019-11-29 stsp
1173 38b0338b 2019-11-29 stsp # Ensure that rebase operation was completed correctly
1174 38b0338b 2019-11-29 stsp (cd $testroot/wt && got rebase -a \
1175 38b0338b 2019-11-29 stsp > $testroot/stdout 2> $testroot/stderr)
1176 38b0338b 2019-11-29 stsp echo -n "" > $testroot/stdout.expected
1177 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1178 49c543a6 2022-03-31 naddy ret=$?
1179 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1180 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
1181 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1182 38b0338b 2019-11-29 stsp return 1
1183 38b0338b 2019-11-29 stsp fi
1184 38b0338b 2019-11-29 stsp echo "got: rebase operation not in progress" > $testroot/stderr.expected
1185 38b0338b 2019-11-29 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1186 49c543a6 2022-03-31 naddy ret=$?
1187 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1188 38b0338b 2019-11-29 stsp diff -u $testroot/stderr.expected $testroot/stderr
1189 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1190 38b0338b 2019-11-29 stsp return 1
1191 38b0338b 2019-11-29 stsp fi
1192 38b0338b 2019-11-29 stsp
1193 da76fce2 2020-02-24 stsp (cd $testroot/wt && got branch -n > $testroot/stdout)
1194 38b0338b 2019-11-29 stsp echo "master" > $testroot/stdout.expected
1195 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1196 49c543a6 2022-03-31 naddy ret=$?
1197 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1198 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
1199 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1200 38b0338b 2019-11-29 stsp return 1
1201 38b0338b 2019-11-29 stsp fi
1202 38b0338b 2019-11-29 stsp
1203 38b0338b 2019-11-29 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1204 38b0338b 2019-11-29 stsp echo "commit $commit2 (master, origin/master)" > $testroot/stdout.expected
1205 38b0338b 2019-11-29 stsp echo "commit $commit1" >> $testroot/stdout.expected
1206 38b0338b 2019-11-29 stsp echo "commit $commit0" >> $testroot/stdout.expected
1207 38b0338b 2019-11-29 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1208 49c543a6 2022-03-31 naddy ret=$?
1209 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1210 38b0338b 2019-11-29 stsp diff -u $testroot/stdout.expected $testroot/stdout
1211 e600f124 2021-03-21 stsp test_done "$testroot" "$ret"
1212 a9662115 2021-08-29 naddy return 1
1213 38b0338b 2019-11-29 stsp fi
1214 e600f124 2021-03-21 stsp
1215 e600f124 2021-03-21 stsp # Forward-only rebase operations should not be backed up
1216 e600f124 2021-03-21 stsp (cd $testroot/repo && got rebase -l > $testroot/stdout)
1217 e600f124 2021-03-21 stsp echo -n > $testroot/stdout.expected
1218 e600f124 2021-03-21 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1219 49c543a6 2022-03-31 naddy ret=$?
1220 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1221 e600f124 2021-03-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
1222 e600f124 2021-03-21 stsp fi
1223 38b0338b 2019-11-29 stsp test_done "$testroot" "$ret"
1224 38b0338b 2019-11-29 stsp }
1225 e51d7b55 2020-01-04 stsp
1226 f6cae3ed 2020-09-13 naddy test_rebase_out_of_date() {
1227 e51d7b55 2020-01-04 stsp local testroot=`test_init rebase_out_of_date`
1228 e51d7b55 2020-01-04 stsp local initial_commit=`git_show_head $testroot/repo`
1229 e51d7b55 2020-01-04 stsp
1230 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1231 e51d7b55 2020-01-04 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1232 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1233 38b0338b 2019-11-29 stsp
1234 e51d7b55 2020-01-04 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1235 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git rm -q beta)
1236 e51d7b55 2020-01-04 stsp echo "new file on branch" > $testroot/repo/epsilon/new
1237 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git add epsilon/new)
1238 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
1239 e51d7b55 2020-01-04 stsp
1240 e51d7b55 2020-01-04 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1241 e51d7b55 2020-01-04 stsp local orig_commit2=`git_show_head $testroot/repo`
1242 e51d7b55 2020-01-04 stsp
1243 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
1244 e51d7b55 2020-01-04 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1245 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to zeta on master"
1246 e51d7b55 2020-01-04 stsp local master_commit1=`git_show_head $testroot/repo`
1247 e51d7b55 2020-01-04 stsp
1248 e51d7b55 2020-01-04 stsp (cd $testroot/repo && git checkout -q master)
1249 e51d7b55 2020-01-04 stsp echo "modified beta on master" > $testroot/repo/beta
1250 e51d7b55 2020-01-04 stsp git_commit $testroot/repo -m "committing to beta on master"
1251 e51d7b55 2020-01-04 stsp local master_commit2=`git_show_head $testroot/repo`
1252 e51d7b55 2020-01-04 stsp
1253 e51d7b55 2020-01-04 stsp got checkout -c $master_commit1 $testroot/repo $testroot/wt \
1254 e51d7b55 2020-01-04 stsp > /dev/null
1255 49c543a6 2022-03-31 naddy ret=$?
1256 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1257 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1258 e51d7b55 2020-01-04 stsp return 1
1259 e51d7b55 2020-01-04 stsp fi
1260 e51d7b55 2020-01-04 stsp
1261 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
1262 e51d7b55 2020-01-04 stsp 2> $testroot/stderr)
1263 e51d7b55 2020-01-04 stsp
1264 e51d7b55 2020-01-04 stsp echo -n > $testroot/stdout.expected
1265 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1266 49c543a6 2022-03-31 naddy ret=$?
1267 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1268 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
1269 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1270 e51d7b55 2020-01-04 stsp return 1
1271 e51d7b55 2020-01-04 stsp fi
1272 e51d7b55 2020-01-04 stsp
1273 e51d7b55 2020-01-04 stsp echo -n "got: work tree must be updated before it can be " \
1274 e51d7b55 2020-01-04 stsp > $testroot/stderr.expected
1275 e51d7b55 2020-01-04 stsp echo "used to rebase a branch" >> $testroot/stderr.expected
1276 e51d7b55 2020-01-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1277 49c543a6 2022-03-31 naddy ret=$?
1278 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1279 e51d7b55 2020-01-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
1280 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1281 e51d7b55 2020-01-04 stsp return 1
1282 e51d7b55 2020-01-04 stsp fi
1283 e51d7b55 2020-01-04 stsp
1284 e51d7b55 2020-01-04 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1285 e51d7b55 2020-01-04 stsp echo "commit $master_commit2 (master)" > $testroot/stdout.expected
1286 e51d7b55 2020-01-04 stsp echo "commit $master_commit1" >> $testroot/stdout.expected
1287 e51d7b55 2020-01-04 stsp echo "commit $initial_commit" >> $testroot/stdout.expected
1288 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1289 49c543a6 2022-03-31 naddy ret=$?
1290 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1291 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1292 1ae0a341 2020-02-14 stsp fi
1293 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1294 1ae0a341 2020-02-14 stsp }
1295 1ae0a341 2020-02-14 stsp
1296 f6cae3ed 2020-09-13 naddy test_rebase_trims_empty_dir() {
1297 1ae0a341 2020-02-14 stsp local testroot=`test_init rebase_trims_empty_dir`
1298 1ae0a341 2020-02-14 stsp
1299 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1300 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1301 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1302 1ae0a341 2020-02-14 stsp
1303 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git rm -q epsilon/zeta)
1304 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "removing zeta on newbranch"
1305 1ae0a341 2020-02-14 stsp
1306 1ae0a341 2020-02-14 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1307 1ae0a341 2020-02-14 stsp local orig_commit2=`git_show_head $testroot/repo`
1308 1ae0a341 2020-02-14 stsp
1309 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q master)
1310 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/repo/alpha
1311 1ae0a341 2020-02-14 stsp git_commit $testroot/repo -m "committing to alpha on master"
1312 1ae0a341 2020-02-14 stsp local master_commit=`git_show_head $testroot/repo`
1313 1ae0a341 2020-02-14 stsp
1314 1ae0a341 2020-02-14 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1315 49c543a6 2022-03-31 naddy ret=$?
1316 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1317 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1318 1ae0a341 2020-02-14 stsp return 1
1319 1ae0a341 2020-02-14 stsp fi
1320 1ae0a341 2020-02-14 stsp
1321 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1322 1ae0a341 2020-02-14 stsp
1323 1ae0a341 2020-02-14 stsp (cd $testroot/repo && git checkout -q newbranch)
1324 1ae0a341 2020-02-14 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
1325 1ae0a341 2020-02-14 stsp local new_commit2=`git_show_head $testroot/repo`
1326 1ae0a341 2020-02-14 stsp
1327 1ae0a341 2020-02-14 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1328 1ae0a341 2020-02-14 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1329 1ae0a341 2020-02-14 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1330 1ae0a341 2020-02-14 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1331 1ae0a341 2020-02-14 stsp
1332 1ae0a341 2020-02-14 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1333 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1334 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1335 1ae0a341 2020-02-14 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1336 1ae0a341 2020-02-14 stsp echo "D epsilon/zeta" >> $testroot/stdout.expected
1337 1ae0a341 2020-02-14 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1338 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1339 1ae0a341 2020-02-14 stsp echo ": removing zeta on newbranch" \
1340 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1341 1ae0a341 2020-02-14 stsp echo "Switching work tree to refs/heads/newbranch" \
1342 1ae0a341 2020-02-14 stsp >> $testroot/stdout.expected
1343 1ae0a341 2020-02-14 stsp
1344 e51d7b55 2020-01-04 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1345 49c543a6 2022-03-31 naddy ret=$?
1346 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1347 e51d7b55 2020-01-04 stsp diff -u $testroot/stdout.expected $testroot/stdout
1348 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1349 1ae0a341 2020-02-14 stsp return 1
1350 e51d7b55 2020-01-04 stsp fi
1351 1ae0a341 2020-02-14 stsp
1352 1ae0a341 2020-02-14 stsp echo "modified delta on branch" > $testroot/content.expected
1353 1ae0a341 2020-02-14 stsp cat $testroot/wt/gamma/delta > $testroot/content
1354 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1355 49c543a6 2022-03-31 naddy ret=$?
1356 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1357 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1358 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1359 1ae0a341 2020-02-14 stsp return 1
1360 1ae0a341 2020-02-14 stsp fi
1361 1ae0a341 2020-02-14 stsp
1362 1ae0a341 2020-02-14 stsp echo "modified alpha on master" > $testroot/content.expected
1363 1ae0a341 2020-02-14 stsp cat $testroot/wt/alpha > $testroot/content
1364 1ae0a341 2020-02-14 stsp cmp -s $testroot/content.expected $testroot/content
1365 49c543a6 2022-03-31 naddy ret=$?
1366 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1367 1ae0a341 2020-02-14 stsp diff -u $testroot/content.expected $testroot/content
1368 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1369 1ae0a341 2020-02-14 stsp return 1
1370 1ae0a341 2020-02-14 stsp fi
1371 1ae0a341 2020-02-14 stsp
1372 1ae0a341 2020-02-14 stsp if [ -e $testroot/wt/epsilon ]; then
1373 1ae0a341 2020-02-14 stsp echo "parent of removed zeta still exists on disk" >&2
1374 1ae0a341 2020-02-14 stsp test_done "$testroot" "1"
1375 1ae0a341 2020-02-14 stsp return 1
1376 1ae0a341 2020-02-14 stsp fi
1377 1ae0a341 2020-02-14 stsp
1378 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got status > $testroot/stdout)
1379 1ae0a341 2020-02-14 stsp
1380 1ae0a341 2020-02-14 stsp echo -n > $testroot/stdout.expected
1381 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1382 49c543a6 2022-03-31 naddy ret=$?
1383 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1384 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1385 1ae0a341 2020-02-14 stsp test_done "$testroot" "$ret"
1386 1ae0a341 2020-02-14 stsp return 1
1387 1ae0a341 2020-02-14 stsp fi
1388 1ae0a341 2020-02-14 stsp
1389 1ae0a341 2020-02-14 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1390 1ae0a341 2020-02-14 stsp echo "commit $new_commit2 (newbranch)" > $testroot/stdout.expected
1391 1ae0a341 2020-02-14 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1392 1ae0a341 2020-02-14 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1393 1ae0a341 2020-02-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1394 49c543a6 2022-03-31 naddy ret=$?
1395 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1396 1ae0a341 2020-02-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
1397 1ae0a341 2020-02-14 stsp fi
1398 e51d7b55 2020-01-04 stsp test_done "$testroot" "$ret"
1399 e51d7b55 2020-01-04 stsp }
1400 ca6da77d 2020-03-22 stsp
1401 f6cae3ed 2020-09-13 naddy test_rebase_delete_missing_file() {
1402 ca6da77d 2020-03-22 stsp local testroot=`test_init rebase_delete_missing_file`
1403 ca6da77d 2020-03-22 stsp
1404 ca6da77d 2020-03-22 stsp mkdir -p $testroot/repo/d/f/g
1405 ca6da77d 2020-03-22 stsp echo "new file" > $testroot/repo/d/f/g/new
1406 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git add d/f/g/new)
1407 ca6da77d 2020-03-22 stsp git_commit $testroot/repo -m "adding a subdir"
1408 ca6da77d 2020-03-22 stsp local commit0=`git_show_head $testroot/repo`
1409 ca6da77d 2020-03-22 stsp
1410 a740a1b3 2020-03-22 stsp got br -r $testroot/repo -c master newbranch
1411 a740a1b3 2020-03-22 stsp
1412 a740a1b3 2020-03-22 stsp got checkout -b newbranch $testroot/repo $testroot/wt > /dev/null
1413 ca6da77d 2020-03-22 stsp
1414 a740a1b3 2020-03-22 stsp echo "modified delta on branch" > $testroot/wt/gamma/delta
1415 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1416 a740a1b3 2020-03-22 stsp -m "committing to delta on newbranch" > /dev/null)
1417 ca6da77d 2020-03-22 stsp
1418 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1419 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1420 a740a1b3 2020-03-22 stsp -m "removing beta and d/f/g/new on newbranch" > /dev/null)
1421 a740a1b3 2020-03-22 stsp
1422 a740a1b3 2020-03-22 stsp (cd $testroot/repo && git checkout -q newbranch)
1423 ca6da77d 2020-03-22 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1424 ca6da77d 2020-03-22 stsp local orig_commit2=`git_show_head $testroot/repo`
1425 1fa49072 2021-09-28 stsp
1426 1fa49072 2021-09-28 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1427 1fa49072 2021-09-28 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1428 ca6da77d 2020-03-22 stsp
1429 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got update -b master > /dev/null)
1430 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got rm beta d/f/g/new > /dev/null)
1431 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got commit \
1432 a740a1b3 2020-03-22 stsp -m "removing beta and d/f/g/new on master" > /dev/null)
1433 a740a1b3 2020-03-22 stsp
1434 ca6da77d 2020-03-22 stsp (cd $testroot/repo && git checkout -q master)
1435 ca6da77d 2020-03-22 stsp local master_commit=`git_show_head $testroot/repo`
1436 ca6da77d 2020-03-22 stsp
1437 a740a1b3 2020-03-22 stsp (cd $testroot/wt && got update -b master > /dev/null)
1438 1fa49072 2021-09-28 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
1439 1fa49072 2021-09-28 stsp 2> $testroot/stderr)
1440 49c543a6 2022-03-31 naddy ret=$?
1441 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
1442 1fa49072 2021-09-28 stsp echo "rebase succeeded unexpectedly" >&2
1443 1fa49072 2021-09-28 stsp test_done "$testroot" "1"
1444 1fa49072 2021-09-28 stsp return 1
1445 1fa49072 2021-09-28 stsp fi
1446 ca6da77d 2020-03-22 stsp
1447 1fa49072 2021-09-28 stsp local new_commit1=$(cd $testroot/wt && got info | \
1448 1fa49072 2021-09-28 stsp grep '^work tree base commit: ' | cut -d: -f2 | tr -d ' ')
1449 ca6da77d 2020-03-22 stsp
1450 ca6da77d 2020-03-22 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1451 ca6da77d 2020-03-22 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1452 ca6da77d 2020-03-22 stsp
1453 ca6da77d 2020-03-22 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1454 ca6da77d 2020-03-22 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1455 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1456 ca6da77d 2020-03-22 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1457 ca6da77d 2020-03-22 stsp echo "! beta" >> $testroot/stdout.expected
1458 ca6da77d 2020-03-22 stsp echo "! d/f/g/new" >> $testroot/stdout.expected
1459 35ca1db7 2021-09-28 stsp echo -n "Files which had incoming changes but could not be found " \
1460 35ca1db7 2021-09-28 stsp >> $testroot/stdout.expected
1461 35ca1db7 2021-09-28 stsp echo "in the work tree: 2" >> $testroot/stdout.expected
1462 1fa49072 2021-09-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1463 49c543a6 2022-03-31 naddy ret=$?
1464 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1465 1fa49072 2021-09-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
1466 1fa49072 2021-09-28 stsp test_done "$testroot" "$ret"
1467 1fa49072 2021-09-28 stsp return 1
1468 1fa49072 2021-09-28 stsp fi
1469 1fa49072 2021-09-28 stsp
1470 1fa49072 2021-09-28 stsp echo -n "got: changes destined for some files were not yet merged " \
1471 1fa49072 2021-09-28 stsp > $testroot/stderr.expected
1472 1fa49072 2021-09-28 stsp echo -n "and should be merged manually if required before the " \
1473 1fa49072 2021-09-28 stsp >> $testroot/stderr.expected
1474 1fa49072 2021-09-28 stsp echo "rebase operation is continued" >> $testroot/stderr.expected
1475 1fa49072 2021-09-28 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1476 49c543a6 2022-03-31 naddy ret=$?
1477 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1478 1fa49072 2021-09-28 stsp diff -u $testroot/stderr.expected $testroot/stderr
1479 1fa49072 2021-09-28 stsp test_done "$testroot" "$ret"
1480 1fa49072 2021-09-28 stsp return 1
1481 1fa49072 2021-09-28 stsp fi
1482 1fa49072 2021-09-28 stsp
1483 1fa49072 2021-09-28 stsp # ignore the missing changes and continue
1484 1fa49072 2021-09-28 stsp (cd $testroot/wt && got rebase -c > $testroot/stdout)
1485 49c543a6 2022-03-31 naddy ret=$?
1486 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1487 1fa49072 2021-09-28 stsp echo "rebase failed unexpectedly" >&2
1488 1fa49072 2021-09-28 stsp test_done "$testroot" "1"
1489 1fa49072 2021-09-28 stsp return 1
1490 1fa49072 2021-09-28 stsp fi
1491 ca6da77d 2020-03-22 stsp echo -n "$short_orig_commit2 -> no-op change" \
1492 1fa49072 2021-09-28 stsp > $testroot/stdout.expected
1493 a740a1b3 2020-03-22 stsp echo ": removing beta and d/f/g/new on newbranch" \
1494 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1495 ca6da77d 2020-03-22 stsp echo "Switching work tree to refs/heads/newbranch" \
1496 ca6da77d 2020-03-22 stsp >> $testroot/stdout.expected
1497 ca6da77d 2020-03-22 stsp
1498 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1499 49c543a6 2022-03-31 naddy ret=$?
1500 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1501 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1502 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1503 ca6da77d 2020-03-22 stsp return 1
1504 ca6da77d 2020-03-22 stsp fi
1505 ca6da77d 2020-03-22 stsp
1506 ca6da77d 2020-03-22 stsp echo "modified delta on branch" > $testroot/content.expected
1507 ca6da77d 2020-03-22 stsp cat $testroot/wt/gamma/delta > $testroot/content
1508 ca6da77d 2020-03-22 stsp cmp -s $testroot/content.expected $testroot/content
1509 49c543a6 2022-03-31 naddy ret=$?
1510 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1511 ca6da77d 2020-03-22 stsp diff -u $testroot/content.expected $testroot/content
1512 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1513 ca6da77d 2020-03-22 stsp return 1
1514 ca6da77d 2020-03-22 stsp fi
1515 ca6da77d 2020-03-22 stsp
1516 ca6da77d 2020-03-22 stsp if [ -e $testroot/wt/beta ]; then
1517 ca6da77d 2020-03-22 stsp echo "removed file beta still exists on disk" >&2
1518 ca6da77d 2020-03-22 stsp test_done "$testroot" "1"
1519 ca6da77d 2020-03-22 stsp return 1
1520 ca6da77d 2020-03-22 stsp fi
1521 ca6da77d 2020-03-22 stsp
1522 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got status > $testroot/stdout)
1523 ca6da77d 2020-03-22 stsp
1524 ca6da77d 2020-03-22 stsp echo -n > $testroot/stdout.expected
1525 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1526 49c543a6 2022-03-31 naddy ret=$?
1527 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1528 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1529 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1530 ca6da77d 2020-03-22 stsp return 1
1531 ca6da77d 2020-03-22 stsp fi
1532 ca6da77d 2020-03-22 stsp
1533 1fa49072 2021-09-28 stsp (cd $testroot/repo && git checkout -q newbranch)
1534 1fa49072 2021-09-28 stsp local new_commit1=`git_show_head $testroot/repo`
1535 1fa49072 2021-09-28 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1536 1fa49072 2021-09-28 stsp
1537 ca6da77d 2020-03-22 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
1538 ca6da77d 2020-03-22 stsp echo "commit $new_commit1 (newbranch)" > $testroot/stdout.expected
1539 ca6da77d 2020-03-22 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1540 ca6da77d 2020-03-22 stsp echo "commit $commit0" >> $testroot/stdout.expected
1541 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1542 49c543a6 2022-03-31 naddy ret=$?
1543 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1544 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1545 70551d57 2020-04-24 stsp fi
1546 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1547 70551d57 2020-04-24 stsp }
1548 70551d57 2020-04-24 stsp
1549 f6cae3ed 2020-09-13 naddy test_rebase_rm_add_rm_file() {
1550 70551d57 2020-04-24 stsp local testroot=`test_init rebase_rm_add_rm_file`
1551 70551d57 2020-04-24 stsp
1552 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1553 70551d57 2020-04-24 stsp (cd $testroot/repo && git rm -q beta)
1554 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "removing beta from newbranch"
1555 70551d57 2020-04-24 stsp local orig_commit1=`git_show_head $testroot/repo`
1556 70551d57 2020-04-24 stsp
1557 70551d57 2020-04-24 stsp echo 'restored beta' > $testroot/repo/beta
1558 70551d57 2020-04-24 stsp (cd $testroot/repo && git add beta)
1559 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "restoring beta on newbranch"
1560 70551d57 2020-04-24 stsp local orig_commit2=`git_show_head $testroot/repo`
1561 70551d57 2020-04-24 stsp
1562 70551d57 2020-04-24 stsp (cd $testroot/repo && git rm -q beta)
1563 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "removing beta from newbranch again"
1564 70551d57 2020-04-24 stsp local orig_commit3=`git_show_head $testroot/repo`
1565 70551d57 2020-04-24 stsp
1566 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q master)
1567 70551d57 2020-04-24 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1568 70551d57 2020-04-24 stsp git_commit $testroot/repo -m "committing to zeta on master"
1569 70551d57 2020-04-24 stsp local master_commit=`git_show_head $testroot/repo`
1570 70551d57 2020-04-24 stsp
1571 70551d57 2020-04-24 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1572 49c543a6 2022-03-31 naddy ret=$?
1573 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1574 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1575 70551d57 2020-04-24 stsp return 1
1576 70551d57 2020-04-24 stsp fi
1577 70551d57 2020-04-24 stsp
1578 70551d57 2020-04-24 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout)
1579 70551d57 2020-04-24 stsp
1580 70551d57 2020-04-24 stsp # this would error out with 'got: file index is corrupt'
1581 70551d57 2020-04-24 stsp (cd $testroot/wt && got status > /dev/null)
1582 49c543a6 2022-03-31 naddy ret=$?
1583 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1584 70551d57 2020-04-24 stsp echo "got status command failed unexpectedly" >&2
1585 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1586 70551d57 2020-04-24 stsp return 1
1587 70551d57 2020-04-24 stsp fi
1588 70551d57 2020-04-24 stsp
1589 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q newbranch)
1590 70551d57 2020-04-24 stsp local new_commit3=`git_show_head $testroot/repo`
1591 70551d57 2020-04-24 stsp local new_commit2=`git_show_parent_commit $testroot/repo`
1592 70551d57 2020-04-24 stsp local new_commit1=`git_show_parent_commit $testroot/repo $new_commit2`
1593 70551d57 2020-04-24 stsp
1594 70551d57 2020-04-24 stsp (cd $testroot/repo && git checkout -q newbranch)
1595 70551d57 2020-04-24 stsp
1596 70551d57 2020-04-24 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1597 70551d57 2020-04-24 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1598 70551d57 2020-04-24 stsp local short_orig_commit3=`trim_obj_id 28 $orig_commit3`
1599 70551d57 2020-04-24 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1600 70551d57 2020-04-24 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1601 70551d57 2020-04-24 stsp local short_new_commit3=`trim_obj_id 28 $new_commit3`
1602 70551d57 2020-04-24 stsp
1603 70551d57 2020-04-24 stsp echo "D beta" > $testroot/stdout.expected
1604 70551d57 2020-04-24 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1605 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1606 70551d57 2020-04-24 stsp echo ": removing beta from newbranch" >> $testroot/stdout.expected
1607 70551d57 2020-04-24 stsp echo "A beta" >> $testroot/stdout.expected
1608 70551d57 2020-04-24 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1609 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1610 70551d57 2020-04-24 stsp echo ": restoring beta on newbranch" >> $testroot/stdout.expected
1611 70551d57 2020-04-24 stsp echo "D beta" >> $testroot/stdout.expected
1612 70551d57 2020-04-24 stsp echo -n "$short_orig_commit3 -> $short_new_commit3" \
1613 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1614 70551d57 2020-04-24 stsp echo ": removing beta from newbranch again" >> $testroot/stdout.expected
1615 70551d57 2020-04-24 stsp echo "Switching work tree to refs/heads/newbranch" \
1616 70551d57 2020-04-24 stsp >> $testroot/stdout.expected
1617 70551d57 2020-04-24 stsp
1618 ca6da77d 2020-03-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1619 49c543a6 2022-03-31 naddy ret=$?
1620 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1621 ca6da77d 2020-03-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1622 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1623 70551d57 2020-04-24 stsp return 1
1624 ca6da77d 2020-03-22 stsp fi
1625 70551d57 2020-04-24 stsp
1626 70551d57 2020-04-24 stsp (cd $testroot/wt && got status > $testroot/stdout)
1627 49c543a6 2022-03-31 naddy ret=$?
1628 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1629 70551d57 2020-04-24 stsp echo "got status command failed unexpectedly" >&2
1630 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1631 70551d57 2020-04-24 stsp return 1
1632 70551d57 2020-04-24 stsp fi
1633 70551d57 2020-04-24 stsp
1634 70551d57 2020-04-24 stsp echo -n > $testroot/stdout.expected
1635 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1636 49c543a6 2022-03-31 naddy ret=$?
1637 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1638 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1639 70551d57 2020-04-24 stsp test_done "$testroot" "$ret"
1640 70551d57 2020-04-24 stsp return 1
1641 70551d57 2020-04-24 stsp fi
1642 70551d57 2020-04-24 stsp
1643 70551d57 2020-04-24 stsp (cd $testroot/wt && got log -l4 | grep ^commit > $testroot/stdout)
1644 70551d57 2020-04-24 stsp echo "commit $new_commit3 (newbranch)" > $testroot/stdout.expected
1645 70551d57 2020-04-24 stsp echo "commit $new_commit2" >> $testroot/stdout.expected
1646 70551d57 2020-04-24 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
1647 70551d57 2020-04-24 stsp echo "commit $master_commit (master)" >> $testroot/stdout.expected
1648 70551d57 2020-04-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1649 49c543a6 2022-03-31 naddy ret=$?
1650 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
1651 70551d57 2020-04-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
1652 70551d57 2020-04-24 stsp fi
1653 ca6da77d 2020-03-22 stsp test_done "$testroot" "$ret"
1654 ca6da77d 2020-03-22 stsp }
1655 598eac43 2022-07-22 stsp
1656 598eac43 2022-07-22 stsp test_rebase_resets_committer() {
1657 598eac43 2022-07-22 stsp local testroot=`test_init rebase_resets_committer`
1658 598eac43 2022-07-22 stsp local commit0=`git_show_head $testroot/repo`
1659 598eac43 2022-07-22 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1660 598eac43 2022-07-22 stsp local committer="Flan Luck <flan_luck@openbsd.org>"
1661 598eac43 2022-07-22 stsp
1662 598eac43 2022-07-22 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1663 598eac43 2022-07-22 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1664 598eac43 2022-07-22 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1665 598eac43 2022-07-22 stsp
1666 598eac43 2022-07-22 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1667 598eac43 2022-07-22 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
1668 598eac43 2022-07-22 stsp
1669 598eac43 2022-07-22 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1670 598eac43 2022-07-22 stsp local orig_commit2=`git_show_head $testroot/repo`
1671 598eac43 2022-07-22 stsp local orig_author_time2=`git_show_author_time $testroot/repo`
1672 598eac43 2022-07-22 stsp
1673 598eac43 2022-07-22 stsp (cd $testroot/repo && git checkout -q master)
1674 598eac43 2022-07-22 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1675 598eac43 2022-07-22 stsp git_commit $testroot/repo -m "committing to zeta on master"
1676 598eac43 2022-07-22 stsp local master_commit=`git_show_head $testroot/repo`
1677 598eac43 2022-07-22 stsp
1678 598eac43 2022-07-22 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1679 598eac43 2022-07-22 stsp ret=$?
1680 598eac43 2022-07-22 stsp if [ $ret -ne 0 ]; then
1681 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
1682 598eac43 2022-07-22 stsp return 1
1683 598eac43 2022-07-22 stsp fi
1684 ca6da77d 2020-03-22 stsp
1685 598eac43 2022-07-22 stsp (cd $testroot/wt && env GOT_AUTHOR="$committer" \
1686 598eac43 2022-07-22 stsp got rebase newbranch > $testroot/stdout)
1687 598eac43 2022-07-22 stsp
1688 598eac43 2022-07-22 stsp (cd $testroot/repo && git checkout -q newbranch)
1689 598eac43 2022-07-22 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
1690 598eac43 2022-07-22 stsp local new_commit2=`git_show_head $testroot/repo`
1691 598eac43 2022-07-22 stsp local new_author_time2=`git_show_author_time $testroot/repo`
1692 598eac43 2022-07-22 stsp
1693 598eac43 2022-07-22 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1694 598eac43 2022-07-22 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1695 598eac43 2022-07-22 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1696 598eac43 2022-07-22 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1697 598eac43 2022-07-22 stsp
1698 598eac43 2022-07-22 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1699 598eac43 2022-07-22 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1700 598eac43 2022-07-22 stsp >> $testroot/stdout.expected
1701 598eac43 2022-07-22 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1702 598eac43 2022-07-22 stsp echo "G alpha" >> $testroot/stdout.expected
1703 598eac43 2022-07-22 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1704 598eac43 2022-07-22 stsp >> $testroot/stdout.expected
1705 598eac43 2022-07-22 stsp echo ": committing more changes on newbranch" \
1706 598eac43 2022-07-22 stsp >> $testroot/stdout.expected
1707 598eac43 2022-07-22 stsp echo "Switching work tree to refs/heads/newbranch" \
1708 598eac43 2022-07-22 stsp >> $testroot/stdout.expected
1709 598eac43 2022-07-22 stsp
1710 598eac43 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1711 598eac43 2022-07-22 stsp ret=$?
1712 598eac43 2022-07-22 stsp if [ $ret -ne 0 ]; then
1713 598eac43 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1714 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
1715 598eac43 2022-07-22 stsp return 1
1716 598eac43 2022-07-22 stsp fi
1717 598eac43 2022-07-22 stsp
1718 598eac43 2022-07-22 stsp # Original commit only had one author
1719 598eac43 2022-07-22 stsp (cd $testroot/repo && got log -l1 -c $orig_commit2 | \
1720 598eac43 2022-07-22 stsp egrep '^(from|via):' > $testroot/stdout)
1721 598eac43 2022-07-22 stsp echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
1722 598eac43 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1723 598eac43 2022-07-22 stsp ret=$?
1724 598eac43 2022-07-22 stsp if [ $ret -ne 0 ]; then
1725 598eac43 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1726 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
1727 598eac43 2022-07-22 stsp return 1
1728 598eac43 2022-07-22 stsp fi
1729 598eac43 2022-07-22 stsp
1730 598eac43 2022-07-22 stsp # Rebased commit should have new committer name added
1731 598eac43 2022-07-22 stsp (cd $testroot/repo && got log -l1 -c $new_commit2 | \
1732 598eac43 2022-07-22 stsp egrep '^(from|via):' > $testroot/stdout)
1733 598eac43 2022-07-22 stsp echo "from: $GOT_AUTHOR" > $testroot/stdout.expected
1734 598eac43 2022-07-22 stsp echo "via: $committer" >> $testroot/stdout.expected
1735 50e7a649 2022-07-22 stsp
1736 50e7a649 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1737 50e7a649 2022-07-22 stsp ret=$?
1738 50e7a649 2022-07-22 stsp if [ $ret -ne 0 ]; then
1739 50e7a649 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1740 50e7a649 2022-07-22 stsp fi
1741 50e7a649 2022-07-22 stsp test_done "$testroot" "$ret"
1742 50e7a649 2022-07-22 stsp }
1743 50e7a649 2022-07-22 stsp
1744 50e7a649 2022-07-22 stsp test_rebase_no_author_info() {
1745 50e7a649 2022-07-22 stsp local testroot=`test_init rebase_no_author_info`
1746 50e7a649 2022-07-22 stsp local commit0=`git_show_head $testroot/repo`
1747 50e7a649 2022-07-22 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1748 50e7a649 2022-07-22 stsp local committer="$GOT_AUTHOR"
1749 50e7a649 2022-07-22 stsp
1750 50e7a649 2022-07-22 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1751 50e7a649 2022-07-22 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1752 50e7a649 2022-07-22 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1753 50e7a649 2022-07-22 stsp
1754 50e7a649 2022-07-22 stsp echo "modified alpha on branch" > $testroot/repo/alpha
1755 50e7a649 2022-07-22 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
1756 50e7a649 2022-07-22 stsp
1757 50e7a649 2022-07-22 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1758 50e7a649 2022-07-22 stsp local orig_commit2=`git_show_head $testroot/repo`
1759 50e7a649 2022-07-22 stsp local orig_author_time2=`git_show_author_time $testroot/repo`
1760 50e7a649 2022-07-22 stsp
1761 50e7a649 2022-07-22 stsp (cd $testroot/repo && git checkout -q master)
1762 50e7a649 2022-07-22 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1763 50e7a649 2022-07-22 stsp git_commit $testroot/repo -m "committing to zeta on master"
1764 50e7a649 2022-07-22 stsp local master_commit=`git_show_head $testroot/repo`
1765 50e7a649 2022-07-22 stsp
1766 50e7a649 2022-07-22 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1767 50e7a649 2022-07-22 stsp ret=$?
1768 50e7a649 2022-07-22 stsp if [ $ret -ne 0 ]; then
1769 50e7a649 2022-07-22 stsp test_done "$testroot" "$ret"
1770 50e7a649 2022-07-22 stsp return 1
1771 50e7a649 2022-07-22 stsp fi
1772 50e7a649 2022-07-22 stsp
1773 1004841d 2022-07-24 op # unset in a subshell to avoid affecting our environment
1774 1004841d 2022-07-24 op (unset GOT_AUTHOR && cd $testroot/wt && \
1775 1004841d 2022-07-24 op got rebase newbranch > $testroot/stdout)
1776 50e7a649 2022-07-22 stsp
1777 50e7a649 2022-07-22 stsp (cd $testroot/repo && git checkout -q newbranch)
1778 50e7a649 2022-07-22 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
1779 50e7a649 2022-07-22 stsp local new_commit2=`git_show_head $testroot/repo`
1780 50e7a649 2022-07-22 stsp local new_author_time2=`git_show_author_time $testroot/repo`
1781 598eac43 2022-07-22 stsp
1782 50e7a649 2022-07-22 stsp local short_orig_commit1=`trim_obj_id 28 $orig_commit1`
1783 50e7a649 2022-07-22 stsp local short_orig_commit2=`trim_obj_id 28 $orig_commit2`
1784 50e7a649 2022-07-22 stsp local short_new_commit1=`trim_obj_id 28 $new_commit1`
1785 50e7a649 2022-07-22 stsp local short_new_commit2=`trim_obj_id 28 $new_commit2`
1786 50e7a649 2022-07-22 stsp
1787 50e7a649 2022-07-22 stsp echo "G gamma/delta" >> $testroot/stdout.expected
1788 50e7a649 2022-07-22 stsp echo -n "$short_orig_commit1 -> $short_new_commit1" \
1789 50e7a649 2022-07-22 stsp >> $testroot/stdout.expected
1790 50e7a649 2022-07-22 stsp echo ": committing to delta on newbranch" >> $testroot/stdout.expected
1791 50e7a649 2022-07-22 stsp echo "G alpha" >> $testroot/stdout.expected
1792 50e7a649 2022-07-22 stsp echo -n "$short_orig_commit2 -> $short_new_commit2" \
1793 50e7a649 2022-07-22 stsp >> $testroot/stdout.expected
1794 50e7a649 2022-07-22 stsp echo ": committing more changes on newbranch" \
1795 50e7a649 2022-07-22 stsp >> $testroot/stdout.expected
1796 50e7a649 2022-07-22 stsp echo "Switching work tree to refs/heads/newbranch" \
1797 50e7a649 2022-07-22 stsp >> $testroot/stdout.expected
1798 50e7a649 2022-07-22 stsp
1799 598eac43 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1800 598eac43 2022-07-22 stsp ret=$?
1801 598eac43 2022-07-22 stsp if [ $ret -ne 0 ]; then
1802 598eac43 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1803 50e7a649 2022-07-22 stsp test_done "$testroot" "$ret"
1804 50e7a649 2022-07-22 stsp return 1
1805 598eac43 2022-07-22 stsp fi
1806 50e7a649 2022-07-22 stsp
1807 50e7a649 2022-07-22 stsp # Original commit only had one author
1808 50e7a649 2022-07-22 stsp (cd $testroot/repo && got log -l1 -c $orig_commit2 | \
1809 50e7a649 2022-07-22 stsp egrep '^(from|via):' > $testroot/stdout)
1810 50e7a649 2022-07-22 stsp echo "from: $committer" > $testroot/stdout.expected
1811 50e7a649 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1812 50e7a649 2022-07-22 stsp ret=$?
1813 50e7a649 2022-07-22 stsp if [ $ret -ne 0 ]; then
1814 50e7a649 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1815 50e7a649 2022-07-22 stsp test_done "$testroot" "$ret"
1816 50e7a649 2022-07-22 stsp return 1
1817 50e7a649 2022-07-22 stsp fi
1818 50e7a649 2022-07-22 stsp
1819 50e7a649 2022-07-22 stsp # Author info of rebased commit should match the original
1820 50e7a649 2022-07-22 stsp (cd $testroot/repo && got log -l1 -c $new_commit2 | \
1821 50e7a649 2022-07-22 stsp egrep '^(from|via):' > $testroot/stdout)
1822 50e7a649 2022-07-22 stsp echo "from: $committer" > $testroot/stdout.expected
1823 50e7a649 2022-07-22 stsp
1824 50e7a649 2022-07-22 stsp cmp -s $testroot/stdout.expected $testroot/stdout
1825 50e7a649 2022-07-22 stsp ret=$?
1826 50e7a649 2022-07-22 stsp if [ $ret -ne 0 ]; then
1827 50e7a649 2022-07-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
1828 442ede73 2022-09-04 stsp fi
1829 442ede73 2022-09-04 stsp test_done "$testroot" "$ret"
1830 442ede73 2022-09-04 stsp }
1831 442ede73 2022-09-04 stsp
1832 442ede73 2022-09-04 stsp test_rebase_nonbranch() {
1833 442ede73 2022-09-04 stsp local testroot=`test_init rebase_nonbranch`
1834 442ede73 2022-09-04 stsp
1835 442ede73 2022-09-04 stsp got ref -r $testroot/repo -c refs/heads/master \
1836 442ede73 2022-09-04 stsp refs/remotes/origin/master >/dev/null
1837 442ede73 2022-09-04 stsp
1838 442ede73 2022-09-04 stsp got checkout -b master $testroot/repo $testroot/wt >/dev/null
1839 442ede73 2022-09-04 stsp
1840 442ede73 2022-09-04 stsp (cd $testroot/wt && got rebase origin/master > $testroot/stdout \
1841 442ede73 2022-09-04 stsp 2> $testroot/stderr)
1842 442ede73 2022-09-04 stsp ret=$?
1843 442ede73 2022-09-04 stsp if [ $ret -eq 0 ]; then
1844 442ede73 2022-09-04 stsp echo "rebase succeeded unexpectedly" >&2
1845 442ede73 2022-09-04 stsp test_done "$testroot" "1"
1846 442ede73 2022-09-04 stsp return 1
1847 50e7a649 2022-07-22 stsp fi
1848 442ede73 2022-09-04 stsp echo -n "got: will not rebase a branch which lives outside the " \
1849 442ede73 2022-09-04 stsp > $testroot/stderr.expected
1850 442ede73 2022-09-04 stsp echo '"refs/heads/" reference namespace' >> $testroot/stderr.expected
1851 442ede73 2022-09-04 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1852 442ede73 2022-09-04 stsp ret=$?
1853 442ede73 2022-09-04 stsp if [ $ret -ne 0 ]; then
1854 442ede73 2022-09-04 stsp diff -u $testroot/stderr.expected $testroot/stderr
1855 442ede73 2022-09-04 stsp fi
1856 598eac43 2022-07-22 stsp test_done "$testroot" "$ret"
1857 598eac43 2022-07-22 stsp }
1858 b2b3fce1 2022-10-29 op
1859 b2b3fce1 2022-10-29 op test_rebase_umask() {
1860 b2b3fce1 2022-10-29 op local testroot=`test_init rebase_umask`
1861 b2b3fce1 2022-10-29 op local commit0=`git_show_head "$testroot/repo"`
1862 b2b3fce1 2022-10-29 op
1863 b2b3fce1 2022-10-29 op got checkout "$testroot/repo" "$testroot/wt" >/dev/null
1864 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got branch newbranch) >/dev/null
1865 b2b3fce1 2022-10-29 op
1866 b2b3fce1 2022-10-29 op echo "modified alpha on branch" >$testroot/wt/alpha
1867 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got commit -m 'modified alpha on newbranch') \
1868 b2b3fce1 2022-10-29 op >/dev/null
1869 b2b3fce1 2022-10-29 op
1870 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got update -b master) >/dev/null
1871 b2b3fce1 2022-10-29 op ret=$?
1872 b2b3fce1 2022-10-29 op if [ $ret -ne 0 ]; then
1873 b2b3fce1 2022-10-29 op echo "got update failed!" >&2
1874 b2b3fce1 2022-10-29 op test_done "$testroot" $ret
1875 b2b3fce1 2022-10-29 op return 1
1876 b2b3fce1 2022-10-29 op fi
1877 598eac43 2022-07-22 stsp
1878 b2b3fce1 2022-10-29 op echo "modified beta on master" >$testroot/wt/beta
1879 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got commit -m 'modified beta on master') \
1880 b2b3fce1 2022-10-29 op >/dev/null
1881 b2b3fce1 2022-10-29 op (cd "$testroot/wt" && got update) >/dev/null
1882 b2b3fce1 2022-10-29 op
1883 b2b3fce1 2022-10-29 op # using a subshell to avoid clobbering global umask
1884 b2b3fce1 2022-10-29 op (umask 077 && cd "$testroot/wt" && got rebase newbranch) >/dev/null
1885 b2b3fce1 2022-10-29 op ret=$?
1886 b2b3fce1 2022-10-29 op if [ $ret -ne 0 ]; then
1887 b2b3fce1 2022-10-29 op echo "got rebase failed" >&2
1888 b2b3fce1 2022-10-29 op test_done "$testroot" $ret
1889 b2b3fce1 2022-10-29 op return 1
1890 b2b3fce1 2022-10-29 op fi
1891 b2b3fce1 2022-10-29 op
1892 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/alpha" | grep -q ^-rw-------
1893 b2b3fce1 2022-10-29 op if [ $? -ne 0 ]; then
1894 b2b3fce1 2022-10-29 op echo "alpha is not 0600 after rebase" >&2
1895 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/alpha" >&2
1896 b2b3fce1 2022-10-29 op test_done "$testroot" 1
1897 b2b3fce1 2022-10-29 op return 1
1898 b2b3fce1 2022-10-29 op fi
1899 b2b3fce1 2022-10-29 op
1900 b2b3fce1 2022-10-29 op test_done "$testroot" 0
1901 49a1ae4b 2023-01-08 stsp }
1902 49a1ae4b 2023-01-08 stsp
1903 49a1ae4b 2023-01-08 stsp test_rebase_out_of_date2() {
1904 49a1ae4b 2023-01-08 stsp local testroot=`test_init rebase_out_of_date2`
1905 49a1ae4b 2023-01-08 stsp local commit0=`git_show_head $testroot/repo`
1906 49a1ae4b 2023-01-08 stsp local commit0_author_time=`git_show_author_time $testroot/repo`
1907 49a1ae4b 2023-01-08 stsp
1908 49a1ae4b 2023-01-08 stsp (cd $testroot/repo && git checkout -q -b newbranch)
1909 49a1ae4b 2023-01-08 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
1910 49a1ae4b 2023-01-08 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
1911 49a1ae4b 2023-01-08 stsp
1912 49a1ae4b 2023-01-08 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
1913 49a1ae4b 2023-01-08 stsp local orig_commit2=`git_show_head $testroot/repo`
1914 49a1ae4b 2023-01-08 stsp local orig_author_time2=`git_show_author_time $testroot/repo`
1915 49a1ae4b 2023-01-08 stsp
1916 49a1ae4b 2023-01-08 stsp (cd $testroot/repo && git checkout -q master)
1917 49a1ae4b 2023-01-08 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
1918 49a1ae4b 2023-01-08 stsp git_commit $testroot/repo -m "committing to zeta on master"
1919 49a1ae4b 2023-01-08 stsp local master_commit=`git_show_head $testroot/repo`
1920 49a1ae4b 2023-01-08 stsp
1921 49a1ae4b 2023-01-08 stsp got checkout $testroot/repo $testroot/wt > /dev/null
1922 49a1ae4b 2023-01-08 stsp ret=$?
1923 49a1ae4b 2023-01-08 stsp if [ $ret -ne 0 ]; then
1924 49a1ae4b 2023-01-08 stsp test_done "$testroot" "$ret"
1925 49a1ae4b 2023-01-08 stsp return 1
1926 49a1ae4b 2023-01-08 stsp fi
1927 49a1ae4b 2023-01-08 stsp
1928 49a1ae4b 2023-01-08 stsp # Backdate the file alpha to an earlier version.
1929 49a1ae4b 2023-01-08 stsp # This sets the work tree's base commit ID back to $commit0,
1930 49a1ae4b 2023-01-08 stsp # which is out-of-date with respect to the master branch.
1931 49a1ae4b 2023-01-08 stsp (cd $testroot/wt && got update -c $commit0 alpha > /dev/null)
1932 49a1ae4b 2023-01-08 stsp
1933 49a1ae4b 2023-01-08 stsp # Rebase into an out-of-date work tree should be refused.
1934 49a1ae4b 2023-01-08 stsp (cd $testroot/wt && got rebase newbranch > $testroot/stdout \
1935 49a1ae4b 2023-01-08 stsp 2> $testroot/stderr)
1936 49a1ae4b 2023-01-08 stsp ret=$?
1937 49a1ae4b 2023-01-08 stsp if [ $ret -eq 0 ]; then
1938 49a1ae4b 2023-01-08 stsp echo "rebase succeeded unexpectedly" >&2
1939 49a1ae4b 2023-01-08 stsp test_done "$testroot" "1"
1940 49a1ae4b 2023-01-08 stsp return 1
1941 49a1ae4b 2023-01-08 stsp fi
1942 49a1ae4b 2023-01-08 stsp echo -n > $testroot/stdout.expected
1943 49a1ae4b 2023-01-08 stsp echo -n "got: work tree must be updated before it can be used to " \
1944 49a1ae4b 2023-01-08 stsp > $testroot/stderr.expected
1945 49a1ae4b 2023-01-08 stsp echo "rebase a branch" >> $testroot/stderr.expected
1946 49a1ae4b 2023-01-08 stsp cmp -s $testroot/stderr.expected $testroot/stderr
1947 49a1ae4b 2023-01-08 stsp ret=$?
1948 49a1ae4b 2023-01-08 stsp if [ $ret -ne 0 ]; then
1949 49a1ae4b 2023-01-08 stsp diff -u $testroot/stderr.expected $testroot/stderr
1950 49a1ae4b 2023-01-08 stsp fi
1951 49a1ae4b 2023-01-08 stsp test_done "$testroot" "$ret"
1952 980c6786 2023-01-31 stsp }
1953 980c6786 2023-01-31 stsp
1954 980c6786 2023-01-31 stsp test_rebase_one_commit() {
1955 980c6786 2023-01-31 stsp local testroot=`test_init rebase_one_commit`
1956 980c6786 2023-01-31 stsp
1957 980c6786 2023-01-31 stsp if ! got checkout $testroot/repo $testroot/wt >/dev/null; then
1958 980c6786 2023-01-31 stsp test_done "$testroot" 1
1959 980c6786 2023-01-31 stsp return 1
1960 980c6786 2023-01-31 stsp fi
1961 980c6786 2023-01-31 stsp
1962 980c6786 2023-01-31 stsp (cd $testroot/wt && got branch newbranch) >/dev/null
1963 980c6786 2023-01-31 stsp
1964 980c6786 2023-01-31 stsp echo "modified alpha on newbranch" >$testroot/wt/alpha
1965 980c6786 2023-01-31 stsp (cd $testroot/wt && got commit -m 'edit alpha') >/dev/null
1966 980c6786 2023-01-31 stsp (cd $testroot/wt && got update) >/dev/null
1967 980c6786 2023-01-31 stsp local commit=`git_show_branch_head $testroot/repo newbranch`
1968 980c6786 2023-01-31 stsp
1969 980c6786 2023-01-31 stsp echo -n '' > $testroot/stderr.expected
1970 980c6786 2023-01-31 stsp
1971 980c6786 2023-01-31 stsp (cd $testroot/wt && got rebase master >$testroot/stdout \
1972 980c6786 2023-01-31 stsp 2> $testroot/stderr)
1973 980c6786 2023-01-31 stsp ret=$?
1974 980c6786 2023-01-31 stsp if [ $ret -ne 0 ]; then
1975 980c6786 2023-01-31 stsp echo "rebase comand failed unexpectedly" >&2
1976 980c6786 2023-01-31 stsp diff -u $testroot/stderr.expected $testroot/stderr
1977 980c6786 2023-01-31 stsp test_done "$testroot" "1"
1978 980c6786 2023-01-31 stsp return 1
1979 980c6786 2023-01-31 stsp fi
1980 980c6786 2023-01-31 stsp
1981 980c6786 2023-01-31 stsp echo "Forwarding refs/heads/master to commit $commit" \
1982 980c6786 2023-01-31 stsp >$testroot/stdout.expected
1983 980c6786 2023-01-31 stsp echo "Switching work tree to refs/heads/master" \
1984 980c6786 2023-01-31 stsp >> $testroot/stdout.expected
1985 980c6786 2023-01-31 stsp
1986 980c6786 2023-01-31 stsp if ! cmp -s $testroot/stdout.expected $testroot/stdout; then
1987 980c6786 2023-01-31 stsp diff -u $testroot/stdout.expected $testroot/stdout
1988 980c6786 2023-01-31 stsp test_done "$testroot" 1
1989 980c6786 2023-01-31 stsp return 1
1990 980c6786 2023-01-31 stsp fi
1991 980c6786 2023-01-31 stsp
1992 980c6786 2023-01-31 stsp test_done "$testroot" 0
1993 b2b3fce1 2022-10-29 op }
1994 b2b3fce1 2022-10-29 op
1995 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1996 dcf44d04 2019-07-11 stsp run_test test_rebase_basic
1997 dcf44d04 2019-07-11 stsp run_test test_rebase_ancestry_check
1998 dcf44d04 2019-07-11 stsp run_test test_rebase_continue
1999 dcf44d04 2019-07-11 stsp run_test test_rebase_abort
2000 ff0d2220 2019-07-11 stsp run_test test_rebase_no_op_change
2001 7d5807f4 2019-07-11 stsp run_test test_rebase_in_progress
2002 64c6d990 2019-07-11 stsp run_test test_rebase_path_prefix
2003 787c8eb6 2019-07-11 stsp run_test test_rebase_preserves_logmsg
2004 fc66b545 2019-08-12 stsp run_test test_rebase_no_commits_to_rebase
2005 38b0338b 2019-11-29 stsp run_test test_rebase_forward
2006 0a706d22 2022-09-21 stsp run_test test_rebase_forward_path_prefix
2007 e51d7b55 2020-01-04 stsp run_test test_rebase_out_of_date
2008 1ae0a341 2020-02-14 stsp run_test test_rebase_trims_empty_dir
2009 ca6da77d 2020-03-22 stsp run_test test_rebase_delete_missing_file
2010 70551d57 2020-04-24 stsp run_test test_rebase_rm_add_rm_file
2011 598eac43 2022-07-22 stsp run_test test_rebase_resets_committer
2012 50e7a649 2022-07-22 stsp run_test test_rebase_no_author_info
2013 442ede73 2022-09-04 stsp run_test test_rebase_nonbranch
2014 b2b3fce1 2022-10-29 op run_test test_rebase_umask
2015 49a1ae4b 2023-01-08 stsp run_test test_rebase_out_of_date2
2016 980c6786 2023-01-31 stsp run_test test_rebase_one_commit