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