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