3 0e673013 2019-01-02 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
5 0e673013 2019-01-02 stsp # Permission to use, copy, modify, and distribute this software for any
6 0e673013 2019-01-02 stsp # purpose with or without fee is hereby granted, provided that the above
7 0e673013 2019-01-02 stsp # copyright notice and this permission notice appear in all copies.
9 0e673013 2019-01-02 stsp # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 0e673013 2019-01-02 stsp # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 0e673013 2019-01-02 stsp # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 0e673013 2019-01-02 stsp # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 0e673013 2019-01-02 stsp # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 0e673013 2019-01-02 stsp # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 0e673013 2019-01-02 stsp # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 0e673013 2019-01-02 stsp . ./common.sh
19 f6cae3ed 2020-09-13 naddy test_checkout_basic() {
20 0e673013 2019-01-02 stsp local testroot=`test_init checkout_basic`
21 08e5873e 2021-09-14 stsp local commit_id=`git_show_head $testroot/repo`
23 0e673013 2019-01-02 stsp echo "A $testroot/wt/alpha" > $testroot/stdout.expected
24 0e673013 2019-01-02 stsp echo "A $testroot/wt/beta" >> $testroot/stdout.expected
25 0e673013 2019-01-02 stsp echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
26 0e673013 2019-01-02 stsp echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
27 08e5873e 2021-09-14 stsp echo "Checked out refs/heads/master: $commit_id" \
28 08e5873e 2021-09-14 stsp >> $testroot/stdout.expected
29 0e673013 2019-01-02 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
31 0e673013 2019-01-02 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
33 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
34 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
38 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
40 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
41 0e673013 2019-01-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
42 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
46 0e673013 2019-01-02 stsp echo "alpha" > $testroot/content.expected
47 0e673013 2019-01-02 stsp echo "beta" >> $testroot/content.expected
48 0e673013 2019-01-02 stsp echo "zeta" >> $testroot/content.expected
49 0e673013 2019-01-02 stsp echo "delta" >> $testroot/content.expected
50 0e673013 2019-01-02 stsp cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
51 0e673013 2019-01-02 stsp $testroot/wt/gamma/delta > $testroot/content
53 8d301dd9 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
55 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
56 0e673013 2019-01-02 stsp diff -u $testroot/content.expected $testroot/content
58 693719bc 2019-01-03 stsp test_done "$testroot" "$ret"
61 f6cae3ed 2020-09-13 naddy test_checkout_dir_exists() {
62 80c1b583 2019-08-07 stsp local testroot=`test_init checkout_dir_exists`
63 08e5873e 2021-09-14 stsp local commit_id=`git_show_head $testroot/repo`
65 80c1b583 2019-08-07 stsp echo "A $testroot/wt/alpha" > $testroot/stdout.expected
66 80c1b583 2019-08-07 stsp echo "A $testroot/wt/beta" >> $testroot/stdout.expected
67 80c1b583 2019-08-07 stsp echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
68 80c1b583 2019-08-07 stsp echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
69 08e5873e 2021-09-14 stsp echo "Checked out refs/heads/master: $commit_id" \
70 08e5873e 2021-09-14 stsp >> $testroot/stdout.expected
71 80c1b583 2019-08-07 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
73 80c1b583 2019-08-07 stsp mkdir $testroot/wt
75 80c1b583 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
77 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
78 80c1b583 2019-08-07 stsp test_done "$testroot" "$ret"
82 80c1b583 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
84 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
85 80c1b583 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
86 80c1b583 2019-08-07 stsp test_done "$testroot" "$ret"
90 80c1b583 2019-08-07 stsp echo "alpha" > $testroot/content.expected
91 80c1b583 2019-08-07 stsp echo "beta" >> $testroot/content.expected
92 80c1b583 2019-08-07 stsp echo "zeta" >> $testroot/content.expected
93 80c1b583 2019-08-07 stsp echo "delta" >> $testroot/content.expected
94 80c1b583 2019-08-07 stsp cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
95 80c1b583 2019-08-07 stsp $testroot/wt/gamma/delta > $testroot/content
97 80c1b583 2019-08-07 stsp cmp -s $testroot/content.expected $testroot/content
99 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
100 80c1b583 2019-08-07 stsp diff -u $testroot/content.expected $testroot/content
102 80c1b583 2019-08-07 stsp test_done "$testroot" "$ret"
105 f6cae3ed 2020-09-13 naddy test_checkout_dir_not_empty() {
106 80c1b583 2019-08-07 stsp local testroot=`test_init checkout_dir_not_empty`
107 08e5873e 2021-09-14 stsp local commit_id=`git_show_head $testroot/repo`
109 80c1b583 2019-08-07 stsp echo "A $testroot/wt/alpha" > $testroot/stdout.expected
110 80c1b583 2019-08-07 stsp echo "A $testroot/wt/beta" >> $testroot/stdout.expected
111 80c1b583 2019-08-07 stsp echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
112 80c1b583 2019-08-07 stsp echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
113 08e5873e 2021-09-14 stsp echo "Checked out refs/heads/master: $commit_id" \
114 08e5873e 2021-09-14 stsp >> $testroot/stdout.expected
115 80c1b583 2019-08-07 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
117 80c1b583 2019-08-07 stsp mkdir $testroot/wt
118 80c1b583 2019-08-07 stsp touch $testroot/wt/foo
120 80c1b583 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout \
121 80c1b583 2019-08-07 stsp 2> $testroot/stderr
123 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
124 80c1b583 2019-08-07 stsp echo "checkout succeeded unexpectedly" >&2
125 80c1b583 2019-08-07 stsp test_done "$testroot" "1"
129 80c1b583 2019-08-07 stsp echo "got: $testroot/wt: directory exists and is not empty" \
130 80c1b583 2019-08-07 stsp > $testroot/stderr.expected
131 80c1b583 2019-08-07 stsp cmp -s $testroot/stderr.expected $testroot/stderr
133 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
134 80c1b583 2019-08-07 stsp diff -u $testroot/stderr.expected $testroot/stderr
135 80c1b583 2019-08-07 stsp test_done "$testroot" "$ret"
139 80c1b583 2019-08-07 stsp echo -n > $testroot/stdout.expected
140 80c1b583 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
142 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
143 80c1b583 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
145 80c1b583 2019-08-07 stsp test_done "$testroot" "$ret"
149 f6cae3ed 2020-09-13 naddy test_checkout_sets_xbit() {
150 68ed9ba5 2019-02-10 stsp local testroot=`test_init checkout_sets_xbit 1`
152 68ed9ba5 2019-02-10 stsp touch $testroot/repo/xfile
153 68ed9ba5 2019-02-10 stsp chmod +x $testroot/repo/xfile
154 68ed9ba5 2019-02-10 stsp (cd $testroot/repo && git add .)
155 68ed9ba5 2019-02-10 stsp git_commit $testroot/repo -m "adding executable file"
156 08e5873e 2021-09-14 stsp local commit_id=`git_show_head $testroot/repo`
158 68ed9ba5 2019-02-10 stsp echo "A $testroot/wt/xfile" > $testroot/stdout.expected
159 08e5873e 2021-09-14 stsp echo "Checked out refs/heads/master: $commit_id" \
160 08e5873e 2021-09-14 stsp >> $testroot/stdout.expected
161 68ed9ba5 2019-02-10 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
163 68ed9ba5 2019-02-10 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
165 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
166 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
170 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
172 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
173 68ed9ba5 2019-02-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
174 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
178 68ed9ba5 2019-02-10 stsp ls -l $testroot/wt/xfile | grep -q '^-rwx'
180 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
181 68ed9ba5 2019-02-10 stsp echo "file is not executable" >&2
182 68ed9ba5 2019-02-10 stsp ls -l $testroot/wt/xfile >&2
184 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
187 f6cae3ed 2020-09-13 naddy test_checkout_commit_from_wrong_branch() {
188 45d344f6 2019-05-14 stsp local testroot=`test_init checkout_commit_from_wrong_branch`
190 45d344f6 2019-05-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
191 45d344f6 2019-05-14 stsp echo "modified alpha on new branch" > $testroot/repo/alpha
192 45d344f6 2019-05-14 stsp git_commit $testroot/repo -m "modified alpha on new branch"
194 45d344f6 2019-05-14 stsp local head_rev=`git_show_head $testroot/repo`
195 45d344f6 2019-05-14 stsp got checkout -b master -c $head_rev $testroot/repo $testroot/wt \
196 45d344f6 2019-05-14 stsp > $testroot/stdout 2> $testroot/stderr
198 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
199 45d344f6 2019-05-14 stsp test_done "$testroot" "1"
203 45d344f6 2019-05-14 stsp echo -n "" > $testroot/stdout.expected
204 45d344f6 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
206 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
207 45d344f6 2019-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
208 45d344f6 2019-05-14 stsp test_done "$testroot" "$ret"
212 4b6c9460 2020-03-05 stsp echo -n "got: target commit is not contained in branch 'master'; " \
213 45d344f6 2019-05-14 stsp > $testroot/stderr.expected
214 4b6c9460 2020-03-05 stsp echo -n "the branch to use must be specified with -b; if necessary " \
215 4b6c9460 2020-03-05 stsp >> $testroot/stderr.expected
216 4b6c9460 2020-03-05 stsp echo -n "a new branch can be created for this commit with "\
217 4b6c9460 2020-03-05 stsp >> $testroot/stderr.expected
218 4b6c9460 2020-03-05 stsp echo "'got branch -c $head_rev BRANCH_NAME'" \
219 4b6c9460 2020-03-05 stsp >> $testroot/stderr.expected
220 45d344f6 2019-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
222 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
223 45d344f6 2019-05-14 stsp diff -u $testroot/stderr.expected $testroot/stderr
224 45d344f6 2019-05-14 stsp test_done "$testroot" "$ret"
228 45d344f6 2019-05-14 stsp test_done "$testroot" "$ret"
231 f6cae3ed 2020-09-13 naddy test_checkout_tag() {
232 303e2782 2019-08-09 stsp local testroot=`test_init checkout_tag`
233 08e5873e 2021-09-14 stsp local commit_id=`git_show_head $testroot/repo`
234 303e2782 2019-08-09 stsp local tag="1.0.0"
236 303e2782 2019-08-09 stsp (cd $testroot/repo && git tag -a -m "test" $tag)
238 303e2782 2019-08-09 stsp echo "A $testroot/wt/alpha" > $testroot/stdout.expected
239 303e2782 2019-08-09 stsp echo "A $testroot/wt/beta" >> $testroot/stdout.expected
240 303e2782 2019-08-09 stsp echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
241 303e2782 2019-08-09 stsp echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
242 08e5873e 2021-09-14 stsp echo "Checked out refs/heads/master: $commit_id" \
243 08e5873e 2021-09-14 stsp >> $testroot/stdout.expected
244 303e2782 2019-08-09 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
246 303e2782 2019-08-09 stsp got checkout -c $tag $testroot/repo $testroot/wt > $testroot/stdout
248 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
249 303e2782 2019-08-09 stsp test_done "$testroot" "$ret"
253 303e2782 2019-08-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
255 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
256 303e2782 2019-08-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
257 303e2782 2019-08-09 stsp test_done "$testroot" "$ret"
261 303e2782 2019-08-09 stsp echo "alpha" > $testroot/content.expected
262 303e2782 2019-08-09 stsp echo "beta" >> $testroot/content.expected
263 303e2782 2019-08-09 stsp echo "zeta" >> $testroot/content.expected
264 303e2782 2019-08-09 stsp echo "delta" >> $testroot/content.expected
265 303e2782 2019-08-09 stsp cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
266 303e2782 2019-08-09 stsp $testroot/wt/gamma/delta > $testroot/content
268 303e2782 2019-08-09 stsp cmp -s $testroot/content.expected $testroot/content
270 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
271 303e2782 2019-08-09 stsp diff -u $testroot/content.expected $testroot/content
273 303e2782 2019-08-09 stsp test_done "$testroot" "$ret"
276 f6cae3ed 2020-09-13 naddy test_checkout_ignores_submodules() {
277 63c5ca5d 2019-08-24 stsp local testroot=`test_init checkout_ignores_submodules`
279 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
281 bf3ab206 2022-10-24 thomas (cd $testroot/repo && git -c protocol.file.allow=always \
282 bf3ab206 2022-10-24 thomas submodule -q add ../repo2)
283 63c5ca5d 2019-08-24 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
284 08e5873e 2021-09-14 stsp local commit_id=`git_show_head $testroot/repo`
286 63c5ca5d 2019-08-24 stsp echo "A $testroot/wt/.gitmodules" > $testroot/stdout.expected
287 63c5ca5d 2019-08-24 stsp echo "A $testroot/wt/alpha" >> $testroot/stdout.expected
288 63c5ca5d 2019-08-24 stsp echo "A $testroot/wt/beta" >> $testroot/stdout.expected
289 63c5ca5d 2019-08-24 stsp echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
290 63c5ca5d 2019-08-24 stsp echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
291 08e5873e 2021-09-14 stsp echo "Checked out refs/heads/master: $commit_id" \
292 08e5873e 2021-09-14 stsp >> $testroot/stdout.expected
293 63c5ca5d 2019-08-24 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
295 63c5ca5d 2019-08-24 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
297 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
298 63c5ca5d 2019-08-24 stsp test_done "$testroot" "$ret"
302 63c5ca5d 2019-08-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
304 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
305 63c5ca5d 2019-08-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
306 63c5ca5d 2019-08-24 stsp test_done "$testroot" "$ret"
310 63c5ca5d 2019-08-24 stsp echo "alpha" > $testroot/content.expected
311 63c5ca5d 2019-08-24 stsp echo "beta" >> $testroot/content.expected
312 63c5ca5d 2019-08-24 stsp echo "zeta" >> $testroot/content.expected
313 63c5ca5d 2019-08-24 stsp echo "delta" >> $testroot/content.expected
314 63c5ca5d 2019-08-24 stsp cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
315 63c5ca5d 2019-08-24 stsp $testroot/wt/gamma/delta > $testroot/content
317 63c5ca5d 2019-08-24 stsp cmp -s $testroot/content.expected $testroot/content
319 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
320 63c5ca5d 2019-08-24 stsp diff -u $testroot/content.expected $testroot/content
322 63c5ca5d 2019-08-24 stsp test_done "$testroot" "$ret"
325 f6cae3ed 2020-09-13 naddy test_checkout_read_only() {
326 7f47418f 2019-12-20 stsp local testroot=`test_init checkout_read_only`
327 08e5873e 2021-09-14 stsp local commit_id=`git_show_head $testroot/repo`
329 7f47418f 2019-12-20 stsp # Make the repostiory read-only
330 7f47418f 2019-12-20 stsp chmod -R a-w $testroot/repo
332 7f47418f 2019-12-20 stsp echo "A $testroot/wt/alpha" > $testroot/stdout.expected
333 7f47418f 2019-12-20 stsp echo "A $testroot/wt/beta" >> $testroot/stdout.expected
334 7f47418f 2019-12-20 stsp echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
335 7f47418f 2019-12-20 stsp echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
336 08e5873e 2021-09-14 stsp echo "Checked out refs/heads/master: $commit_id" \
337 08e5873e 2021-09-14 stsp >> $testroot/stdout.expected
338 7f47418f 2019-12-20 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
340 7f47418f 2019-12-20 stsp got checkout $testroot/repo $testroot/wt \
341 7f47418f 2019-12-20 stsp > $testroot/stdout 2> $testroot/stderr
343 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
344 7f47418f 2019-12-20 stsp test_done "$testroot" "$ret"
348 7f47418f 2019-12-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout
350 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
351 7f47418f 2019-12-20 stsp diff -u $testroot/stdout.expected $testroot/stdout
352 7f47418f 2019-12-20 stsp test_done "$testroot" "$ret"
356 7f47418f 2019-12-20 stsp echo -n "got: warning: could not create a reference " \
357 7f47418f 2019-12-20 stsp > $testroot/stderr.expected
358 7f47418f 2019-12-20 stsp echo -n "to the work tree's base commit; the commit could " \
359 7f47418f 2019-12-20 stsp >> $testroot/stderr.expected
360 e6786710 2021-07-03 stsp echo -n "be garbage-collected by Git or 'gotadmin cleanup'; " \
361 7f47418f 2019-12-20 stsp >> $testroot/stderr.expected
362 e6786710 2021-07-03 stsp echo -n "making the repository " >> $testroot/stderr.expected
363 7f47418f 2019-12-20 stsp echo "writable and running 'got update' will prevent this" \
364 7f47418f 2019-12-20 stsp >> $testroot/stderr.expected
365 7f47418f 2019-12-20 stsp cmp -s $testroot/stderr.expected $testroot/stderr
367 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
368 7f47418f 2019-12-20 stsp diff -u $testroot/stderr.expected $testroot/stderr
369 7f47418f 2019-12-20 stsp test_done "$testroot" "$ret"
373 7f47418f 2019-12-20 stsp echo "alpha" > $testroot/content.expected
374 7f47418f 2019-12-20 stsp echo "beta" >> $testroot/content.expected
375 7f47418f 2019-12-20 stsp echo "zeta" >> $testroot/content.expected
376 7f47418f 2019-12-20 stsp echo "delta" >> $testroot/content.expected
377 7f47418f 2019-12-20 stsp cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
378 7f47418f 2019-12-20 stsp $testroot/wt/gamma/delta > $testroot/content
380 7f47418f 2019-12-20 stsp cmp -s $testroot/content.expected $testroot/content
382 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
383 7f47418f 2019-12-20 stsp diff -u $testroot/content.expected $testroot/content
385 7f47418f 2019-12-20 stsp chmod -R u+w $testroot/repo # make repo cleanup work
386 7f47418f 2019-12-20 stsp test_done "$testroot" "$ret"
389 f6cae3ed 2020-09-13 naddy test_checkout_into_nonempty_dir() {
390 bb51a5b4 2020-01-13 stsp local testroot=`test_init checkout_into_nonempty_dir`
391 08e5873e 2021-09-14 stsp local commit_id=`git_show_head $testroot/repo`
393 bb51a5b4 2020-01-13 stsp mkdir -p $testroot/wt
394 bb51a5b4 2020-01-13 stsp make_test_tree $testroot/wt
396 bb51a5b4 2020-01-13 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout \
397 bb51a5b4 2020-01-13 stsp 2> $testroot/stderr
399 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
400 bb51a5b4 2020-01-13 stsp echo "checkout succeeded unexpectedly" >&2
401 bb51a5b4 2020-01-13 stsp test_done "$testroot" "1"
405 bb51a5b4 2020-01-13 stsp echo -n > $testroot/stdout.expected
406 bb51a5b4 2020-01-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
408 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
409 bb51a5b4 2020-01-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
410 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
414 bb51a5b4 2020-01-13 stsp echo "got: $testroot/wt: directory exists and is not empty" \
415 bb51a5b4 2020-01-13 stsp > $testroot/stderr.expected
416 bb51a5b4 2020-01-13 stsp cmp -s $testroot/stderr.expected $testroot/stderr
418 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
419 bb51a5b4 2020-01-13 stsp diff -u $testroot/stderr.expected $testroot/stderr
420 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
424 3b9f0f87 2020-07-23 stsp echo "? $testroot/wt/alpha" > $testroot/stdout.expected
425 3b9f0f87 2020-07-23 stsp echo "? $testroot/wt/beta" >> $testroot/stdout.expected
426 3b9f0f87 2020-07-23 stsp echo "? $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
427 3b9f0f87 2020-07-23 stsp echo "? $testroot/wt/gamma/delta" >> $testroot/stdout.expected
428 08e5873e 2021-09-14 stsp echo "Checked out refs/heads/master: $commit_id" \
429 08e5873e 2021-09-14 stsp >> $testroot/stdout.expected
430 bb51a5b4 2020-01-13 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
432 bb51a5b4 2020-01-13 stsp got checkout -E $testroot/repo $testroot/wt > $testroot/stdout
434 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
435 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
439 bb51a5b4 2020-01-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
441 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
442 bb51a5b4 2020-01-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
443 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
447 bb51a5b4 2020-01-13 stsp echo "E $testroot/wt/alpha" > $testroot/stdout.expected
448 bb51a5b4 2020-01-13 stsp echo "E $testroot/wt/beta" >> $testroot/stdout.expected
449 bb51a5b4 2020-01-13 stsp echo "E $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
450 bb51a5b4 2020-01-13 stsp echo "E $testroot/wt/gamma/delta" >> $testroot/stdout.expected
451 08e5873e 2021-09-14 stsp echo "Checked out refs/heads/master: $commit_id" \
452 08e5873e 2021-09-14 stsp >> $testroot/stdout.expected
453 bb51a5b4 2020-01-13 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
455 bb51a5b4 2020-01-13 stsp got checkout -E $testroot/repo $testroot/wt > $testroot/stdout
457 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
458 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
462 bb51a5b4 2020-01-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
464 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
465 bb51a5b4 2020-01-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
466 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
470 bb51a5b4 2020-01-13 stsp echo "alpha" > $testroot/content.expected
471 bb51a5b4 2020-01-13 stsp echo "beta" >> $testroot/content.expected
472 bb51a5b4 2020-01-13 stsp echo "zeta" >> $testroot/content.expected
473 bb51a5b4 2020-01-13 stsp echo "delta" >> $testroot/content.expected
474 bb51a5b4 2020-01-13 stsp cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
475 bb51a5b4 2020-01-13 stsp $testroot/wt/gamma/delta > $testroot/content
477 bb51a5b4 2020-01-13 stsp cmp -s $testroot/content.expected $testroot/content
479 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
480 bb51a5b4 2020-01-13 stsp diff -u $testroot/content.expected $testroot/content
481 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
485 bb51a5b4 2020-01-13 stsp echo "modified alpha" > $testroot/wt/alpha
487 bb51a5b4 2020-01-13 stsp echo "E $testroot/wt/alpha" > $testroot/stdout.expected
488 bb51a5b4 2020-01-13 stsp echo "E $testroot/wt/beta" >> $testroot/stdout.expected
489 bb51a5b4 2020-01-13 stsp echo "E $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
490 bb51a5b4 2020-01-13 stsp echo "E $testroot/wt/gamma/delta" >> $testroot/stdout.expected
491 08e5873e 2021-09-14 stsp echo "Checked out refs/heads/master: $commit_id" \
492 08e5873e 2021-09-14 stsp >> $testroot/stdout.expected
493 bb51a5b4 2020-01-13 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
495 bb51a5b4 2020-01-13 stsp got checkout -E $testroot/repo $testroot/wt > $testroot/stdout
497 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
498 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
502 bb51a5b4 2020-01-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
504 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
505 bb51a5b4 2020-01-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
506 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
510 bb51a5b4 2020-01-13 stsp echo "modified alpha" > $testroot/content.expected
511 bb51a5b4 2020-01-13 stsp echo "beta" >> $testroot/content.expected
512 bb51a5b4 2020-01-13 stsp echo "zeta" >> $testroot/content.expected
513 bb51a5b4 2020-01-13 stsp echo "delta" >> $testroot/content.expected
514 bb51a5b4 2020-01-13 stsp cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
515 bb51a5b4 2020-01-13 stsp $testroot/wt/gamma/delta > $testroot/content
517 bb51a5b4 2020-01-13 stsp cmp -s $testroot/content.expected $testroot/content
519 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
520 bb51a5b4 2020-01-13 stsp diff -u $testroot/content.expected $testroot/content
521 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
525 bb51a5b4 2020-01-13 stsp echo 'M alpha' > $testroot/stdout.expected
526 bb51a5b4 2020-01-13 stsp (cd $testroot/wt && got status > $testroot/stdout)
528 8ba819a3 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
530 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
531 8ba819a3 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
533 8ba819a3 2020-07-23 stsp test_done "$testroot" "$ret"
536 f6cae3ed 2020-09-13 naddy test_checkout_symlink() {
537 8ba819a3 2020-07-23 stsp local testroot=`test_init checkout_symlink`
539 8ba819a3 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
540 8ba819a3 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
541 8ba819a3 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
542 b7422a2f 2020-07-23 stsp (cd $testroot/repo && ln -s passwd.link passwd2.link)
543 0ab20ee9 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
544 0ab20ee9 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
545 906c123b 2020-07-23 stsp (cd $testroot/repo && ln -s .got/foo dotgotfoo.link)
546 8ba819a3 2020-07-23 stsp (cd $testroot/repo && git add .)
547 0ab20ee9 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
548 08e5873e 2021-09-14 stsp local commit_id=`git_show_head $testroot/repo`
550 b7422a2f 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
552 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
553 b7422a2f 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
554 8ba819a3 2020-07-23 stsp test_done "$testroot" "$ret"
558 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/alpha" > $testroot/stdout.expected
559 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/alpha.link" >> $testroot/stdout.expected
560 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/beta" >> $testroot/stdout.expected
561 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/dotgotfoo.link" >> $testroot/stdout.expected
562 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/epsilon/beta.link" >> $testroot/stdout.expected
563 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
564 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/epsilon.link" >> $testroot/stdout.expected
565 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
566 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/nonexistent.link" >> $testroot/stdout.expected
567 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/passwd.link" >> $testroot/stdout.expected
568 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/passwd2.link" >> $testroot/stdout.expected
569 08e5873e 2021-09-14 stsp echo "Checked out refs/heads/master: $commit_id" \
570 08e5873e 2021-09-14 stsp >> $testroot/stdout.expected
571 b7422a2f 2020-07-23 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
573 b7422a2f 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
575 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
576 b7422a2f 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
577 b7422a2f 2020-07-23 stsp test_done "$testroot" "$ret"
581 8ba819a3 2020-07-23 stsp if ! [ -h $testroot/wt/alpha.link ]; then
582 8ba819a3 2020-07-23 stsp echo "alpha.link is not a symlink"
583 8ba819a3 2020-07-23 stsp test_done "$testroot" "1"
587 8ba819a3 2020-07-23 stsp readlink $testroot/wt/alpha.link > $testroot/stdout
588 8ba819a3 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
589 8ba819a3 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
591 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
592 8ba819a3 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
593 8ba819a3 2020-07-23 stsp test_done "$testroot" "$ret"
597 8ba819a3 2020-07-23 stsp if ! [ -h $testroot/wt/epsilon.link ]; then
598 8ba819a3 2020-07-23 stsp echo "epsilon.link is not a symlink"
599 8ba819a3 2020-07-23 stsp test_done "$testroot" "1"
603 8ba819a3 2020-07-23 stsp readlink $testroot/wt/epsilon.link > $testroot/stdout
604 8ba819a3 2020-07-23 stsp echo "epsilon" > $testroot/stdout.expected
605 bb51a5b4 2020-01-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
607 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
608 bb51a5b4 2020-01-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
609 8ba819a3 2020-07-23 stsp test_done "$testroot" "$ret"
613 8ba819a3 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
614 8ba819a3 2020-07-23 stsp echo -n "passwd.link symlink points outside of work tree: " >&2
615 8ba819a3 2020-07-23 stsp readlink $testroot/wt/passwd.link >&2
616 8ba819a3 2020-07-23 stsp test_done "$testroot" "1"
620 8ba819a3 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
621 8ba819a3 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
623 8ba819a3 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
625 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
626 8ba819a3 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
627 0ab20ee9 2020-07-23 stsp test_done "$testroot" "$ret"
631 b7422a2f 2020-07-23 stsp if ! [ -h $testroot/wt/passwd2.link ]; then
632 b7422a2f 2020-07-23 stsp echo "passwd2.link is not a symlink"
633 b7422a2f 2020-07-23 stsp test_done "$testroot" "1"
637 b7422a2f 2020-07-23 stsp readlink $testroot/wt/passwd2.link > $testroot/stdout
638 b7422a2f 2020-07-23 stsp echo "passwd.link" > $testroot/stdout.expected
639 b7422a2f 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
641 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
642 b7422a2f 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
643 b7422a2f 2020-07-23 stsp test_done "$testroot" "$ret"
647 0ab20ee9 2020-07-23 stsp readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
648 0ab20ee9 2020-07-23 stsp echo "../beta" > $testroot/stdout.expected
649 0ab20ee9 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
651 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
652 0ab20ee9 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
653 0ab20ee9 2020-07-23 stsp test_done "$testroot" "$ret"
657 0ab20ee9 2020-07-23 stsp readlink $testroot/wt/nonexistent.link > $testroot/stdout
658 0ab20ee9 2020-07-23 stsp echo "nonexistent" > $testroot/stdout.expected
659 0ab20ee9 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
661 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
662 0ab20ee9 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
663 906c123b 2020-07-23 stsp test_done "$testroot" "$ret"
667 906c123b 2020-07-23 stsp if [ -h $testroot/wt/dotgotfoo.link ]; then
668 906c123b 2020-07-23 stsp echo -n "dotgotfoo.link symlink points into .got dir: " >&2
669 906c123b 2020-07-23 stsp readlink $testroot/wt/dotgotfoo.link >&2
670 906c123b 2020-07-23 stsp test_done "$testroot" "1"
674 906c123b 2020-07-23 stsp echo -n ".got/foo" > $testroot/content.expected
675 906c123b 2020-07-23 stsp cp $testroot/wt/dotgotfoo.link $testroot/content
677 906c123b 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
679 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
680 906c123b 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
682 0ab20ee9 2020-07-23 stsp test_done "$testroot" "$ret"
685 f6cae3ed 2020-09-13 naddy test_checkout_symlink_relative_wtpath() {
686 7d61d891 2020-07-23 stsp local testroot=`test_init checkout_symlink_with_wtpath`
688 7d61d891 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
689 7d61d891 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
690 7d61d891 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
691 7d61d891 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
692 7d61d891 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
693 7d61d891 2020-07-23 stsp (cd $testroot/repo && ln -s .got/foo dotgotfoo.link)
694 7d61d891 2020-07-23 stsp (cd $testroot/repo && git add .)
695 7d61d891 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
697 7d61d891 2020-07-23 stsp (cd $testroot && got checkout $testroot/repo wt > /dev/null)
699 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
700 7d61d891 2020-07-23 stsp test_done "$testroot" "$ret"
704 7d61d891 2020-07-23 stsp if ! [ -h $testroot/wt/alpha.link ]; then
705 7d61d891 2020-07-23 stsp echo "alpha.link is not a symlink"
706 7d61d891 2020-07-23 stsp test_done "$testroot" "1"
710 7d61d891 2020-07-23 stsp readlink $testroot/wt/alpha.link > $testroot/stdout
711 7d61d891 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
712 7d61d891 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
714 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
715 7d61d891 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
716 7d61d891 2020-07-23 stsp test_done "$testroot" "$ret"
720 7d61d891 2020-07-23 stsp if ! [ -h $testroot/wt/epsilon.link ]; then
721 7d61d891 2020-07-23 stsp echo "epsilon.link is not a symlink"
722 7d61d891 2020-07-23 stsp test_done "$testroot" "1"
726 7d61d891 2020-07-23 stsp readlink $testroot/wt/epsilon.link > $testroot/stdout
727 7d61d891 2020-07-23 stsp echo "epsilon" > $testroot/stdout.expected
728 7d61d891 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
730 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
731 7d61d891 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
732 7d61d891 2020-07-23 stsp test_done "$testroot" "$ret"
736 7d61d891 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
737 7d61d891 2020-07-23 stsp echo -n "passwd.link symlink points outside of work tree: " >&2
738 7d61d891 2020-07-23 stsp readlink $testroot/wt/passwd.link >&2
739 7d61d891 2020-07-23 stsp test_done "$testroot" "1"
743 7d61d891 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
744 7d61d891 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
746 7d61d891 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
748 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
749 7d61d891 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
750 7d61d891 2020-07-23 stsp test_done "$testroot" "$ret"
754 7d61d891 2020-07-23 stsp readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
755 7d61d891 2020-07-23 stsp echo "../beta" > $testroot/stdout.expected
756 7d61d891 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
758 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
759 7d61d891 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
760 7d61d891 2020-07-23 stsp test_done "$testroot" "$ret"
764 7d61d891 2020-07-23 stsp readlink $testroot/wt/nonexistent.link > $testroot/stdout
765 7d61d891 2020-07-23 stsp echo "nonexistent" > $testroot/stdout.expected
766 7d61d891 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
768 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
769 7d61d891 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
770 7d61d891 2020-07-23 stsp test_done "$testroot" "$ret"
774 7d61d891 2020-07-23 stsp if [ -h $testroot/wt/dotgotfoo.link ]; then
775 7d61d891 2020-07-23 stsp echo -n "dotgotfoo.link symlink points into .got dir: " >&2
776 7d61d891 2020-07-23 stsp readlink $testroot/wt/dotgotfoo.link >&2
777 7d61d891 2020-07-23 stsp test_done "$testroot" "1"
781 7d61d891 2020-07-23 stsp echo -n ".got/foo" > $testroot/content.expected
782 7d61d891 2020-07-23 stsp cp $testroot/wt/dotgotfoo.link $testroot/content
784 7d61d891 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
786 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
787 7d61d891 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
789 7d61d891 2020-07-23 stsp test_done "$testroot" "$ret"
792 20b7abb3 2020-10-22 stsp test_checkout_repo_with_unknown_extension() {
793 20b7abb3 2020-10-22 stsp local testroot=`test_init checkout_repo_with_unknown_extension`
795 20b7abb3 2020-10-22 stsp (cd $testroot/repo &&
796 b091c2cd 2023-02-07 thomas git config --add extensions.badExtension foobar)
797 20b7abb3 2020-10-22 stsp (cd $testroot/repo &&
798 20b7abb3 2020-10-22 stsp git config --add extensions.otherBadExtension 0)
800 20b7abb3 2020-10-22 stsp echo "got: badExtension: unsupported repository format extension" \
801 20b7abb3 2020-10-22 stsp > $testroot/stderr.expected
802 20b7abb3 2020-10-22 stsp got checkout $testroot/repo $testroot/wt \
803 20b7abb3 2020-10-22 stsp > $testroot/stdout 2> $testroot/stderr
806 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
807 20b7abb3 2020-10-22 stsp echo "got checkout command succeeded unexpectedly" >&2
808 20b7abb3 2020-10-22 stsp test_done "$testroot" "1"
812 20b7abb3 2020-10-22 stsp cmp -s $testroot/stderr.expected $testroot/stderr
814 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
815 20b7abb3 2020-10-22 stsp diff -u $testroot/stderr.expected $testroot/stderr
817 67c65ed7 2021-09-14 tracey test_done "$testroot" "$ret"
820 67c65ed7 2021-09-14 tracey test_checkout_quiet() {
821 67c65ed7 2021-09-14 tracey local testroot=`test_init checkout_quiet`
823 67c65ed7 2021-09-14 tracey echo -n "Checked out refs/heads/master: " >> $testroot/stdout.expected
824 67c65ed7 2021-09-14 tracey git_show_head $testroot/repo >> $testroot/stdout.expected
825 67d7451c 2021-09-15 naddy printf "\nNow shut up and hack\n" >> $testroot/stdout.expected
827 67c65ed7 2021-09-14 tracey got checkout -q $testroot/repo $testroot/wt > $testroot/stdout
829 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
830 67c65ed7 2021-09-14 tracey test_done "$testroot" "$ret"
834 67c65ed7 2021-09-14 tracey cmp -s $testroot/stdout.expected $testroot/stdout
836 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
837 67c65ed7 2021-09-14 tracey diff -u $testroot/stdout.expected $testroot/stdout
838 67c65ed7 2021-09-14 tracey test_done "$testroot" "$ret"
842 67c65ed7 2021-09-14 tracey echo "alpha" > $testroot/content.expected
843 67c65ed7 2021-09-14 tracey echo "beta" >> $testroot/content.expected
844 67c65ed7 2021-09-14 tracey echo "zeta" >> $testroot/content.expected
845 67c65ed7 2021-09-14 tracey echo "delta" >> $testroot/content.expected
846 67c65ed7 2021-09-14 tracey cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
847 67c65ed7 2021-09-14 tracey $testroot/wt/gamma/delta > $testroot/content
849 67c65ed7 2021-09-14 tracey cmp -s $testroot/content.expected $testroot/content
851 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
852 67c65ed7 2021-09-14 tracey diff -u $testroot/content.expected $testroot/content
854 20b7abb3 2020-10-22 stsp test_done "$testroot" "$ret"
857 a2c162eb 2022-10-30 thomas test_checkout_umask() {
858 a2c162eb 2022-10-30 thomas local testroot=`test_init checkout_umask`
860 a2c162eb 2022-10-30 thomas # using a subshell to avoid clobbering global umask
861 a2c162eb 2022-10-30 thomas (umask 044 && got checkout "$testroot/repo" "$testroot/wt") \
862 a2c162eb 2022-10-30 thomas >/dev/null
864 a2c162eb 2022-10-30 thomas if [ $ret -ne 0 ]; then
865 a2c162eb 2022-10-30 thomas test_done "$testroot" $ret
869 a2c162eb 2022-10-30 thomas for f in alpha beta epsilon/zeta gamma/delta; do
870 a2c162eb 2022-10-30 thomas ls -l "$testroot/wt/$f" | grep -q ^-rw-------
871 a2c162eb 2022-10-30 thomas if [ $? -ne 0 ]; then
872 a2c162eb 2022-10-30 thomas echo "$f is not 0600 after checkout" >&2
873 a2c162eb 2022-10-30 thomas ls -l "$testroot/wt/$f" >&2
874 a2c162eb 2022-10-30 thomas test_done "$testroot" 1
879 a2c162eb 2022-10-30 thomas for d in epsilon gamma; do
880 a2c162eb 2022-10-30 thomas ls -ld "$testroot/wt/$d" | grep -q ^drwx--x--x
881 a2c162eb 2022-10-30 thomas if [ $? -ne 0 ]; then
882 a2c162eb 2022-10-30 thomas echo "$d is not 711 after checkout" >&2
883 a2c162eb 2022-10-30 thomas ls -ld "$testroot/wt/$d" >&2
884 a2c162eb 2022-10-30 thomas test_done "$testroot" 1
889 a2c162eb 2022-10-30 thomas test_done "$testroot" 0
892 e0220e74 2022-10-31 thomas test_checkout_ulimit_n() {
893 e0220e74 2022-10-31 thomas local testroot=`test_init checkout_ulimit_n`
895 e0220e74 2022-10-31 thomas echo -n "Checked out refs/heads/master: " >> $testroot/stdout.expected
896 e0220e74 2022-10-31 thomas git_show_head $testroot/repo >> $testroot/stdout.expected
897 e0220e74 2022-10-31 thomas printf "\nNow shut up and hack\n" >> $testroot/stdout.expected
899 e0220e74 2022-10-31 thomas # Drastically reduce the number of files we are allowed to use.
900 e0220e74 2022-10-31 thomas # This tests our down-scaling of caches which store open file handles.
901 e0220e74 2022-10-31 thomas # Checkout should still work; if it does not, then either there is
902 e0220e74 2022-10-31 thomas # a bug or the fixed limit used by this test case is no longer valid
903 61d05f0f 2022-10-31 thomas # and must be raised. Use a subshell to avoid changing global ulimit.
904 4838433d 2023-01-28 thomas (ulimit -n 33; got checkout -q $testroot/repo $testroot/wt \
905 61d05f0f 2022-10-31 thomas > $testroot/stdout)
907 e0220e74 2022-10-31 thomas if [ $ret -ne 0 ]; then
908 e0220e74 2022-10-31 thomas test_done "$testroot" "$ret"
912 e0220e74 2022-10-31 thomas cmp -s $testroot/stdout.expected $testroot/stdout
914 e0220e74 2022-10-31 thomas if [ $ret -ne 0 ]; then
915 e0220e74 2022-10-31 thomas diff -u $testroot/stdout.expected $testroot/stdout
916 e0220e74 2022-10-31 thomas test_done "$testroot" "$ret"
920 e0220e74 2022-10-31 thomas echo "alpha" > $testroot/content.expected
921 e0220e74 2022-10-31 thomas echo "beta" >> $testroot/content.expected
922 e0220e74 2022-10-31 thomas echo "zeta" >> $testroot/content.expected
923 e0220e74 2022-10-31 thomas echo "delta" >> $testroot/content.expected
924 e0220e74 2022-10-31 thomas cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
925 e0220e74 2022-10-31 thomas $testroot/wt/gamma/delta > $testroot/content
927 e0220e74 2022-10-31 thomas cmp -s $testroot/content.expected $testroot/content
929 e0220e74 2022-10-31 thomas if [ $ret -ne 0 ]; then
930 e0220e74 2022-10-31 thomas diff -u $testroot/content.expected $testroot/content
932 fb885120 2023-07-19 thomas test_done "$testroot" "$ret"
935 fb885120 2023-07-19 thomas test_checkout_commit_keywords() {
936 fb885120 2023-07-19 thomas local testroot=$(test_init checkout_commit_keywords)
938 8642913b 2023-07-26 thomas set -- "$(git_show_head $testroot/repo)"
940 fb885120 2023-07-19 thomas got checkout $testroot/repo $testroot/wt > /dev/null
942 fb885120 2023-07-19 thomas if [ $ret -ne 0 ]; then
943 fb885120 2023-07-19 thomas echo "checkout failed unexpectedly" >&2
944 fb885120 2023-07-19 thomas test_done "$testroot" "$ret"
948 fb885120 2023-07-19 thomas for i in $(seq 4); do
949 fb885120 2023-07-19 thomas echo "zeta change $i" > "$testroot/wt/epsilon/zeta"
951 fb885120 2023-07-19 thomas (cd "$testroot/wt" && got ci -m "commit number $i" > /dev/null)
953 fb885120 2023-07-19 thomas if [ $ret -ne 0 ]; then
954 fb885120 2023-07-19 thomas echo "commit failed unexpectedly" >&2
955 fb885120 2023-07-19 thomas test_done "$testroot" "$ret"
958 8642913b 2023-07-26 thomas set -- "$@" "$(git_show_head $testroot/repo)"
961 fb885120 2023-07-19 thomas echo "A $testroot/wt2/alpha" > $testroot/stdout.expected
962 fb885120 2023-07-19 thomas echo "A $testroot/wt2/beta" >> $testroot/stdout.expected
963 fb885120 2023-07-19 thomas echo "A $testroot/wt2/epsilon/zeta" >> $testroot/stdout.expected
964 fb885120 2023-07-19 thomas echo "A $testroot/wt2/gamma/delta" >> $testroot/stdout.expected
965 8642913b 2023-07-26 thomas echo "Checked out refs/heads/master: $(pop_idx 4 $@)" \
966 fb885120 2023-07-19 thomas >> $testroot/stdout.expected
967 fb885120 2023-07-19 thomas echo "Now shut up and hack" >> $testroot/stdout.expected
969 fb885120 2023-07-19 thomas got co -c :head:- $testroot/repo $testroot/wt2 > $testroot/stdout
971 fb885120 2023-07-19 thomas if [ $ret -ne 0 ]; then
972 fb885120 2023-07-19 thomas test_done "$testroot" "$ret"
976 fb885120 2023-07-19 thomas cmp -s $testroot/stdout.expected $testroot/stdout
978 fb885120 2023-07-19 thomas if [ $ret -ne 0 ]; then
979 fb885120 2023-07-19 thomas diff -u $testroot/stdout.expected $testroot/stdout
980 fb885120 2023-07-19 thomas test_done "$testroot" "$ret"
984 fb885120 2023-07-19 thomas echo "A $testroot/wt3/alpha" > $testroot/stdout.expected
985 fb885120 2023-07-19 thomas echo "A $testroot/wt3/beta" >> $testroot/stdout.expected
986 fb885120 2023-07-19 thomas echo "A $testroot/wt3/epsilon/zeta" >> $testroot/stdout.expected
987 fb885120 2023-07-19 thomas echo "A $testroot/wt3/gamma/delta" >> $testroot/stdout.expected
988 8642913b 2023-07-26 thomas echo "Checked out refs/heads/master: $(pop_idx 4 $@)" \
989 fb885120 2023-07-19 thomas >> $testroot/stdout.expected
990 fb885120 2023-07-19 thomas echo "Now shut up and hack" >> $testroot/stdout.expected
992 fb885120 2023-07-19 thomas got co -bmaster -c:base:- $testroot/repo $testroot/wt3 > \
993 fb885120 2023-07-19 thomas $testroot/stdout
995 fb885120 2023-07-19 thomas if [ $ret -ne 0 ]; then
996 fb885120 2023-07-19 thomas test_done "$testroot" "$ret"
1000 fb885120 2023-07-19 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1002 fb885120 2023-07-19 thomas if [ $ret -ne 0 ]; then
1003 fb885120 2023-07-19 thomas diff -u $testroot/stdout.expected $testroot/stdout
1006 e0220e74 2022-10-31 thomas test_done "$testroot" "$ret"
1009 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1010 0e673013 2019-01-02 stsp run_test test_checkout_basic
1011 80c1b583 2019-08-07 stsp run_test test_checkout_dir_exists
1012 80c1b583 2019-08-07 stsp run_test test_checkout_dir_not_empty
1013 68ed9ba5 2019-02-10 stsp run_test test_checkout_sets_xbit
1014 45d344f6 2019-05-14 stsp run_test test_checkout_commit_from_wrong_branch
1015 303e2782 2019-08-09 stsp run_test test_checkout_tag
1016 63c5ca5d 2019-08-24 stsp run_test test_checkout_ignores_submodules
1017 7f47418f 2019-12-20 stsp run_test test_checkout_read_only
1018 bb51a5b4 2020-01-13 stsp run_test test_checkout_into_nonempty_dir
1019 8ba819a3 2020-07-23 stsp run_test test_checkout_symlink
1020 7d61d891 2020-07-23 stsp run_test test_checkout_symlink_relative_wtpath
1021 20b7abb3 2020-10-22 stsp run_test test_checkout_repo_with_unknown_extension
1022 67c65ed7 2021-09-14 tracey run_test test_checkout_quiet
1023 a2c162eb 2022-10-30 thomas run_test test_checkout_umask
1024 e0220e74 2022-10-31 thomas run_test test_checkout_ulimit_n
1025 fb885120 2023-07-19 thomas run_test test_checkout_commit_keywords