Blame


1 2822a352 2019-10-15 stsp #!/bin/sh
2 2822a352 2019-10-15 stsp #
3 2822a352 2019-10-15 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 2822a352 2019-10-15 stsp #
5 2822a352 2019-10-15 stsp # Permission to use, copy, modify, and distribute this software for any
6 2822a352 2019-10-15 stsp # purpose with or without fee is hereby granted, provided that the above
7 2822a352 2019-10-15 stsp # copyright notice and this permission notice appear in all copies.
8 2822a352 2019-10-15 stsp #
9 2822a352 2019-10-15 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 2822a352 2019-10-15 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 2822a352 2019-10-15 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 2822a352 2019-10-15 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 2822a352 2019-10-15 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 2822a352 2019-10-15 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 2822a352 2019-10-15 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 2822a352 2019-10-15 stsp
17 2822a352 2019-10-15 stsp . ./common.sh
18 2822a352 2019-10-15 stsp
19 f6cae3ed 2020-09-13 naddy test_integrate_basic() {
20 2822a352 2019-10-15 stsp local testroot=`test_init integrate_basic`
21 2822a352 2019-10-15 stsp
22 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q -b newbranch
23 2822a352 2019-10-15 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
24 2822a352 2019-10-15 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
25 2822a352 2019-10-15 stsp
26 2822a352 2019-10-15 stsp echo "modified alpha on branch" > $testroot/repo/alpha
27 d1e03b8c 2023-10-08 thomas git -C $testroot/repo rm -q beta
28 2822a352 2019-10-15 stsp echo "new file on branch" > $testroot/repo/epsilon/new
29 d1e03b8c 2023-10-08 thomas git -C $testroot/repo add epsilon/new
30 2822a352 2019-10-15 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
31 2822a352 2019-10-15 stsp
32 2822a352 2019-10-15 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
33 2822a352 2019-10-15 stsp local orig_commit2=`git_show_head $testroot/repo`
34 2822a352 2019-10-15 stsp
35 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q master
36 2822a352 2019-10-15 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
37 2822a352 2019-10-15 stsp git_commit $testroot/repo -m "committing to zeta on master"
38 2822a352 2019-10-15 stsp local master_commit=`git_show_head $testroot/repo`
39 2822a352 2019-10-15 stsp
40 2822a352 2019-10-15 stsp got checkout $testroot/repo $testroot/wt > /dev/null
41 fc414659 2022-04-16 thomas ret=$?
42 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
43 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
44 2822a352 2019-10-15 stsp return 1
45 2822a352 2019-10-15 stsp fi
46 2822a352 2019-10-15 stsp
47 2822a352 2019-10-15 stsp (cd $testroot/wt && got rebase newbranch > /dev/null)
48 fc414659 2022-04-16 thomas ret=$?
49 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
50 2822a352 2019-10-15 stsp echo "got rebase failed unexpectedly"
51 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
52 2822a352 2019-10-15 stsp return 1
53 2822a352 2019-10-15 stsp fi
54 2822a352 2019-10-15 stsp
55 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q newbranch
56 2822a352 2019-10-15 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
57 2822a352 2019-10-15 stsp local new_commit2=`git_show_head $testroot/repo`
58 2822a352 2019-10-15 stsp
59 2822a352 2019-10-15 stsp (cd $testroot/wt && got update -b master > /dev/null)
60 fc414659 2022-04-16 thomas ret=$?
61 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
62 2822a352 2019-10-15 stsp echo "got update failed unexpectedly"
63 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
64 2822a352 2019-10-15 stsp return 1
65 2822a352 2019-10-15 stsp fi
66 2822a352 2019-10-15 stsp
67 2822a352 2019-10-15 stsp (cd $testroot/wt && got integrate newbranch > $testroot/stdout)
68 2822a352 2019-10-15 stsp
69 2822a352 2019-10-15 stsp echo "U alpha" > $testroot/stdout.expected
70 2822a352 2019-10-15 stsp echo "D beta" >> $testroot/stdout.expected
71 2822a352 2019-10-15 stsp echo "A epsilon/new" >> $testroot/stdout.expected
72 2822a352 2019-10-15 stsp echo "U gamma/delta" >> $testroot/stdout.expected
73 2822a352 2019-10-15 stsp echo "Integrated refs/heads/newbranch into refs/heads/master" \
74 2822a352 2019-10-15 stsp >> $testroot/stdout.expected
75 2822a352 2019-10-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
76 fc414659 2022-04-16 thomas ret=$?
77 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
78 2822a352 2019-10-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
79 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
80 2822a352 2019-10-15 stsp return 1
81 2822a352 2019-10-15 stsp fi
82 2822a352 2019-10-15 stsp
83 2822a352 2019-10-15 stsp echo "modified delta on branch" > $testroot/content.expected
84 2822a352 2019-10-15 stsp cat $testroot/wt/gamma/delta > $testroot/content
85 2822a352 2019-10-15 stsp cmp -s $testroot/content.expected $testroot/content
86 fc414659 2022-04-16 thomas ret=$?
87 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
88 2822a352 2019-10-15 stsp diff -u $testroot/content.expected $testroot/content
89 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
90 2822a352 2019-10-15 stsp return 1
91 2822a352 2019-10-15 stsp fi
92 2822a352 2019-10-15 stsp
93 2822a352 2019-10-15 stsp echo "modified alpha on branch" > $testroot/content.expected
94 2822a352 2019-10-15 stsp cat $testroot/wt/alpha > $testroot/content
95 2822a352 2019-10-15 stsp cmp -s $testroot/content.expected $testroot/content
96 fc414659 2022-04-16 thomas ret=$?
97 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
98 2822a352 2019-10-15 stsp diff -u $testroot/content.expected $testroot/content
99 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
100 2822a352 2019-10-15 stsp return 1
101 2822a352 2019-10-15 stsp fi
102 2822a352 2019-10-15 stsp
103 2822a352 2019-10-15 stsp if [ -e $testroot/wt/beta ]; then
104 2822a352 2019-10-15 stsp echo "removed file beta still exists on disk" >&2
105 2822a352 2019-10-15 stsp test_done "$testroot" "1"
106 2822a352 2019-10-15 stsp return 1
107 2822a352 2019-10-15 stsp fi
108 2822a352 2019-10-15 stsp
109 2822a352 2019-10-15 stsp echo "new file on branch" > $testroot/content.expected
110 2822a352 2019-10-15 stsp cat $testroot/wt/epsilon/new > $testroot/content
111 2822a352 2019-10-15 stsp cmp -s $testroot/content.expected $testroot/content
112 fc414659 2022-04-16 thomas ret=$?
113 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
114 2822a352 2019-10-15 stsp diff -u $testroot/content.expected $testroot/content
115 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
116 2822a352 2019-10-15 stsp return 1
117 2822a352 2019-10-15 stsp fi
118 2822a352 2019-10-15 stsp
119 2822a352 2019-10-15 stsp (cd $testroot/wt && got status > $testroot/stdout)
120 2822a352 2019-10-15 stsp
121 2822a352 2019-10-15 stsp echo -n > $testroot/stdout.expected
122 2822a352 2019-10-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
123 fc414659 2022-04-16 thomas ret=$?
124 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
125 2822a352 2019-10-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
126 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
127 2822a352 2019-10-15 stsp return 1
128 2822a352 2019-10-15 stsp fi
129 2822a352 2019-10-15 stsp
130 2822a352 2019-10-15 stsp (cd $testroot/wt && got log -l3 | grep ^commit > $testroot/stdout)
131 2822a352 2019-10-15 stsp echo "commit $new_commit2 (master, newbranch)" \
132 2822a352 2019-10-15 stsp > $testroot/stdout.expected
133 2822a352 2019-10-15 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
134 2822a352 2019-10-15 stsp echo "commit $master_commit" >> $testroot/stdout.expected
135 6e210706 2021-01-22 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 6e210706 2021-01-22 stsp diff -u $testroot/stdout.expected $testroot/stdout
139 6e210706 2021-01-22 stsp test_done "$testroot" "$ret"
140 6e210706 2021-01-22 stsp return 1
141 6e210706 2021-01-22 stsp fi
142 6e210706 2021-01-22 stsp
143 6e210706 2021-01-22 stsp (cd $testroot/wt && got update > $testroot/stdout)
144 6e210706 2021-01-22 stsp echo "Already up-to-date" > $testroot/stdout.expected
145 2822a352 2019-10-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
146 fc414659 2022-04-16 thomas ret=$?
147 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
148 2822a352 2019-10-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
149 2822a352 2019-10-15 stsp fi
150 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
151 2822a352 2019-10-15 stsp }
152 2822a352 2019-10-15 stsp
153 f6cae3ed 2020-09-13 naddy test_integrate_requires_rebase_first() {
154 2822a352 2019-10-15 stsp local testroot=`test_init integrate_requires_rebase_first`
155 2822a352 2019-10-15 stsp local init_commit=`git_show_head $testroot/repo`
156 2822a352 2019-10-15 stsp
157 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q -b newbranch
158 2822a352 2019-10-15 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
159 2822a352 2019-10-15 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
160 2822a352 2019-10-15 stsp
161 2822a352 2019-10-15 stsp echo "modified alpha on branch" > $testroot/repo/alpha
162 d1e03b8c 2023-10-08 thomas git -C $testroot/repo rm -q beta
163 2822a352 2019-10-15 stsp echo "new file on branch" > $testroot/repo/epsilon/new
164 d1e03b8c 2023-10-08 thomas git -C $testroot/repo add epsilon/new
165 2822a352 2019-10-15 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
166 2822a352 2019-10-15 stsp
167 2822a352 2019-10-15 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
168 2822a352 2019-10-15 stsp local orig_commit2=`git_show_head $testroot/repo`
169 2822a352 2019-10-15 stsp
170 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q master
171 2822a352 2019-10-15 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
172 2822a352 2019-10-15 stsp git_commit $testroot/repo -m "committing to zeta on master"
173 2822a352 2019-10-15 stsp local master_commit=`git_show_head $testroot/repo`
174 2822a352 2019-10-15 stsp
175 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q newbranch
176 2822a352 2019-10-15 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
177 2822a352 2019-10-15 stsp local new_commit2=`git_show_head $testroot/repo`
178 2822a352 2019-10-15 stsp
179 2822a352 2019-10-15 stsp got checkout -b master $testroot/repo $testroot/wt > /dev/null
180 fc414659 2022-04-16 thomas ret=$?
181 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
182 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
183 2822a352 2019-10-15 stsp return 1
184 2822a352 2019-10-15 stsp fi
185 2822a352 2019-10-15 stsp
186 2822a352 2019-10-15 stsp (cd $testroot/wt && got integrate newbranch \
187 2822a352 2019-10-15 stsp > $testroot/stdout 2> $testroot/stderr)
188 fc414659 2022-04-16 thomas ret=$?
189 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
190 2822a352 2019-10-15 stsp echo "got integrate succeeded unexpectedly"
191 0b477035 2023-06-22 thomas test_done "$testroot" "1"
192 2822a352 2019-10-15 stsp return 1
193 2822a352 2019-10-15 stsp fi
194 2822a352 2019-10-15 stsp
195 2822a352 2019-10-15 stsp echo -n > $testroot/stdout.expected
196 2822a352 2019-10-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
197 fc414659 2022-04-16 thomas ret=$?
198 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
199 2822a352 2019-10-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
200 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
201 2822a352 2019-10-15 stsp return 1
202 2822a352 2019-10-15 stsp fi
203 2822a352 2019-10-15 stsp
204 2822a352 2019-10-15 stsp echo "got: specified branch must be rebased first" \
205 2822a352 2019-10-15 stsp > $testroot/stderr.expected
206 2822a352 2019-10-15 stsp cmp -s $testroot/stderr.expected $testroot/stderr
207 fc414659 2022-04-16 thomas ret=$?
208 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
209 2822a352 2019-10-15 stsp diff -u $testroot/stderr.expected $testroot/stderr
210 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
211 2822a352 2019-10-15 stsp return 1
212 2822a352 2019-10-15 stsp fi
213 2822a352 2019-10-15 stsp
214 2822a352 2019-10-15 stsp (cd $testroot/repo && got log -c master | \
215 2822a352 2019-10-15 stsp grep ^commit > $testroot/stdout)
216 2822a352 2019-10-15 stsp echo "commit $master_commit (master)" > $testroot/stdout.expected
217 2822a352 2019-10-15 stsp echo "commit $init_commit" >> $testroot/stdout.expected
218 2822a352 2019-10-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
219 fc414659 2022-04-16 thomas ret=$?
220 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
221 2822a352 2019-10-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
222 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
223 2822a352 2019-10-15 stsp return 1
224 2822a352 2019-10-15 stsp fi
225 2822a352 2019-10-15 stsp
226 2822a352 2019-10-15 stsp (cd $testroot/repo && got log -c newbranch | \
227 2822a352 2019-10-15 stsp grep ^commit > $testroot/stdout)
228 2822a352 2019-10-15 stsp echo "commit $new_commit2 (newbranch)" \
229 2822a352 2019-10-15 stsp > $testroot/stdout.expected
230 2822a352 2019-10-15 stsp echo "commit $new_commit1" >> $testroot/stdout.expected
231 2822a352 2019-10-15 stsp echo "commit $init_commit" >> $testroot/stdout.expected
232 2822a352 2019-10-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
233 fc414659 2022-04-16 thomas ret=$?
234 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
235 8b692cd0 2019-10-21 stsp diff -u $testroot/stdout.expected $testroot/stdout
236 8b692cd0 2019-10-21 stsp test_done "$testroot" "$ret"
237 8b692cd0 2019-10-21 stsp return 1
238 8b692cd0 2019-10-21 stsp fi
239 8b692cd0 2019-10-21 stsp
240 8b692cd0 2019-10-21 stsp (cd $testroot/repo && got branch -l > $testroot/stdout)
241 fc414659 2022-04-16 thomas ret=$?
242 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
243 8b692cd0 2019-10-21 stsp echo "got rebase failed unexpectedly"
244 8b692cd0 2019-10-21 stsp test_done "$testroot" "$ret"
245 8b692cd0 2019-10-21 stsp return 1
246 8b692cd0 2019-10-21 stsp fi
247 8b692cd0 2019-10-21 stsp
248 8b692cd0 2019-10-21 stsp echo " master: $master_commit" > $testroot/stdout.expected
249 8b692cd0 2019-10-21 stsp echo " newbranch: $new_commit2" >> $testroot/stdout.expected
250 2822a352 2019-10-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
251 fc414659 2022-04-16 thomas ret=$?
252 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
253 2822a352 2019-10-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
254 2822a352 2019-10-15 stsp fi
255 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
256 2822a352 2019-10-15 stsp }
257 2822a352 2019-10-15 stsp
258 f6cae3ed 2020-09-13 naddy test_integrate_path_prefix() {
259 2822a352 2019-10-15 stsp local testroot=`test_init integrate_path_prefix`
260 2822a352 2019-10-15 stsp
261 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q -b newbranch
262 2822a352 2019-10-15 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
263 2822a352 2019-10-15 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
264 2822a352 2019-10-15 stsp
265 2822a352 2019-10-15 stsp echo "modified alpha on branch" > $testroot/repo/alpha
266 d1e03b8c 2023-10-08 thomas git -C $testroot/repo rm -q beta
267 2822a352 2019-10-15 stsp echo "new file on branch" > $testroot/repo/epsilon/new
268 d1e03b8c 2023-10-08 thomas git -C $testroot/repo add epsilon/new
269 2822a352 2019-10-15 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
270 2822a352 2019-10-15 stsp
271 2822a352 2019-10-15 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
272 2822a352 2019-10-15 stsp local orig_commit2=`git_show_head $testroot/repo`
273 2822a352 2019-10-15 stsp
274 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q master
275 2822a352 2019-10-15 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
276 2822a352 2019-10-15 stsp git_commit $testroot/repo -m "committing to zeta on master"
277 2822a352 2019-10-15 stsp local master_commit=`git_show_head $testroot/repo`
278 2822a352 2019-10-15 stsp
279 2822a352 2019-10-15 stsp got checkout $testroot/repo $testroot/wt > /dev/null
280 fc414659 2022-04-16 thomas ret=$?
281 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
282 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
283 2822a352 2019-10-15 stsp return 1
284 2822a352 2019-10-15 stsp fi
285 2822a352 2019-10-15 stsp
286 2822a352 2019-10-15 stsp (cd $testroot/wt && got rebase newbranch > /dev/null)
287 fc414659 2022-04-16 thomas ret=$?
288 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
289 2822a352 2019-10-15 stsp echo "got rebase failed unexpectedly"
290 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
291 2822a352 2019-10-15 stsp return 1
292 2822a352 2019-10-15 stsp fi
293 2822a352 2019-10-15 stsp
294 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q newbranch
295 2822a352 2019-10-15 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
296 2822a352 2019-10-15 stsp local new_commit2=`git_show_head $testroot/repo`
297 2822a352 2019-10-15 stsp
298 2822a352 2019-10-15 stsp rm -r $testroot/wt
299 2822a352 2019-10-15 stsp got checkout -b master -p epsilon $testroot/repo $testroot/wt \
300 2822a352 2019-10-15 stsp > /dev/null
301 fc414659 2022-04-16 thomas ret=$?
302 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
303 2822a352 2019-10-15 stsp echo "got checkout failed unexpectedly"
304 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
305 2822a352 2019-10-15 stsp return 1
306 2822a352 2019-10-15 stsp fi
307 2822a352 2019-10-15 stsp
308 2822a352 2019-10-15 stsp (cd $testroot/wt && got integrate newbranch > $testroot/stdout)
309 2822a352 2019-10-15 stsp
310 2822a352 2019-10-15 stsp echo "A new" > $testroot/stdout.expected
311 2822a352 2019-10-15 stsp echo "Integrated refs/heads/newbranch into refs/heads/master" \
312 2822a352 2019-10-15 stsp >> $testroot/stdout.expected
313 2822a352 2019-10-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
314 fc414659 2022-04-16 thomas ret=$?
315 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
316 2822a352 2019-10-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
317 2822a352 2019-10-15 stsp fi
318 2822a352 2019-10-15 stsp test_done "$testroot" "$ret"
319 2822a352 2019-10-15 stsp }
320 3aef623b 2019-10-15 stsp
321 f6cae3ed 2020-09-13 naddy test_integrate_backwards_in_time() {
322 3aef623b 2019-10-15 stsp local testroot=`test_init integrate_backwards_in_time`
323 3aef623b 2019-10-15 stsp
324 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q -b newbranch
325 3aef623b 2019-10-15 stsp echo "modified delta on branch" > $testroot/repo/gamma/delta
326 3aef623b 2019-10-15 stsp git_commit $testroot/repo -m "committing to delta on newbranch"
327 3aef623b 2019-10-15 stsp
328 3aef623b 2019-10-15 stsp echo "modified alpha on branch" > $testroot/repo/alpha
329 d1e03b8c 2023-10-08 thomas git -C $testroot/repo rm -q beta
330 3aef623b 2019-10-15 stsp echo "new file on branch" > $testroot/repo/epsilon/new
331 d1e03b8c 2023-10-08 thomas git -C $testroot/repo add epsilon/new
332 3aef623b 2019-10-15 stsp git_commit $testroot/repo -m "committing more changes on newbranch"
333 3aef623b 2019-10-15 stsp
334 3aef623b 2019-10-15 stsp local orig_commit1=`git_show_parent_commit $testroot/repo`
335 3aef623b 2019-10-15 stsp local orig_commit2=`git_show_head $testroot/repo`
336 3aef623b 2019-10-15 stsp
337 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q master
338 3aef623b 2019-10-15 stsp echo "modified zeta on master" > $testroot/repo/epsilon/zeta
339 3aef623b 2019-10-15 stsp git_commit $testroot/repo -m "committing to zeta on master"
340 3aef623b 2019-10-15 stsp local master_commit=`git_show_head $testroot/repo`
341 2822a352 2019-10-15 stsp
342 3aef623b 2019-10-15 stsp got checkout $testroot/repo $testroot/wt > /dev/null
343 fc414659 2022-04-16 thomas ret=$?
344 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
345 3aef623b 2019-10-15 stsp test_done "$testroot" "$ret"
346 3aef623b 2019-10-15 stsp return 1
347 3aef623b 2019-10-15 stsp fi
348 2822a352 2019-10-15 stsp
349 3aef623b 2019-10-15 stsp (cd $testroot/wt && got rebase newbranch > /dev/null)
350 fc414659 2022-04-16 thomas ret=$?
351 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
352 3aef623b 2019-10-15 stsp echo "got rebase failed unexpectedly"
353 3aef623b 2019-10-15 stsp test_done "$testroot" "$ret"
354 3aef623b 2019-10-15 stsp return 1
355 3aef623b 2019-10-15 stsp fi
356 3aef623b 2019-10-15 stsp
357 d1e03b8c 2023-10-08 thomas git -C $testroot/repo checkout -q newbranch
358 3aef623b 2019-10-15 stsp local new_commit1=`git_show_parent_commit $testroot/repo`
359 3aef623b 2019-10-15 stsp local new_commit2=`git_show_head $testroot/repo`
360 3aef623b 2019-10-15 stsp
361 3aef623b 2019-10-15 stsp # attempt to integrate master into newbranch (wrong way around)
362 3aef623b 2019-10-15 stsp (cd $testroot/wt && got update -b newbranch > /dev/null)
363 fc414659 2022-04-16 thomas ret=$?
364 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
365 3aef623b 2019-10-15 stsp echo "got update failed unexpectedly"
366 3aef623b 2019-10-15 stsp test_done "$testroot" "$ret"
367 3aef623b 2019-10-15 stsp return 1
368 3aef623b 2019-10-15 stsp fi
369 3aef623b 2019-10-15 stsp
370 3aef623b 2019-10-15 stsp (cd $testroot/wt && got integrate master \
371 3aef623b 2019-10-15 stsp > $testroot/stdout 2> $testroot/stderr)
372 fc414659 2022-04-16 thomas ret=$?
373 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
374 3aef623b 2019-10-15 stsp echo "got integrate succeeded unexpectedly"
375 4e2bdb0d 2022-06-13 thomas test_done "$testroot" "1"
376 3aef623b 2019-10-15 stsp return 1
377 3aef623b 2019-10-15 stsp fi
378 3aef623b 2019-10-15 stsp
379 3aef623b 2019-10-15 stsp echo -n > $testroot/stdout.expected
380 3aef623b 2019-10-15 stsp cmp -s $testroot/stdout.expected $testroot/stdout
381 fc414659 2022-04-16 thomas ret=$?
382 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
383 3aef623b 2019-10-15 stsp diff -u $testroot/stdout.expected $testroot/stdout
384 3aef623b 2019-10-15 stsp test_done "$testroot" "$ret"
385 3aef623b 2019-10-15 stsp return 1
386 3aef623b 2019-10-15 stsp fi
387 3aef623b 2019-10-15 stsp
388 3aef623b 2019-10-15 stsp echo "got: specified branch must be rebased first" \
389 3aef623b 2019-10-15 stsp > $testroot/stderr.expected
390 3aef623b 2019-10-15 stsp cmp -s $testroot/stderr.expected $testroot/stderr
391 fc414659 2022-04-16 thomas ret=$?
392 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
393 3aef623b 2019-10-15 stsp diff -u $testroot/stderr.expected $testroot/stderr
394 3aef623b 2019-10-15 stsp fi
395 3aef623b 2019-10-15 stsp test_done "$testroot" "$ret"
396 3aef623b 2019-10-15 stsp }
397 9314b9f4 2020-11-06 stsp
398 f6d8c0ac 2020-11-09 stsp test_integrate_replace_symlink_with_file() {
399 f6d8c0ac 2020-11-09 stsp local testroot=`test_init integrate_replace_symlink_with_file`
400 9314b9f4 2020-11-06 stsp
401 9314b9f4 2020-11-06 stsp got checkout $testroot/repo $testroot/wt > /dev/null
402 fc414659 2022-04-16 thomas ret=$?
403 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
404 9314b9f4 2020-11-06 stsp echo "checkout failed unexpectedly" >&2
405 9314b9f4 2020-11-06 stsp test_done "$testroot" "$ret"
406 9314b9f4 2020-11-06 stsp return 1
407 9314b9f4 2020-11-06 stsp fi
408 3aef623b 2019-10-15 stsp
409 9314b9f4 2020-11-06 stsp (cd $testroot/wt && ln -s alpha alpha.link)
410 9314b9f4 2020-11-06 stsp (cd $testroot/wt && got add alpha alpha.link >/dev/null)
411 9314b9f4 2020-11-06 stsp (cd $testroot/wt && got commit -m "add regular file and symlink" \
412 9314b9f4 2020-11-06 stsp >/dev/null)
413 9314b9f4 2020-11-06 stsp
414 f6d8c0ac 2020-11-09 stsp (cd $testroot/wt && got br replace_symlink_with_file >/dev/null)
415 9314b9f4 2020-11-06 stsp (cd $testroot/wt && rm alpha.link >/dev/null)
416 9314b9f4 2020-11-06 stsp (cd $testroot/wt && cp alpha alpha.link)
417 9314b9f4 2020-11-06 stsp (cd $testroot/wt && got stage alpha.link >/dev/null)
418 9314b9f4 2020-11-06 stsp (cd $testroot/wt && got commit -m "replace symlink" >/dev/null)
419 9314b9f4 2020-11-06 stsp
420 9314b9f4 2020-11-06 stsp (cd $testroot/wt && got up -b master >/dev/null)
421 f6d8c0ac 2020-11-09 stsp (cd $testroot/wt && got integrate replace_symlink_with_file \
422 f6d8c0ac 2020-11-09 stsp > $testroot/stdout)
423 9314b9f4 2020-11-06 stsp
424 f6d8c0ac 2020-11-09 stsp echo "U alpha.link" > $testroot/stdout.expected
425 f6d8c0ac 2020-11-09 stsp echo -n "Integrated refs/heads/replace_symlink_with_file " \
426 f6d8c0ac 2020-11-09 stsp >> $testroot/stdout.expected
427 f6d8c0ac 2020-11-09 stsp echo "into refs/heads/master" >> $testroot/stdout.expected
428 f6d8c0ac 2020-11-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
429 fc414659 2022-04-16 thomas ret=$?
430 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
431 f6d8c0ac 2020-11-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
432 f6d8c0ac 2020-11-09 stsp test_done "$testroot" "$ret"
433 f6d8c0ac 2020-11-09 stsp return 1
434 f6d8c0ac 2020-11-09 stsp fi
435 f6d8c0ac 2020-11-09 stsp
436 f6d8c0ac 2020-11-09 stsp if [ -h $testroot/wt/alpha.link ]; then
437 f6d8c0ac 2020-11-09 stsp echo "alpha.link is still a symlink"
438 f6d8c0ac 2020-11-09 stsp test_done "$testroot" "1"
439 f6d8c0ac 2020-11-09 stsp return 1
440 9314b9f4 2020-11-06 stsp fi
441 f6d8c0ac 2020-11-09 stsp
442 f6d8c0ac 2020-11-09 stsp echo "alpha" > $testroot/content.expected
443 f6d8c0ac 2020-11-09 stsp cat $testroot/wt/alpha.link > $testroot/content
444 f6d8c0ac 2020-11-09 stsp
445 f6d8c0ac 2020-11-09 stsp cmp -s $testroot/content.expected $testroot/content
446 fc414659 2022-04-16 thomas ret=$?
447 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
448 f6d8c0ac 2020-11-09 stsp diff -u $testroot/content.expected $testroot/content
449 f6d8c0ac 2020-11-09 stsp fi
450 9314b9f4 2020-11-06 stsp test_done "$testroot" "$ret"
451 9314b9f4 2020-11-06 stsp }
452 9314b9f4 2020-11-06 stsp
453 f6d8c0ac 2020-11-09 stsp test_integrate_replace_file_with_symlink() {
454 f6d8c0ac 2020-11-09 stsp local testroot=`test_init integrate_replace_file_with_symlink`
455 f6d8c0ac 2020-11-09 stsp
456 f6d8c0ac 2020-11-09 stsp got checkout $testroot/repo $testroot/wt > /dev/null
457 fc414659 2022-04-16 thomas ret=$?
458 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
459 f6d8c0ac 2020-11-09 stsp echo "checkout failed unexpectedly" >&2
460 f6d8c0ac 2020-11-09 stsp test_done "$testroot" "$ret"
461 f6d8c0ac 2020-11-09 stsp return 1
462 f6d8c0ac 2020-11-09 stsp fi
463 f6d8c0ac 2020-11-09 stsp
464 f6d8c0ac 2020-11-09 stsp (cd $testroot/wt && got br replace_file_with_symlink >/dev/null)
465 f6d8c0ac 2020-11-09 stsp (cd $testroot/wt && rm alpha)
466 f6d8c0ac 2020-11-09 stsp (cd $testroot/wt && ln -s beta alpha)
467 f6d8c0ac 2020-11-09 stsp (cd $testroot/wt && got commit -m "replace regular file with symlink" \
468 f6d8c0ac 2020-11-09 stsp >/dev/null)
469 f6d8c0ac 2020-11-09 stsp
470 f6d8c0ac 2020-11-09 stsp (cd $testroot/wt && got up -b master >/dev/null)
471 f6d8c0ac 2020-11-09 stsp (cd $testroot/wt && got integrate replace_file_with_symlink \
472 f6d8c0ac 2020-11-09 stsp > $testroot/stdout)
473 f6d8c0ac 2020-11-09 stsp
474 f6d8c0ac 2020-11-09 stsp echo "U alpha" > $testroot/stdout.expected
475 f6d8c0ac 2020-11-09 stsp echo -n "Integrated refs/heads/replace_file_with_symlink " \
476 f6d8c0ac 2020-11-09 stsp >> $testroot/stdout.expected
477 f6d8c0ac 2020-11-09 stsp echo "into refs/heads/master" >> $testroot/stdout.expected
478 f6d8c0ac 2020-11-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
479 fc414659 2022-04-16 thomas ret=$?
480 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
481 f6d8c0ac 2020-11-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
482 f6d8c0ac 2020-11-09 stsp test_done "$testroot" "$ret"
483 f6d8c0ac 2020-11-09 stsp return 1
484 f6d8c0ac 2020-11-09 stsp fi
485 f6d8c0ac 2020-11-09 stsp
486 f6d8c0ac 2020-11-09 stsp if ! [ -h $testroot/wt/alpha ]; then
487 f6d8c0ac 2020-11-09 stsp echo "alpha is not a symlink"
488 f6d8c0ac 2020-11-09 stsp test_done "$testroot" "1"
489 f6d8c0ac 2020-11-09 stsp return 1
490 f6d8c0ac 2020-11-09 stsp fi
491 f6d8c0ac 2020-11-09 stsp
492 f6d8c0ac 2020-11-09 stsp readlink $testroot/wt/alpha > $testroot/stdout
493 f6d8c0ac 2020-11-09 stsp echo "beta" > $testroot/stdout.expected
494 f6d8c0ac 2020-11-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
495 fc414659 2022-04-16 thomas ret=$?
496 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
497 f6d8c0ac 2020-11-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
498 885707ed 2022-09-27 thomas fi
499 885707ed 2022-09-27 thomas test_done "$testroot" "$ret"
500 885707ed 2022-09-27 thomas }
501 885707ed 2022-09-27 thomas
502 885707ed 2022-09-27 thomas test_integrate_into_nonbranch() {
503 885707ed 2022-09-27 thomas local testroot=`test_init test_integrate_into_nonbranch`
504 885707ed 2022-09-27 thomas
505 885707ed 2022-09-27 thomas got checkout $testroot/repo $testroot/wt > /dev/null
506 885707ed 2022-09-27 thomas ret=$?
507 885707ed 2022-09-27 thomas if [ $ret -ne 0 ]; then
508 885707ed 2022-09-27 thomas echo "checkout failed unexpectedly" >&2
509 885707ed 2022-09-27 thomas test_done "$testroot" "$ret"
510 885707ed 2022-09-27 thomas return 1
511 885707ed 2022-09-27 thomas fi
512 885707ed 2022-09-27 thomas
513 885707ed 2022-09-27 thomas local commit=`git_show_head $testroot/repo`
514 885707ed 2022-09-27 thomas (cd $testroot/repo && got ref -c $commit refs/remotes/origin/master)
515 885707ed 2022-09-27 thomas
516 885707ed 2022-09-27 thomas echo "modified alpha on branch" > $testroot/repo/alpha
517 885707ed 2022-09-27 thomas git_commit $testroot/repo -m "committing to alpha on master"
518 885707ed 2022-09-27 thomas
519 885707ed 2022-09-27 thomas (cd $testroot/wt && got up -b origin/master > /dev/null)
520 885707ed 2022-09-27 thomas ret=$?
521 885707ed 2022-09-27 thomas if [ $ret -ne 0 ]; then
522 885707ed 2022-09-27 thomas echo "got branch failed unexpectedly"
523 885707ed 2022-09-27 thomas test_done "$testroot" "$ret"
524 885707ed 2022-09-27 thomas return 1
525 f6d8c0ac 2020-11-09 stsp fi
526 885707ed 2022-09-27 thomas
527 885707ed 2022-09-27 thomas (cd $testroot/wt && got integrate master \
528 885707ed 2022-09-27 thomas > $testroot/stdout 2> $testroot/stderr)
529 885707ed 2022-09-27 thomas ret=$?
530 885707ed 2022-09-27 thomas if [ $ret -eq 0 ]; then
531 885707ed 2022-09-27 thomas echo "got integrate succeeded unexpectedly"
532 0b477035 2023-06-22 thomas test_done "$testroot" "1"
533 885707ed 2022-09-27 thomas return 1
534 885707ed 2022-09-27 thomas fi
535 885707ed 2022-09-27 thomas
536 885707ed 2022-09-27 thomas echo -n "got: will not integrate into a reference outside the " \
537 885707ed 2022-09-27 thomas > $testroot/stderr.expected
538 885707ed 2022-09-27 thomas echo "\"refs/heads/\" reference namespace" >> $testroot/stderr.expected
539 885707ed 2022-09-27 thomas cmp -s $testroot/stderr.expected $testroot/stderr
540 885707ed 2022-09-27 thomas ret=$?
541 885707ed 2022-09-27 thomas if [ $ret -ne 0 ]; then
542 885707ed 2022-09-27 thomas diff -u $testroot/stderr.expected $testroot/stderr
543 885707ed 2022-09-27 thomas fi
544 f6d8c0ac 2020-11-09 stsp test_done "$testroot" "$ret"
545 f6d8c0ac 2020-11-09 stsp }
546 f6d8c0ac 2020-11-09 stsp
547 7fb414ae 2020-08-08 stsp test_parseargs "$@"
548 2822a352 2019-10-15 stsp run_test test_integrate_basic
549 2822a352 2019-10-15 stsp run_test test_integrate_requires_rebase_first
550 2822a352 2019-10-15 stsp run_test test_integrate_path_prefix
551 3aef623b 2019-10-15 stsp run_test test_integrate_backwards_in_time
552 f6d8c0ac 2020-11-09 stsp run_test test_integrate_replace_symlink_with_file
553 f6d8c0ac 2020-11-09 stsp run_test test_integrate_replace_file_with_symlink
554 885707ed 2022-09-27 thomas run_test test_integrate_into_nonbranch