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 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy 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 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
143 80c1b583 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
145 692a4bb1 2023-08-28 stsp test_done "$testroot" "$ret"
149 692a4bb1 2023-08-28 stsp test_checkout_into_repo() {
150 692a4bb1 2023-08-28 stsp local testroot=`test_init checkout_into_repo`
151 692a4bb1 2023-08-28 stsp local commit_id=`git_show_head $testroot/repo`
153 692a4bb1 2023-08-28 stsp got checkout $testroot/repo $testroot/repo/wt \
154 692a4bb1 2023-08-28 stsp > $testroot/stdout 2> $testroot/stderr
156 692a4bb1 2023-08-28 stsp if [ $ret -eq 0 ]; then
157 692a4bb1 2023-08-28 stsp echo "checkout succeeded unexpectedly" >&2
158 692a4bb1 2023-08-28 stsp test_done "$testroot" "1"
162 692a4bb1 2023-08-28 stsp echo -n > $testroot/stdout.expected
164 692a4bb1 2023-08-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
166 692a4bb1 2023-08-28 stsp if [ $ret -ne 0 ]; then
167 692a4bb1 2023-08-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
168 692a4bb1 2023-08-28 stsp test_done "$testroot" "$ret"
172 692a4bb1 2023-08-28 stsp echo -n "got: work tree and repository paths may not overlap: " \
173 692a4bb1 2023-08-28 stsp > $testroot/stderr.expected
174 692a4bb1 2023-08-28 stsp echo "$testroot/repo/wt: bad path" >> $testroot/stderr.expected
175 692a4bb1 2023-08-28 stsp cmp -s $testroot/stderr.expected $testroot/stderr
177 692a4bb1 2023-08-28 stsp if [ $ret -ne 0 ]; then
178 692a4bb1 2023-08-28 stsp diff -u $testroot/stderr.expected $testroot/stderr
180 80c1b583 2019-08-07 stsp test_done "$testroot" "$ret"
183 692a4bb1 2023-08-28 stsp test_checkout_overlap_repo() {
184 692a4bb1 2023-08-28 stsp local testroot=`test_init checkout_into_repo`
185 692a4bb1 2023-08-28 stsp local commit_id=`git_show_head $testroot/repo`
187 692a4bb1 2023-08-28 stsp got checkout $testroot/repo $testroot \
188 692a4bb1 2023-08-28 stsp > $testroot/stdout 2> $testroot/stderr
190 692a4bb1 2023-08-28 stsp if [ $ret -eq 0 ]; then
191 692a4bb1 2023-08-28 stsp echo "checkout succeeded unexpectedly" >&2
192 692a4bb1 2023-08-28 stsp test_done "$testroot" "1"
196 692a4bb1 2023-08-28 stsp echo -n > $testroot/stdout.expected
198 692a4bb1 2023-08-28 stsp cmp -s $testroot/stdout.expected $testroot/stdout
200 692a4bb1 2023-08-28 stsp if [ $ret -ne 0 ]; then
201 692a4bb1 2023-08-28 stsp diff -u $testroot/stdout.expected $testroot/stdout
202 692a4bb1 2023-08-28 stsp test_done "$testroot" "$ret"
206 692a4bb1 2023-08-28 stsp echo -n "got: work tree and repository paths may not overlap: " \
207 692a4bb1 2023-08-28 stsp > $testroot/stderr.expected
208 692a4bb1 2023-08-28 stsp echo "$testroot: bad path" >> $testroot/stderr.expected
209 692a4bb1 2023-08-28 stsp cmp -s $testroot/stderr.expected $testroot/stderr
211 692a4bb1 2023-08-28 stsp if [ $ret -ne 0 ]; then
212 692a4bb1 2023-08-28 stsp diff -u $testroot/stderr.expected $testroot/stderr
214 692a4bb1 2023-08-28 stsp test_done "$testroot" "$ret"
217 f6cae3ed 2020-09-13 naddy test_checkout_sets_xbit() {
218 68ed9ba5 2019-02-10 stsp local testroot=`test_init checkout_sets_xbit 1`
220 68ed9ba5 2019-02-10 stsp touch $testroot/repo/xfile
221 68ed9ba5 2019-02-10 stsp chmod +x $testroot/repo/xfile
222 68ed9ba5 2019-02-10 stsp (cd $testroot/repo && git add .)
223 68ed9ba5 2019-02-10 stsp git_commit $testroot/repo -m "adding executable file"
224 08e5873e 2021-09-14 stsp local commit_id=`git_show_head $testroot/repo`
226 68ed9ba5 2019-02-10 stsp echo "A $testroot/wt/xfile" > $testroot/stdout.expected
227 08e5873e 2021-09-14 stsp echo "Checked out refs/heads/master: $commit_id" \
228 08e5873e 2021-09-14 stsp >> $testroot/stdout.expected
229 68ed9ba5 2019-02-10 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
231 68ed9ba5 2019-02-10 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
233 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
234 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
238 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
240 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
241 68ed9ba5 2019-02-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
242 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
246 68ed9ba5 2019-02-10 stsp ls -l $testroot/wt/xfile | grep -q '^-rwx'
248 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
249 68ed9ba5 2019-02-10 stsp echo "file is not executable" >&2
250 68ed9ba5 2019-02-10 stsp ls -l $testroot/wt/xfile >&2
252 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
255 f6cae3ed 2020-09-13 naddy test_checkout_commit_from_wrong_branch() {
256 45d344f6 2019-05-14 stsp local testroot=`test_init checkout_commit_from_wrong_branch`
258 45d344f6 2019-05-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
259 45d344f6 2019-05-14 stsp echo "modified alpha on new branch" > $testroot/repo/alpha
260 45d344f6 2019-05-14 stsp git_commit $testroot/repo -m "modified alpha on new branch"
262 45d344f6 2019-05-14 stsp local head_rev=`git_show_head $testroot/repo`
263 45d344f6 2019-05-14 stsp got checkout -b master -c $head_rev $testroot/repo $testroot/wt \
264 45d344f6 2019-05-14 stsp > $testroot/stdout 2> $testroot/stderr
266 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
267 45d344f6 2019-05-14 stsp test_done "$testroot" "1"
271 45d344f6 2019-05-14 stsp echo -n "" > $testroot/stdout.expected
272 45d344f6 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
274 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
275 45d344f6 2019-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
276 45d344f6 2019-05-14 stsp test_done "$testroot" "$ret"
280 4b6c9460 2020-03-05 stsp echo -n "got: target commit is not contained in branch 'master'; " \
281 45d344f6 2019-05-14 stsp > $testroot/stderr.expected
282 4b6c9460 2020-03-05 stsp echo -n "the branch to use must be specified with -b; if necessary " \
283 4b6c9460 2020-03-05 stsp >> $testroot/stderr.expected
284 4b6c9460 2020-03-05 stsp echo -n "a new branch can be created for this commit with "\
285 4b6c9460 2020-03-05 stsp >> $testroot/stderr.expected
286 4b6c9460 2020-03-05 stsp echo "'got branch -c $head_rev BRANCH_NAME'" \
287 4b6c9460 2020-03-05 stsp >> $testroot/stderr.expected
288 45d344f6 2019-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
290 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
291 45d344f6 2019-05-14 stsp diff -u $testroot/stderr.expected $testroot/stderr
292 45d344f6 2019-05-14 stsp test_done "$testroot" "$ret"
296 45d344f6 2019-05-14 stsp test_done "$testroot" "$ret"
299 f6cae3ed 2020-09-13 naddy test_checkout_tag() {
300 303e2782 2019-08-09 stsp local testroot=`test_init checkout_tag`
301 08e5873e 2021-09-14 stsp local commit_id=`git_show_head $testroot/repo`
302 303e2782 2019-08-09 stsp local tag="1.0.0"
304 303e2782 2019-08-09 stsp (cd $testroot/repo && git tag -a -m "test" $tag)
306 303e2782 2019-08-09 stsp echo "A $testroot/wt/alpha" > $testroot/stdout.expected
307 303e2782 2019-08-09 stsp echo "A $testroot/wt/beta" >> $testroot/stdout.expected
308 303e2782 2019-08-09 stsp echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
309 303e2782 2019-08-09 stsp echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
310 08e5873e 2021-09-14 stsp echo "Checked out refs/heads/master: $commit_id" \
311 08e5873e 2021-09-14 stsp >> $testroot/stdout.expected
312 303e2782 2019-08-09 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
314 303e2782 2019-08-09 stsp got checkout -c $tag $testroot/repo $testroot/wt > $testroot/stdout
316 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
317 303e2782 2019-08-09 stsp test_done "$testroot" "$ret"
321 303e2782 2019-08-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
323 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
324 303e2782 2019-08-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
325 303e2782 2019-08-09 stsp test_done "$testroot" "$ret"
329 303e2782 2019-08-09 stsp echo "alpha" > $testroot/content.expected
330 303e2782 2019-08-09 stsp echo "beta" >> $testroot/content.expected
331 303e2782 2019-08-09 stsp echo "zeta" >> $testroot/content.expected
332 303e2782 2019-08-09 stsp echo "delta" >> $testroot/content.expected
333 303e2782 2019-08-09 stsp cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
334 303e2782 2019-08-09 stsp $testroot/wt/gamma/delta > $testroot/content
336 303e2782 2019-08-09 stsp cmp -s $testroot/content.expected $testroot/content
338 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
339 303e2782 2019-08-09 stsp diff -u $testroot/content.expected $testroot/content
341 303e2782 2019-08-09 stsp test_done "$testroot" "$ret"
344 f6cae3ed 2020-09-13 naddy test_checkout_ignores_submodules() {
345 63c5ca5d 2019-08-24 stsp local testroot=`test_init checkout_ignores_submodules`
347 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
349 f1aec6ed 2022-10-24 stsp (cd $testroot/repo && git -c protocol.file.allow=always \
350 f1aec6ed 2022-10-24 stsp submodule -q add ../repo2)
351 63c5ca5d 2019-08-24 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
352 08e5873e 2021-09-14 stsp local commit_id=`git_show_head $testroot/repo`
354 63c5ca5d 2019-08-24 stsp echo "A $testroot/wt/.gitmodules" > $testroot/stdout.expected
355 63c5ca5d 2019-08-24 stsp echo "A $testroot/wt/alpha" >> $testroot/stdout.expected
356 63c5ca5d 2019-08-24 stsp echo "A $testroot/wt/beta" >> $testroot/stdout.expected
357 63c5ca5d 2019-08-24 stsp echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
358 63c5ca5d 2019-08-24 stsp echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
359 08e5873e 2021-09-14 stsp echo "Checked out refs/heads/master: $commit_id" \
360 08e5873e 2021-09-14 stsp >> $testroot/stdout.expected
361 63c5ca5d 2019-08-24 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
363 63c5ca5d 2019-08-24 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
365 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
366 63c5ca5d 2019-08-24 stsp test_done "$testroot" "$ret"
370 63c5ca5d 2019-08-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
372 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
373 63c5ca5d 2019-08-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
374 63c5ca5d 2019-08-24 stsp test_done "$testroot" "$ret"
378 63c5ca5d 2019-08-24 stsp echo "alpha" > $testroot/content.expected
379 63c5ca5d 2019-08-24 stsp echo "beta" >> $testroot/content.expected
380 63c5ca5d 2019-08-24 stsp echo "zeta" >> $testroot/content.expected
381 63c5ca5d 2019-08-24 stsp echo "delta" >> $testroot/content.expected
382 63c5ca5d 2019-08-24 stsp cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
383 63c5ca5d 2019-08-24 stsp $testroot/wt/gamma/delta > $testroot/content
385 63c5ca5d 2019-08-24 stsp cmp -s $testroot/content.expected $testroot/content
387 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
388 63c5ca5d 2019-08-24 stsp diff -u $testroot/content.expected $testroot/content
390 63c5ca5d 2019-08-24 stsp test_done "$testroot" "$ret"
393 f6cae3ed 2020-09-13 naddy test_checkout_read_only() {
394 7f47418f 2019-12-20 stsp local testroot=`test_init checkout_read_only`
395 08e5873e 2021-09-14 stsp local commit_id=`git_show_head $testroot/repo`
397 7f47418f 2019-12-20 stsp # Make the repostiory read-only
398 7f47418f 2019-12-20 stsp chmod -R a-w $testroot/repo
400 7f47418f 2019-12-20 stsp echo "A $testroot/wt/alpha" > $testroot/stdout.expected
401 7f47418f 2019-12-20 stsp echo "A $testroot/wt/beta" >> $testroot/stdout.expected
402 7f47418f 2019-12-20 stsp echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
403 7f47418f 2019-12-20 stsp echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
404 08e5873e 2021-09-14 stsp echo "Checked out refs/heads/master: $commit_id" \
405 08e5873e 2021-09-14 stsp >> $testroot/stdout.expected
406 7f47418f 2019-12-20 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
408 7f47418f 2019-12-20 stsp got checkout $testroot/repo $testroot/wt \
409 7f47418f 2019-12-20 stsp > $testroot/stdout 2> $testroot/stderr
411 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
412 7f47418f 2019-12-20 stsp test_done "$testroot" "$ret"
416 7f47418f 2019-12-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout
418 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
419 7f47418f 2019-12-20 stsp diff -u $testroot/stdout.expected $testroot/stdout
420 7f47418f 2019-12-20 stsp test_done "$testroot" "$ret"
424 7f47418f 2019-12-20 stsp echo -n "got: warning: could not create a reference " \
425 7f47418f 2019-12-20 stsp > $testroot/stderr.expected
426 7f47418f 2019-12-20 stsp echo -n "to the work tree's base commit; the commit could " \
427 7f47418f 2019-12-20 stsp >> $testroot/stderr.expected
428 e6786710 2021-07-03 stsp echo -n "be garbage-collected by Git or 'gotadmin cleanup'; " \
429 7f47418f 2019-12-20 stsp >> $testroot/stderr.expected
430 e6786710 2021-07-03 stsp echo -n "making the repository " >> $testroot/stderr.expected
431 7f47418f 2019-12-20 stsp echo "writable and running 'got update' will prevent this" \
432 7f47418f 2019-12-20 stsp >> $testroot/stderr.expected
433 7f47418f 2019-12-20 stsp cmp -s $testroot/stderr.expected $testroot/stderr
435 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
436 7f47418f 2019-12-20 stsp diff -u $testroot/stderr.expected $testroot/stderr
437 7f47418f 2019-12-20 stsp test_done "$testroot" "$ret"
441 7f47418f 2019-12-20 stsp echo "alpha" > $testroot/content.expected
442 7f47418f 2019-12-20 stsp echo "beta" >> $testroot/content.expected
443 7f47418f 2019-12-20 stsp echo "zeta" >> $testroot/content.expected
444 7f47418f 2019-12-20 stsp echo "delta" >> $testroot/content.expected
445 7f47418f 2019-12-20 stsp cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
446 7f47418f 2019-12-20 stsp $testroot/wt/gamma/delta > $testroot/content
448 7f47418f 2019-12-20 stsp cmp -s $testroot/content.expected $testroot/content
450 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
451 7f47418f 2019-12-20 stsp diff -u $testroot/content.expected $testroot/content
453 7f47418f 2019-12-20 stsp chmod -R u+w $testroot/repo # make repo cleanup work
454 7f47418f 2019-12-20 stsp test_done "$testroot" "$ret"
457 f6cae3ed 2020-09-13 naddy test_checkout_into_nonempty_dir() {
458 bb51a5b4 2020-01-13 stsp local testroot=`test_init checkout_into_nonempty_dir`
459 08e5873e 2021-09-14 stsp local commit_id=`git_show_head $testroot/repo`
461 bb51a5b4 2020-01-13 stsp mkdir -p $testroot/wt
462 bb51a5b4 2020-01-13 stsp make_test_tree $testroot/wt
464 bb51a5b4 2020-01-13 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout \
465 bb51a5b4 2020-01-13 stsp 2> $testroot/stderr
467 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
468 bb51a5b4 2020-01-13 stsp echo "checkout succeeded unexpectedly" >&2
469 bb51a5b4 2020-01-13 stsp test_done "$testroot" "1"
473 bb51a5b4 2020-01-13 stsp echo -n > $testroot/stdout.expected
474 bb51a5b4 2020-01-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
476 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
477 bb51a5b4 2020-01-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
478 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
482 bb51a5b4 2020-01-13 stsp echo "got: $testroot/wt: directory exists and is not empty" \
483 bb51a5b4 2020-01-13 stsp > $testroot/stderr.expected
484 bb51a5b4 2020-01-13 stsp cmp -s $testroot/stderr.expected $testroot/stderr
486 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
487 bb51a5b4 2020-01-13 stsp diff -u $testroot/stderr.expected $testroot/stderr
488 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
492 3b9f0f87 2020-07-23 stsp echo "? $testroot/wt/alpha" > $testroot/stdout.expected
493 3b9f0f87 2020-07-23 stsp echo "? $testroot/wt/beta" >> $testroot/stdout.expected
494 3b9f0f87 2020-07-23 stsp echo "? $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
495 3b9f0f87 2020-07-23 stsp echo "? $testroot/wt/gamma/delta" >> $testroot/stdout.expected
496 08e5873e 2021-09-14 stsp echo "Checked out refs/heads/master: $commit_id" \
497 08e5873e 2021-09-14 stsp >> $testroot/stdout.expected
498 bb51a5b4 2020-01-13 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
500 bb51a5b4 2020-01-13 stsp got checkout -E $testroot/repo $testroot/wt > $testroot/stdout
502 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
503 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
507 bb51a5b4 2020-01-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
509 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
510 bb51a5b4 2020-01-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
511 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
515 bb51a5b4 2020-01-13 stsp echo "E $testroot/wt/alpha" > $testroot/stdout.expected
516 bb51a5b4 2020-01-13 stsp echo "E $testroot/wt/beta" >> $testroot/stdout.expected
517 bb51a5b4 2020-01-13 stsp echo "E $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
518 bb51a5b4 2020-01-13 stsp echo "E $testroot/wt/gamma/delta" >> $testroot/stdout.expected
519 08e5873e 2021-09-14 stsp echo "Checked out refs/heads/master: $commit_id" \
520 08e5873e 2021-09-14 stsp >> $testroot/stdout.expected
521 bb51a5b4 2020-01-13 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
523 bb51a5b4 2020-01-13 stsp got checkout -E $testroot/repo $testroot/wt > $testroot/stdout
525 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
526 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
530 bb51a5b4 2020-01-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
532 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
533 bb51a5b4 2020-01-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
534 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
538 bb51a5b4 2020-01-13 stsp echo "alpha" > $testroot/content.expected
539 bb51a5b4 2020-01-13 stsp echo "beta" >> $testroot/content.expected
540 bb51a5b4 2020-01-13 stsp echo "zeta" >> $testroot/content.expected
541 bb51a5b4 2020-01-13 stsp echo "delta" >> $testroot/content.expected
542 bb51a5b4 2020-01-13 stsp cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
543 bb51a5b4 2020-01-13 stsp $testroot/wt/gamma/delta > $testroot/content
545 bb51a5b4 2020-01-13 stsp cmp -s $testroot/content.expected $testroot/content
547 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
548 bb51a5b4 2020-01-13 stsp diff -u $testroot/content.expected $testroot/content
549 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
553 bb51a5b4 2020-01-13 stsp echo "modified alpha" > $testroot/wt/alpha
555 bb51a5b4 2020-01-13 stsp echo "E $testroot/wt/alpha" > $testroot/stdout.expected
556 bb51a5b4 2020-01-13 stsp echo "E $testroot/wt/beta" >> $testroot/stdout.expected
557 bb51a5b4 2020-01-13 stsp echo "E $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
558 bb51a5b4 2020-01-13 stsp echo "E $testroot/wt/gamma/delta" >> $testroot/stdout.expected
559 08e5873e 2021-09-14 stsp echo "Checked out refs/heads/master: $commit_id" \
560 08e5873e 2021-09-14 stsp >> $testroot/stdout.expected
561 bb51a5b4 2020-01-13 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
563 bb51a5b4 2020-01-13 stsp got checkout -E $testroot/repo $testroot/wt > $testroot/stdout
565 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
566 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
570 bb51a5b4 2020-01-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
572 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
573 bb51a5b4 2020-01-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
574 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
578 bb51a5b4 2020-01-13 stsp echo "modified alpha" > $testroot/content.expected
579 bb51a5b4 2020-01-13 stsp echo "beta" >> $testroot/content.expected
580 bb51a5b4 2020-01-13 stsp echo "zeta" >> $testroot/content.expected
581 bb51a5b4 2020-01-13 stsp echo "delta" >> $testroot/content.expected
582 bb51a5b4 2020-01-13 stsp cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
583 bb51a5b4 2020-01-13 stsp $testroot/wt/gamma/delta > $testroot/content
585 bb51a5b4 2020-01-13 stsp cmp -s $testroot/content.expected $testroot/content
587 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
588 bb51a5b4 2020-01-13 stsp diff -u $testroot/content.expected $testroot/content
589 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
593 bb51a5b4 2020-01-13 stsp echo 'M alpha' > $testroot/stdout.expected
594 bb51a5b4 2020-01-13 stsp (cd $testroot/wt && got status > $testroot/stdout)
596 8ba819a3 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
598 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
599 8ba819a3 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
601 8ba819a3 2020-07-23 stsp test_done "$testroot" "$ret"
604 f6cae3ed 2020-09-13 naddy test_checkout_symlink() {
605 8ba819a3 2020-07-23 stsp local testroot=`test_init checkout_symlink`
607 8ba819a3 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
608 8ba819a3 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
609 8ba819a3 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
610 b7422a2f 2020-07-23 stsp (cd $testroot/repo && ln -s passwd.link passwd2.link)
611 0ab20ee9 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
612 0ab20ee9 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
613 906c123b 2020-07-23 stsp (cd $testroot/repo && ln -s .got/foo dotgotfoo.link)
614 8ba819a3 2020-07-23 stsp (cd $testroot/repo && git add .)
615 0ab20ee9 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
616 08e5873e 2021-09-14 stsp local commit_id=`git_show_head $testroot/repo`
618 b7422a2f 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
620 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
621 b7422a2f 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
622 8ba819a3 2020-07-23 stsp test_done "$testroot" "$ret"
626 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/alpha" > $testroot/stdout.expected
627 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/alpha.link" >> $testroot/stdout.expected
628 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/beta" >> $testroot/stdout.expected
629 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/dotgotfoo.link" >> $testroot/stdout.expected
630 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/epsilon/beta.link" >> $testroot/stdout.expected
631 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
632 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/epsilon.link" >> $testroot/stdout.expected
633 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
634 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/nonexistent.link" >> $testroot/stdout.expected
635 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/passwd.link" >> $testroot/stdout.expected
636 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/passwd2.link" >> $testroot/stdout.expected
637 08e5873e 2021-09-14 stsp echo "Checked out refs/heads/master: $commit_id" \
638 08e5873e 2021-09-14 stsp >> $testroot/stdout.expected
639 b7422a2f 2020-07-23 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
641 b7422a2f 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
643 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
644 b7422a2f 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
645 b7422a2f 2020-07-23 stsp test_done "$testroot" "$ret"
649 8ba819a3 2020-07-23 stsp if ! [ -h $testroot/wt/alpha.link ]; then
650 8ba819a3 2020-07-23 stsp echo "alpha.link is not a symlink"
651 8ba819a3 2020-07-23 stsp test_done "$testroot" "1"
655 8ba819a3 2020-07-23 stsp readlink $testroot/wt/alpha.link > $testroot/stdout
656 8ba819a3 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
657 8ba819a3 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
659 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
660 8ba819a3 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
661 8ba819a3 2020-07-23 stsp test_done "$testroot" "$ret"
665 8ba819a3 2020-07-23 stsp if ! [ -h $testroot/wt/epsilon.link ]; then
666 8ba819a3 2020-07-23 stsp echo "epsilon.link is not a symlink"
667 8ba819a3 2020-07-23 stsp test_done "$testroot" "1"
671 8ba819a3 2020-07-23 stsp readlink $testroot/wt/epsilon.link > $testroot/stdout
672 8ba819a3 2020-07-23 stsp echo "epsilon" > $testroot/stdout.expected
673 bb51a5b4 2020-01-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
675 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
676 bb51a5b4 2020-01-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
677 8ba819a3 2020-07-23 stsp test_done "$testroot" "$ret"
681 8ba819a3 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
682 8ba819a3 2020-07-23 stsp echo -n "passwd.link symlink points outside of work tree: " >&2
683 8ba819a3 2020-07-23 stsp readlink $testroot/wt/passwd.link >&2
684 8ba819a3 2020-07-23 stsp test_done "$testroot" "1"
688 8ba819a3 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
689 8ba819a3 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
691 8ba819a3 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
693 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
694 8ba819a3 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
695 0ab20ee9 2020-07-23 stsp test_done "$testroot" "$ret"
699 b7422a2f 2020-07-23 stsp if ! [ -h $testroot/wt/passwd2.link ]; then
700 b7422a2f 2020-07-23 stsp echo "passwd2.link is not a symlink"
701 b7422a2f 2020-07-23 stsp test_done "$testroot" "1"
705 b7422a2f 2020-07-23 stsp readlink $testroot/wt/passwd2.link > $testroot/stdout
706 b7422a2f 2020-07-23 stsp echo "passwd.link" > $testroot/stdout.expected
707 b7422a2f 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
709 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
710 b7422a2f 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
711 b7422a2f 2020-07-23 stsp test_done "$testroot" "$ret"
715 0ab20ee9 2020-07-23 stsp readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
716 0ab20ee9 2020-07-23 stsp echo "../beta" > $testroot/stdout.expected
717 0ab20ee9 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
719 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
720 0ab20ee9 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
721 0ab20ee9 2020-07-23 stsp test_done "$testroot" "$ret"
725 0ab20ee9 2020-07-23 stsp readlink $testroot/wt/nonexistent.link > $testroot/stdout
726 0ab20ee9 2020-07-23 stsp echo "nonexistent" > $testroot/stdout.expected
727 0ab20ee9 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
729 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
730 0ab20ee9 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
731 906c123b 2020-07-23 stsp test_done "$testroot" "$ret"
735 906c123b 2020-07-23 stsp if [ -h $testroot/wt/dotgotfoo.link ]; then
736 906c123b 2020-07-23 stsp echo -n "dotgotfoo.link symlink points into .got dir: " >&2
737 906c123b 2020-07-23 stsp readlink $testroot/wt/dotgotfoo.link >&2
738 906c123b 2020-07-23 stsp test_done "$testroot" "1"
742 906c123b 2020-07-23 stsp echo -n ".got/foo" > $testroot/content.expected
743 906c123b 2020-07-23 stsp cp $testroot/wt/dotgotfoo.link $testroot/content
745 906c123b 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
747 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
748 906c123b 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
750 0ab20ee9 2020-07-23 stsp test_done "$testroot" "$ret"
753 f6cae3ed 2020-09-13 naddy test_checkout_symlink_relative_wtpath() {
754 7d61d891 2020-07-23 stsp local testroot=`test_init checkout_symlink_with_wtpath`
756 7d61d891 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
757 7d61d891 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
758 7d61d891 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
759 7d61d891 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
760 7d61d891 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
761 7d61d891 2020-07-23 stsp (cd $testroot/repo && ln -s .got/foo dotgotfoo.link)
762 7d61d891 2020-07-23 stsp (cd $testroot/repo && git add .)
763 7d61d891 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
765 7d61d891 2020-07-23 stsp (cd $testroot && got checkout $testroot/repo wt > /dev/null)
767 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
768 7d61d891 2020-07-23 stsp test_done "$testroot" "$ret"
772 7d61d891 2020-07-23 stsp if ! [ -h $testroot/wt/alpha.link ]; then
773 7d61d891 2020-07-23 stsp echo "alpha.link is not a symlink"
774 7d61d891 2020-07-23 stsp test_done "$testroot" "1"
778 7d61d891 2020-07-23 stsp readlink $testroot/wt/alpha.link > $testroot/stdout
779 7d61d891 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
780 7d61d891 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
782 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
783 7d61d891 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
784 7d61d891 2020-07-23 stsp test_done "$testroot" "$ret"
788 7d61d891 2020-07-23 stsp if ! [ -h $testroot/wt/epsilon.link ]; then
789 7d61d891 2020-07-23 stsp echo "epsilon.link is not a symlink"
790 7d61d891 2020-07-23 stsp test_done "$testroot" "1"
794 7d61d891 2020-07-23 stsp readlink $testroot/wt/epsilon.link > $testroot/stdout
795 7d61d891 2020-07-23 stsp echo "epsilon" > $testroot/stdout.expected
796 7d61d891 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
798 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
799 7d61d891 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
800 7d61d891 2020-07-23 stsp test_done "$testroot" "$ret"
804 7d61d891 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
805 7d61d891 2020-07-23 stsp echo -n "passwd.link symlink points outside of work tree: " >&2
806 7d61d891 2020-07-23 stsp readlink $testroot/wt/passwd.link >&2
807 7d61d891 2020-07-23 stsp test_done "$testroot" "1"
811 7d61d891 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
812 7d61d891 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
814 7d61d891 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
816 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
817 7d61d891 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
818 7d61d891 2020-07-23 stsp test_done "$testroot" "$ret"
822 7d61d891 2020-07-23 stsp readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
823 7d61d891 2020-07-23 stsp echo "../beta" > $testroot/stdout.expected
824 7d61d891 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
826 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
827 7d61d891 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
828 7d61d891 2020-07-23 stsp test_done "$testroot" "$ret"
832 7d61d891 2020-07-23 stsp readlink $testroot/wt/nonexistent.link > $testroot/stdout
833 7d61d891 2020-07-23 stsp echo "nonexistent" > $testroot/stdout.expected
834 7d61d891 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
836 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
837 7d61d891 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
838 7d61d891 2020-07-23 stsp test_done "$testroot" "$ret"
842 7d61d891 2020-07-23 stsp if [ -h $testroot/wt/dotgotfoo.link ]; then
843 7d61d891 2020-07-23 stsp echo -n "dotgotfoo.link symlink points into .got dir: " >&2
844 7d61d891 2020-07-23 stsp readlink $testroot/wt/dotgotfoo.link >&2
845 7d61d891 2020-07-23 stsp test_done "$testroot" "1"
849 7d61d891 2020-07-23 stsp echo -n ".got/foo" > $testroot/content.expected
850 7d61d891 2020-07-23 stsp cp $testroot/wt/dotgotfoo.link $testroot/content
852 7d61d891 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
854 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
855 7d61d891 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
857 7d61d891 2020-07-23 stsp test_done "$testroot" "$ret"
860 20b7abb3 2020-10-22 stsp test_checkout_repo_with_unknown_extension() {
861 20b7abb3 2020-10-22 stsp local testroot=`test_init checkout_repo_with_unknown_extension`
863 20b7abb3 2020-10-22 stsp (cd $testroot/repo &&
864 27749ea2 2023-02-05 op git config --add extensions.badExtension foobar)
865 20b7abb3 2020-10-22 stsp (cd $testroot/repo &&
866 20b7abb3 2020-10-22 stsp git config --add extensions.otherBadExtension 0)
868 20b7abb3 2020-10-22 stsp echo "got: badExtension: unsupported repository format extension" \
869 20b7abb3 2020-10-22 stsp > $testroot/stderr.expected
870 20b7abb3 2020-10-22 stsp got checkout $testroot/repo $testroot/wt \
871 20b7abb3 2020-10-22 stsp > $testroot/stdout 2> $testroot/stderr
874 49c543a6 2022-03-31 naddy if [ $ret -eq 0 ]; then
875 20b7abb3 2020-10-22 stsp echo "got checkout command succeeded unexpectedly" >&2
876 20b7abb3 2020-10-22 stsp test_done "$testroot" "1"
880 20b7abb3 2020-10-22 stsp cmp -s $testroot/stderr.expected $testroot/stderr
882 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
883 20b7abb3 2020-10-22 stsp diff -u $testroot/stderr.expected $testroot/stderr
885 67c65ed7 2021-09-14 tracey test_done "$testroot" "$ret"
888 67c65ed7 2021-09-14 tracey test_checkout_quiet() {
889 67c65ed7 2021-09-14 tracey local testroot=`test_init checkout_quiet`
891 67c65ed7 2021-09-14 tracey echo -n "Checked out refs/heads/master: " >> $testroot/stdout.expected
892 67c65ed7 2021-09-14 tracey git_show_head $testroot/repo >> $testroot/stdout.expected
893 67d7451c 2021-09-15 naddy printf "\nNow shut up and hack\n" >> $testroot/stdout.expected
895 67c65ed7 2021-09-14 tracey got checkout -q $testroot/repo $testroot/wt > $testroot/stdout
897 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
898 67c65ed7 2021-09-14 tracey test_done "$testroot" "$ret"
902 67c65ed7 2021-09-14 tracey cmp -s $testroot/stdout.expected $testroot/stdout
904 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
905 67c65ed7 2021-09-14 tracey diff -u $testroot/stdout.expected $testroot/stdout
906 67c65ed7 2021-09-14 tracey test_done "$testroot" "$ret"
910 67c65ed7 2021-09-14 tracey echo "alpha" > $testroot/content.expected
911 67c65ed7 2021-09-14 tracey echo "beta" >> $testroot/content.expected
912 67c65ed7 2021-09-14 tracey echo "zeta" >> $testroot/content.expected
913 67c65ed7 2021-09-14 tracey echo "delta" >> $testroot/content.expected
914 67c65ed7 2021-09-14 tracey cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
915 67c65ed7 2021-09-14 tracey $testroot/wt/gamma/delta > $testroot/content
917 67c65ed7 2021-09-14 tracey cmp -s $testroot/content.expected $testroot/content
919 49c543a6 2022-03-31 naddy if [ $ret -ne 0 ]; then
920 67c65ed7 2021-09-14 tracey diff -u $testroot/content.expected $testroot/content
922 20b7abb3 2020-10-22 stsp test_done "$testroot" "$ret"
925 b2b3fce1 2022-10-29 op test_checkout_umask() {
926 b2b3fce1 2022-10-29 op local testroot=`test_init checkout_umask`
928 b2b3fce1 2022-10-29 op # using a subshell to avoid clobbering global umask
929 b2b3fce1 2022-10-29 op (umask 044 && got checkout "$testroot/repo" "$testroot/wt") \
932 b2b3fce1 2022-10-29 op if [ $ret -ne 0 ]; then
933 b2b3fce1 2022-10-29 op test_done "$testroot" $ret
937 b2b3fce1 2022-10-29 op for f in alpha beta epsilon/zeta gamma/delta; do
938 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/$f" | grep -q ^-rw-------
939 b2b3fce1 2022-10-29 op if [ $? -ne 0 ]; then
940 b2b3fce1 2022-10-29 op echo "$f is not 0600 after checkout" >&2
941 b2b3fce1 2022-10-29 op ls -l "$testroot/wt/$f" >&2
942 b2b3fce1 2022-10-29 op test_done "$testroot" 1
947 b2b3fce1 2022-10-29 op for d in epsilon gamma; do
948 b2b3fce1 2022-10-29 op ls -ld "$testroot/wt/$d" | grep -q ^drwx--x--x
949 b2b3fce1 2022-10-29 op if [ $? -ne 0 ]; then
950 b2b3fce1 2022-10-29 op echo "$d is not 711 after checkout" >&2
951 b2b3fce1 2022-10-29 op ls -ld "$testroot/wt/$d" >&2
952 b2b3fce1 2022-10-29 op test_done "$testroot" 1
957 b2b3fce1 2022-10-29 op test_done "$testroot" 0
960 5753b4a9 2022-10-31 stsp test_checkout_ulimit_n() {
961 5753b4a9 2022-10-31 stsp local testroot=`test_init checkout_ulimit_n`
963 5753b4a9 2022-10-31 stsp echo -n "Checked out refs/heads/master: " >> $testroot/stdout.expected
964 5753b4a9 2022-10-31 stsp git_show_head $testroot/repo >> $testroot/stdout.expected
965 5753b4a9 2022-10-31 stsp printf "\nNow shut up and hack\n" >> $testroot/stdout.expected
967 5753b4a9 2022-10-31 stsp # Drastically reduce the number of files we are allowed to use.
968 5753b4a9 2022-10-31 stsp # This tests our down-scaling of caches which store open file handles.
969 5753b4a9 2022-10-31 stsp # Checkout should still work; if it does not, then either there is
970 5753b4a9 2022-10-31 stsp # a bug or the fixed limit used by this test case is no longer valid
971 f4c9dec9 2022-10-31 stsp # and must be raised. Use a subshell to avoid changing global ulimit.
972 113ee344 2023-01-27 tracey (ulimit -n 33; got checkout -q $testroot/repo $testroot/wt \
973 f4c9dec9 2022-10-31 stsp > $testroot/stdout)
975 5753b4a9 2022-10-31 stsp if [ $ret -ne 0 ]; then
976 5753b4a9 2022-10-31 stsp test_done "$testroot" "$ret"
980 5753b4a9 2022-10-31 stsp cmp -s $testroot/stdout.expected $testroot/stdout
982 5753b4a9 2022-10-31 stsp if [ $ret -ne 0 ]; then
983 5753b4a9 2022-10-31 stsp diff -u $testroot/stdout.expected $testroot/stdout
984 5753b4a9 2022-10-31 stsp test_done "$testroot" "$ret"
988 5753b4a9 2022-10-31 stsp echo "alpha" > $testroot/content.expected
989 5753b4a9 2022-10-31 stsp echo "beta" >> $testroot/content.expected
990 5753b4a9 2022-10-31 stsp echo "zeta" >> $testroot/content.expected
991 5753b4a9 2022-10-31 stsp echo "delta" >> $testroot/content.expected
992 5753b4a9 2022-10-31 stsp cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
993 5753b4a9 2022-10-31 stsp $testroot/wt/gamma/delta > $testroot/content
995 5753b4a9 2022-10-31 stsp cmp -s $testroot/content.expected $testroot/content
997 5753b4a9 2022-10-31 stsp if [ $ret -ne 0 ]; then
998 5753b4a9 2022-10-31 stsp diff -u $testroot/content.expected $testroot/content
1000 c8d1a97c 2023-07-17 mark test_done "$testroot" "$ret"
1003 c8d1a97c 2023-07-17 mark test_checkout_commit_keywords() {
1004 c8d1a97c 2023-07-17 mark local testroot=$(test_init checkout_commit_keywords)
1006 79c49d84 2023-07-24 mark set -- "$(git_show_head $testroot/repo)"
1008 c8d1a97c 2023-07-17 mark got checkout $testroot/repo $testroot/wt > /dev/null
1010 c8d1a97c 2023-07-17 mark if [ $ret -ne 0 ]; then
1011 c8d1a97c 2023-07-17 mark echo "checkout failed unexpectedly" >&2
1012 c8d1a97c 2023-07-17 mark test_done "$testroot" "$ret"
1016 c8d1a97c 2023-07-17 mark for i in $(seq 4); do
1017 c8d1a97c 2023-07-17 mark echo "zeta change $i" > "$testroot/wt/epsilon/zeta"
1019 c8d1a97c 2023-07-17 mark (cd "$testroot/wt" && got ci -m "commit number $i" > /dev/null)
1021 c8d1a97c 2023-07-17 mark if [ $ret -ne 0 ]; then
1022 c8d1a97c 2023-07-17 mark echo "commit failed unexpectedly" >&2
1023 c8d1a97c 2023-07-17 mark test_done "$testroot" "$ret"
1026 79c49d84 2023-07-24 mark set -- "$@" "$(git_show_head $testroot/repo)"
1029 c8d1a97c 2023-07-17 mark echo "A $testroot/wt2/alpha" > $testroot/stdout.expected
1030 c8d1a97c 2023-07-17 mark echo "A $testroot/wt2/beta" >> $testroot/stdout.expected
1031 c8d1a97c 2023-07-17 mark echo "A $testroot/wt2/epsilon/zeta" >> $testroot/stdout.expected
1032 c8d1a97c 2023-07-17 mark echo "A $testroot/wt2/gamma/delta" >> $testroot/stdout.expected
1033 79c49d84 2023-07-24 mark echo "Checked out refs/heads/master: $(pop_idx 4 $@)" \
1034 c8d1a97c 2023-07-17 mark >> $testroot/stdout.expected
1035 c8d1a97c 2023-07-17 mark echo "Now shut up and hack" >> $testroot/stdout.expected
1037 c8d1a97c 2023-07-17 mark got co -c :head:- $testroot/repo $testroot/wt2 > $testroot/stdout
1039 c8d1a97c 2023-07-17 mark if [ $ret -ne 0 ]; then
1040 c8d1a97c 2023-07-17 mark test_done "$testroot" "$ret"
1044 c8d1a97c 2023-07-17 mark cmp -s $testroot/stdout.expected $testroot/stdout
1046 c8d1a97c 2023-07-17 mark if [ $ret -ne 0 ]; then
1047 c8d1a97c 2023-07-17 mark diff -u $testroot/stdout.expected $testroot/stdout
1048 c8d1a97c 2023-07-17 mark test_done "$testroot" "$ret"
1052 c8d1a97c 2023-07-17 mark echo "A $testroot/wt3/alpha" > $testroot/stdout.expected
1053 c8d1a97c 2023-07-17 mark echo "A $testroot/wt3/beta" >> $testroot/stdout.expected
1054 c8d1a97c 2023-07-17 mark echo "A $testroot/wt3/epsilon/zeta" >> $testroot/stdout.expected
1055 c8d1a97c 2023-07-17 mark echo "A $testroot/wt3/gamma/delta" >> $testroot/stdout.expected
1056 79c49d84 2023-07-24 mark echo "Checked out refs/heads/master: $(pop_idx 4 $@)" \
1057 c8d1a97c 2023-07-17 mark >> $testroot/stdout.expected
1058 c8d1a97c 2023-07-17 mark echo "Now shut up and hack" >> $testroot/stdout.expected
1060 c8d1a97c 2023-07-17 mark got co -bmaster -c:base:- $testroot/repo $testroot/wt3 > \
1061 c8d1a97c 2023-07-17 mark $testroot/stdout
1063 c8d1a97c 2023-07-17 mark if [ $ret -ne 0 ]; then
1064 c8d1a97c 2023-07-17 mark test_done "$testroot" "$ret"
1068 c8d1a97c 2023-07-17 mark cmp -s $testroot/stdout.expected $testroot/stdout
1070 c8d1a97c 2023-07-17 mark if [ $ret -ne 0 ]; then
1071 c8d1a97c 2023-07-17 mark diff -u $testroot/stdout.expected $testroot/stdout
1074 5753b4a9 2022-10-31 stsp test_done "$testroot" "$ret"
1077 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1078 0e673013 2019-01-02 stsp run_test test_checkout_basic
1079 80c1b583 2019-08-07 stsp run_test test_checkout_dir_exists
1080 80c1b583 2019-08-07 stsp run_test test_checkout_dir_not_empty
1081 692a4bb1 2023-08-28 stsp run_test test_checkout_into_repo
1082 692a4bb1 2023-08-28 stsp run_test test_checkout_overlap_repo
1083 68ed9ba5 2019-02-10 stsp run_test test_checkout_sets_xbit
1084 45d344f6 2019-05-14 stsp run_test test_checkout_commit_from_wrong_branch
1085 303e2782 2019-08-09 stsp run_test test_checkout_tag
1086 63c5ca5d 2019-08-24 stsp run_test test_checkout_ignores_submodules
1087 7f47418f 2019-12-20 stsp run_test test_checkout_read_only
1088 bb51a5b4 2020-01-13 stsp run_test test_checkout_into_nonempty_dir
1089 8ba819a3 2020-07-23 stsp run_test test_checkout_symlink
1090 7d61d891 2020-07-23 stsp run_test test_checkout_symlink_relative_wtpath
1091 20b7abb3 2020-10-22 stsp run_test test_checkout_repo_with_unknown_extension
1092 67c65ed7 2021-09-14 tracey run_test test_checkout_quiet
1093 b2b3fce1 2022-10-29 op run_test test_checkout_umask
1094 5753b4a9 2022-10-31 stsp run_test test_checkout_ulimit_n
1095 c8d1a97c 2023-07-17 mark run_test test_checkout_commit_keywords