Blame


1 0e673013 2019-01-02 stsp #!/bin/sh
2 0e673013 2019-01-02 stsp #
3 0e673013 2019-01-02 stsp # Copyright (c) 2019 Stefan Sperling <stsp@openbsd.org>
4 0e673013 2019-01-02 stsp #
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.
8 0e673013 2019-01-02 stsp #
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.
16 0e673013 2019-01-02 stsp
17 0e673013 2019-01-02 stsp . ./common.sh
18 0e673013 2019-01-02 stsp
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`
22 0e673013 2019-01-02 stsp
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
30 0e673013 2019-01-02 stsp
31 0e673013 2019-01-02 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
32 fc414659 2022-04-16 thomas ret=$?
33 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
34 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
35 0e673013 2019-01-02 stsp return 1
36 0e673013 2019-01-02 stsp fi
37 0e673013 2019-01-02 stsp
38 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
39 fc414659 2022-04-16 thomas ret=$?
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"
43 0e673013 2019-01-02 stsp return 1
44 0e673013 2019-01-02 stsp fi
45 0e673013 2019-01-02 stsp
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
52 0e673013 2019-01-02 stsp
53 8d301dd9 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
54 fc414659 2022-04-16 thomas ret=$?
55 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
56 0e673013 2019-01-02 stsp diff -u $testroot/content.expected $testroot/content
57 0e673013 2019-01-02 stsp fi
58 693719bc 2019-01-03 stsp test_done "$testroot" "$ret"
59 0e673013 2019-01-02 stsp }
60 0e673013 2019-01-02 stsp
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`
64 80c1b583 2019-08-07 stsp
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
72 80c1b583 2019-08-07 stsp
73 80c1b583 2019-08-07 stsp mkdir $testroot/wt
74 80c1b583 2019-08-07 stsp
75 80c1b583 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
76 fc414659 2022-04-16 thomas ret=$?
77 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
78 80c1b583 2019-08-07 stsp test_done "$testroot" "$ret"
79 80c1b583 2019-08-07 stsp return 1
80 80c1b583 2019-08-07 stsp fi
81 80c1b583 2019-08-07 stsp
82 80c1b583 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
83 fc414659 2022-04-16 thomas ret=$?
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"
87 80c1b583 2019-08-07 stsp return 1
88 80c1b583 2019-08-07 stsp fi
89 80c1b583 2019-08-07 stsp
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
96 80c1b583 2019-08-07 stsp
97 80c1b583 2019-08-07 stsp cmp -s $testroot/content.expected $testroot/content
98 fc414659 2022-04-16 thomas ret=$?
99 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
100 80c1b583 2019-08-07 stsp diff -u $testroot/content.expected $testroot/content
101 80c1b583 2019-08-07 stsp fi
102 80c1b583 2019-08-07 stsp test_done "$testroot" "$ret"
103 80c1b583 2019-08-07 stsp }
104 80c1b583 2019-08-07 stsp
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`
108 80c1b583 2019-08-07 stsp
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
116 80c1b583 2019-08-07 stsp
117 80c1b583 2019-08-07 stsp mkdir $testroot/wt
118 80c1b583 2019-08-07 stsp touch $testroot/wt/foo
119 80c1b583 2019-08-07 stsp
120 80c1b583 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout \
121 80c1b583 2019-08-07 stsp 2> $testroot/stderr
122 fc414659 2022-04-16 thomas ret=$?
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"
126 80c1b583 2019-08-07 stsp return 1
127 80c1b583 2019-08-07 stsp fi
128 80c1b583 2019-08-07 stsp
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
132 fc414659 2022-04-16 thomas ret=$?
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"
136 80c1b583 2019-08-07 stsp return 1
137 80c1b583 2019-08-07 stsp fi
138 80c1b583 2019-08-07 stsp
139 80c1b583 2019-08-07 stsp echo -n > $testroot/stdout.expected
140 80c1b583 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
141 fc414659 2022-04-16 thomas ret=$?
142 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
143 80c1b583 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
144 484d974b 2023-08-29 thomas fi
145 484d974b 2023-08-29 thomas test_done "$testroot" "$ret"
146 484d974b 2023-08-29 thomas
147 484d974b 2023-08-29 thomas }
148 484d974b 2023-08-29 thomas
149 484d974b 2023-08-29 thomas test_checkout_into_repo() {
150 484d974b 2023-08-29 thomas local testroot=`test_init checkout_into_repo`
151 484d974b 2023-08-29 thomas local commit_id=`git_show_head $testroot/repo`
152 484d974b 2023-08-29 thomas
153 484d974b 2023-08-29 thomas got checkout $testroot/repo $testroot/repo/wt \
154 484d974b 2023-08-29 thomas > $testroot/stdout 2> $testroot/stderr
155 484d974b 2023-08-29 thomas ret=$?
156 484d974b 2023-08-29 thomas if [ $ret -eq 0 ]; then
157 484d974b 2023-08-29 thomas echo "checkout succeeded unexpectedly" >&2
158 484d974b 2023-08-29 thomas test_done "$testroot" "1"
159 484d974b 2023-08-29 thomas return 1
160 484d974b 2023-08-29 thomas fi
161 484d974b 2023-08-29 thomas
162 484d974b 2023-08-29 thomas echo -n > $testroot/stdout.expected
163 484d974b 2023-08-29 thomas
164 484d974b 2023-08-29 thomas cmp -s $testroot/stdout.expected $testroot/stdout
165 484d974b 2023-08-29 thomas ret=$?
166 484d974b 2023-08-29 thomas if [ $ret -ne 0 ]; then
167 484d974b 2023-08-29 thomas diff -u $testroot/stdout.expected $testroot/stdout
168 484d974b 2023-08-29 thomas test_done "$testroot" "$ret"
169 484d974b 2023-08-29 thomas return 1
170 484d974b 2023-08-29 thomas fi
171 484d974b 2023-08-29 thomas
172 484d974b 2023-08-29 thomas echo -n "got: work tree and repository paths may not overlap: " \
173 484d974b 2023-08-29 thomas > $testroot/stderr.expected
174 484d974b 2023-08-29 thomas echo "$testroot/repo/wt: bad path" >> $testroot/stderr.expected
175 484d974b 2023-08-29 thomas cmp -s $testroot/stderr.expected $testroot/stderr
176 484d974b 2023-08-29 thomas ret=$?
177 484d974b 2023-08-29 thomas if [ $ret -ne 0 ]; then
178 484d974b 2023-08-29 thomas diff -u $testroot/stderr.expected $testroot/stderr
179 80c1b583 2019-08-07 stsp fi
180 80c1b583 2019-08-07 stsp test_done "$testroot" "$ret"
181 484d974b 2023-08-29 thomas }
182 80c1b583 2019-08-07 stsp
183 484d974b 2023-08-29 thomas test_checkout_overlap_repo() {
184 484d974b 2023-08-29 thomas local testroot=`test_init checkout_into_repo`
185 484d974b 2023-08-29 thomas local commit_id=`git_show_head $testroot/repo`
186 484d974b 2023-08-29 thomas
187 484d974b 2023-08-29 thomas got checkout $testroot/repo $testroot \
188 484d974b 2023-08-29 thomas > $testroot/stdout 2> $testroot/stderr
189 484d974b 2023-08-29 thomas ret=$?
190 484d974b 2023-08-29 thomas if [ $ret -eq 0 ]; then
191 484d974b 2023-08-29 thomas echo "checkout succeeded unexpectedly" >&2
192 484d974b 2023-08-29 thomas test_done "$testroot" "1"
193 484d974b 2023-08-29 thomas return 1
194 484d974b 2023-08-29 thomas fi
195 484d974b 2023-08-29 thomas
196 484d974b 2023-08-29 thomas echo -n > $testroot/stdout.expected
197 484d974b 2023-08-29 thomas
198 484d974b 2023-08-29 thomas cmp -s $testroot/stdout.expected $testroot/stdout
199 484d974b 2023-08-29 thomas ret=$?
200 484d974b 2023-08-29 thomas if [ $ret -ne 0 ]; then
201 484d974b 2023-08-29 thomas diff -u $testroot/stdout.expected $testroot/stdout
202 484d974b 2023-08-29 thomas test_done "$testroot" "$ret"
203 484d974b 2023-08-29 thomas return 1
204 484d974b 2023-08-29 thomas fi
205 484d974b 2023-08-29 thomas
206 484d974b 2023-08-29 thomas echo -n "got: work tree and repository paths may not overlap: " \
207 484d974b 2023-08-29 thomas > $testroot/stderr.expected
208 484d974b 2023-08-29 thomas echo "$testroot: bad path" >> $testroot/stderr.expected
209 484d974b 2023-08-29 thomas cmp -s $testroot/stderr.expected $testroot/stderr
210 484d974b 2023-08-29 thomas ret=$?
211 484d974b 2023-08-29 thomas if [ $ret -ne 0 ]; then
212 484d974b 2023-08-29 thomas diff -u $testroot/stderr.expected $testroot/stderr
213 484d974b 2023-08-29 thomas fi
214 484d974b 2023-08-29 thomas test_done "$testroot" "$ret"
215 80c1b583 2019-08-07 stsp }
216 80c1b583 2019-08-07 stsp
217 f6cae3ed 2020-09-13 naddy test_checkout_sets_xbit() {
218 68ed9ba5 2019-02-10 stsp local testroot=`test_init checkout_sets_xbit 1`
219 68ed9ba5 2019-02-10 stsp
220 68ed9ba5 2019-02-10 stsp touch $testroot/repo/xfile
221 68ed9ba5 2019-02-10 stsp chmod +x $testroot/repo/xfile
222 d1e03b8c 2023-10-08 thomas git -C $testroot/repo 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`
225 68ed9ba5 2019-02-10 stsp
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
230 68ed9ba5 2019-02-10 stsp
231 68ed9ba5 2019-02-10 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
232 fc414659 2022-04-16 thomas ret=$?
233 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
234 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
235 68ed9ba5 2019-02-10 stsp return 1
236 68ed9ba5 2019-02-10 stsp fi
237 68ed9ba5 2019-02-10 stsp
238 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
239 fc414659 2022-04-16 thomas ret=$?
240 fc414659 2022-04-16 thomas 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"
243 68ed9ba5 2019-02-10 stsp return 1
244 68ed9ba5 2019-02-10 stsp fi
245 68ed9ba5 2019-02-10 stsp
246 68ed9ba5 2019-02-10 stsp ls -l $testroot/wt/xfile | grep -q '^-rwx'
247 fc414659 2022-04-16 thomas ret=$?
248 fc414659 2022-04-16 thomas 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
251 68ed9ba5 2019-02-10 stsp fi
252 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
253 68ed9ba5 2019-02-10 stsp }
254 68ed9ba5 2019-02-10 stsp
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`
257 45d344f6 2019-05-14 stsp
258 d1e03b8c 2023-10-08 thomas git -C $testroot/repo 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"
261 45d344f6 2019-05-14 stsp
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
265 fc414659 2022-04-16 thomas ret=$?
266 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
267 45d344f6 2019-05-14 stsp test_done "$testroot" "1"
268 45d344f6 2019-05-14 stsp return 1
269 45d344f6 2019-05-14 stsp fi
270 45d344f6 2019-05-14 stsp
271 45d344f6 2019-05-14 stsp echo -n "" > $testroot/stdout.expected
272 45d344f6 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
273 fc414659 2022-04-16 thomas ret=$?
274 fc414659 2022-04-16 thomas 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"
277 45d344f6 2019-05-14 stsp return 1
278 45d344f6 2019-05-14 stsp fi
279 45d344f6 2019-05-14 stsp
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
289 fc414659 2022-04-16 thomas ret=$?
290 fc414659 2022-04-16 thomas 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"
293 45d344f6 2019-05-14 stsp return 1
294 45d344f6 2019-05-14 stsp fi
295 45d344f6 2019-05-14 stsp
296 45d344f6 2019-05-14 stsp test_done "$testroot" "$ret"
297 45d344f6 2019-05-14 stsp }
298 45d344f6 2019-05-14 stsp
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"
303 303e2782 2019-08-09 stsp
304 d1e03b8c 2023-10-08 thomas git -C $testroot/repo tag -a -m "test" $tag
305 303e2782 2019-08-09 stsp
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
313 303e2782 2019-08-09 stsp
314 303e2782 2019-08-09 stsp got checkout -c $tag $testroot/repo $testroot/wt > $testroot/stdout
315 fc414659 2022-04-16 thomas ret=$?
316 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
317 303e2782 2019-08-09 stsp test_done "$testroot" "$ret"
318 303e2782 2019-08-09 stsp return 1
319 303e2782 2019-08-09 stsp fi
320 303e2782 2019-08-09 stsp
321 303e2782 2019-08-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
322 fc414659 2022-04-16 thomas ret=$?
323 fc414659 2022-04-16 thomas 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"
326 303e2782 2019-08-09 stsp return 1
327 303e2782 2019-08-09 stsp fi
328 303e2782 2019-08-09 stsp
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
335 303e2782 2019-08-09 stsp
336 303e2782 2019-08-09 stsp cmp -s $testroot/content.expected $testroot/content
337 fc414659 2022-04-16 thomas ret=$?
338 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
339 303e2782 2019-08-09 stsp diff -u $testroot/content.expected $testroot/content
340 303e2782 2019-08-09 stsp fi
341 303e2782 2019-08-09 stsp test_done "$testroot" "$ret"
342 303e2782 2019-08-09 stsp }
343 63c5ca5d 2019-08-24 stsp
344 f6cae3ed 2020-09-13 naddy test_checkout_ignores_submodules() {
345 63c5ca5d 2019-08-24 stsp local testroot=`test_init checkout_ignores_submodules`
346 63c5ca5d 2019-08-24 stsp
347 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
348 e7303626 2020-05-14 stsp
349 d1e03b8c 2023-10-08 thomas git -C $testroot/repo -c protocol.file.allow=always \
350 d1e03b8c 2023-10-08 thomas submodule -q add ../repo2
351 d1e03b8c 2023-10-08 thomas git -C $testroot/repo commit -q -m 'adding submodule'
352 08e5873e 2021-09-14 stsp local commit_id=`git_show_head $testroot/repo`
353 63c5ca5d 2019-08-24 stsp
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
362 303e2782 2019-08-09 stsp
363 63c5ca5d 2019-08-24 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
364 fc414659 2022-04-16 thomas ret=$?
365 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
366 63c5ca5d 2019-08-24 stsp test_done "$testroot" "$ret"
367 63c5ca5d 2019-08-24 stsp return 1
368 63c5ca5d 2019-08-24 stsp fi
369 63c5ca5d 2019-08-24 stsp
370 63c5ca5d 2019-08-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
371 fc414659 2022-04-16 thomas ret=$?
372 fc414659 2022-04-16 thomas 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"
375 63c5ca5d 2019-08-24 stsp return 1
376 63c5ca5d 2019-08-24 stsp fi
377 63c5ca5d 2019-08-24 stsp
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
384 63c5ca5d 2019-08-24 stsp
385 63c5ca5d 2019-08-24 stsp cmp -s $testroot/content.expected $testroot/content
386 fc414659 2022-04-16 thomas ret=$?
387 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
388 63c5ca5d 2019-08-24 stsp diff -u $testroot/content.expected $testroot/content
389 63c5ca5d 2019-08-24 stsp fi
390 63c5ca5d 2019-08-24 stsp test_done "$testroot" "$ret"
391 63c5ca5d 2019-08-24 stsp }
392 7f47418f 2019-12-20 stsp
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`
396 7f47418f 2019-12-20 stsp
397 7f47418f 2019-12-20 stsp # Make the repostiory read-only
398 7f47418f 2019-12-20 stsp chmod -R a-w $testroot/repo
399 7f47418f 2019-12-20 stsp
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
407 7f47418f 2019-12-20 stsp
408 7f47418f 2019-12-20 stsp got checkout $testroot/repo $testroot/wt \
409 7f47418f 2019-12-20 stsp > $testroot/stdout 2> $testroot/stderr
410 fc414659 2022-04-16 thomas ret=$?
411 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
412 7f47418f 2019-12-20 stsp test_done "$testroot" "$ret"
413 7f47418f 2019-12-20 stsp return 1
414 7f47418f 2019-12-20 stsp fi
415 63c5ca5d 2019-08-24 stsp
416 7f47418f 2019-12-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout
417 fc414659 2022-04-16 thomas ret=$?
418 fc414659 2022-04-16 thomas 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"
421 7f47418f 2019-12-20 stsp return 1
422 7f47418f 2019-12-20 stsp fi
423 7f47418f 2019-12-20 stsp
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
434 fc414659 2022-04-16 thomas ret=$?
435 fc414659 2022-04-16 thomas 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"
438 7f47418f 2019-12-20 stsp return 1
439 7f47418f 2019-12-20 stsp fi
440 7f47418f 2019-12-20 stsp
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
447 7f47418f 2019-12-20 stsp
448 7f47418f 2019-12-20 stsp cmp -s $testroot/content.expected $testroot/content
449 fc414659 2022-04-16 thomas ret=$?
450 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
451 7f47418f 2019-12-20 stsp diff -u $testroot/content.expected $testroot/content
452 7f47418f 2019-12-20 stsp fi
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"
455 7f47418f 2019-12-20 stsp }
456 bb51a5b4 2020-01-13 stsp
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`
460 bb51a5b4 2020-01-13 stsp
461 bb51a5b4 2020-01-13 stsp mkdir -p $testroot/wt
462 bb51a5b4 2020-01-13 stsp make_test_tree $testroot/wt
463 bb51a5b4 2020-01-13 stsp
464 bb51a5b4 2020-01-13 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout \
465 bb51a5b4 2020-01-13 stsp 2> $testroot/stderr
466 fc414659 2022-04-16 thomas ret=$?
467 fc414659 2022-04-16 thomas 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"
470 bb51a5b4 2020-01-13 stsp return 1
471 bb51a5b4 2020-01-13 stsp fi
472 bb51a5b4 2020-01-13 stsp
473 bb51a5b4 2020-01-13 stsp echo -n > $testroot/stdout.expected
474 bb51a5b4 2020-01-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
475 fc414659 2022-04-16 thomas ret=$?
476 fc414659 2022-04-16 thomas 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"
479 bb51a5b4 2020-01-13 stsp return 1
480 bb51a5b4 2020-01-13 stsp fi
481 bb51a5b4 2020-01-13 stsp
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
485 fc414659 2022-04-16 thomas ret=$?
486 fc414659 2022-04-16 thomas 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"
489 bb51a5b4 2020-01-13 stsp return 1
490 bb51a5b4 2020-01-13 stsp fi
491 bb51a5b4 2020-01-13 stsp
492 aaf972e2 2023-09-18 thomas echo "E $testroot/wt/alpha" > $testroot/stdout.expected
493 aaf972e2 2023-09-18 thomas echo "E $testroot/wt/beta" >> $testroot/stdout.expected
494 aaf972e2 2023-09-18 thomas echo "E $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
495 aaf972e2 2023-09-18 thomas echo "E $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
499 7f47418f 2019-12-20 stsp
500 bb51a5b4 2020-01-13 stsp got checkout -E $testroot/repo $testroot/wt > $testroot/stdout
501 fc414659 2022-04-16 thomas ret=$?
502 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
503 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
504 bb51a5b4 2020-01-13 stsp return 1
505 bb51a5b4 2020-01-13 stsp fi
506 bb51a5b4 2020-01-13 stsp
507 bb51a5b4 2020-01-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
508 fc414659 2022-04-16 thomas ret=$?
509 fc414659 2022-04-16 thomas 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"
512 bb51a5b4 2020-01-13 stsp return 1
513 bb51a5b4 2020-01-13 stsp fi
514 bb51a5b4 2020-01-13 stsp
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
522 bb51a5b4 2020-01-13 stsp
523 bb51a5b4 2020-01-13 stsp got checkout -E $testroot/repo $testroot/wt > $testroot/stdout
524 fc414659 2022-04-16 thomas ret=$?
525 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
526 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
527 bb51a5b4 2020-01-13 stsp return 1
528 bb51a5b4 2020-01-13 stsp fi
529 bb51a5b4 2020-01-13 stsp
530 bb51a5b4 2020-01-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
531 fc414659 2022-04-16 thomas ret=$?
532 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
533 bb51a5b4 2020-01-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
534 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
535 bb51a5b4 2020-01-13 stsp return 1
536 bb51a5b4 2020-01-13 stsp fi
537 bb51a5b4 2020-01-13 stsp
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
544 bb51a5b4 2020-01-13 stsp
545 bb51a5b4 2020-01-13 stsp cmp -s $testroot/content.expected $testroot/content
546 fc414659 2022-04-16 thomas ret=$?
547 fc414659 2022-04-16 thomas 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"
550 bb51a5b4 2020-01-13 stsp return 1
551 bb51a5b4 2020-01-13 stsp fi
552 bb51a5b4 2020-01-13 stsp
553 aaf972e2 2023-09-18 thomas # retry, but with alpha modified
554 aaf972e2 2023-09-18 thomas
555 aaf972e2 2023-09-18 thomas rm -rf "$testroot/wt/.got"
556 aaf972e2 2023-09-18 thomas echo modified alpha >$testroot/wt/alpha
557 bb51a5b4 2020-01-13 stsp
558 bb51a5b4 2020-01-13 stsp echo "E $testroot/wt/alpha" > $testroot/stdout.expected
559 bb51a5b4 2020-01-13 stsp echo "E $testroot/wt/beta" >> $testroot/stdout.expected
560 bb51a5b4 2020-01-13 stsp echo "E $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
561 bb51a5b4 2020-01-13 stsp echo "E $testroot/wt/gamma/delta" >> $testroot/stdout.expected
562 08e5873e 2021-09-14 stsp echo "Checked out refs/heads/master: $commit_id" \
563 08e5873e 2021-09-14 stsp >> $testroot/stdout.expected
564 bb51a5b4 2020-01-13 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
565 bb51a5b4 2020-01-13 stsp
566 bb51a5b4 2020-01-13 stsp got checkout -E $testroot/repo $testroot/wt > $testroot/stdout
567 fc414659 2022-04-16 thomas ret=$?
568 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
569 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
570 bb51a5b4 2020-01-13 stsp return 1
571 bb51a5b4 2020-01-13 stsp fi
572 bb51a5b4 2020-01-13 stsp
573 bb51a5b4 2020-01-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
574 fc414659 2022-04-16 thomas ret=$?
575 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
576 bb51a5b4 2020-01-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
577 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
578 bb51a5b4 2020-01-13 stsp return 1
579 bb51a5b4 2020-01-13 stsp fi
580 bb51a5b4 2020-01-13 stsp
581 bb51a5b4 2020-01-13 stsp echo "modified alpha" > $testroot/content.expected
582 bb51a5b4 2020-01-13 stsp echo "beta" >> $testroot/content.expected
583 bb51a5b4 2020-01-13 stsp echo "zeta" >> $testroot/content.expected
584 bb51a5b4 2020-01-13 stsp echo "delta" >> $testroot/content.expected
585 bb51a5b4 2020-01-13 stsp cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
586 bb51a5b4 2020-01-13 stsp $testroot/wt/gamma/delta > $testroot/content
587 bb51a5b4 2020-01-13 stsp
588 bb51a5b4 2020-01-13 stsp cmp -s $testroot/content.expected $testroot/content
589 fc414659 2022-04-16 thomas ret=$?
590 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
591 bb51a5b4 2020-01-13 stsp diff -u $testroot/content.expected $testroot/content
592 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
593 4da1bbe9 2020-07-19 stsp return 1
594 bb51a5b4 2020-01-13 stsp fi
595 bb51a5b4 2020-01-13 stsp
596 bb51a5b4 2020-01-13 stsp echo 'M alpha' > $testroot/stdout.expected
597 bb51a5b4 2020-01-13 stsp (cd $testroot/wt && got status > $testroot/stdout)
598 8ba819a3 2020-07-23 stsp
599 8ba819a3 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
600 fc414659 2022-04-16 thomas ret=$?
601 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
602 8ba819a3 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
603 8ba819a3 2020-07-23 stsp fi
604 8ba819a3 2020-07-23 stsp test_done "$testroot" "$ret"
605 8ba819a3 2020-07-23 stsp }
606 8ba819a3 2020-07-23 stsp
607 f6cae3ed 2020-09-13 naddy test_checkout_symlink() {
608 8ba819a3 2020-07-23 stsp local testroot=`test_init checkout_symlink`
609 8ba819a3 2020-07-23 stsp
610 8ba819a3 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
611 8ba819a3 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
612 8ba819a3 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
613 b7422a2f 2020-07-23 stsp (cd $testroot/repo && ln -s passwd.link passwd2.link)
614 0ab20ee9 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
615 0ab20ee9 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
616 906c123b 2020-07-23 stsp (cd $testroot/repo && ln -s .got/foo dotgotfoo.link)
617 d1e03b8c 2023-10-08 thomas git -C $testroot/repo add .
618 0ab20ee9 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
619 08e5873e 2021-09-14 stsp local commit_id=`git_show_head $testroot/repo`
620 8ba819a3 2020-07-23 stsp
621 b7422a2f 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
622 fc414659 2022-04-16 thomas ret=$?
623 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
624 b7422a2f 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
625 8ba819a3 2020-07-23 stsp test_done "$testroot" "$ret"
626 8ba819a3 2020-07-23 stsp return 1
627 8ba819a3 2020-07-23 stsp fi
628 b7422a2f 2020-07-23 stsp
629 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/alpha" > $testroot/stdout.expected
630 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/alpha.link" >> $testroot/stdout.expected
631 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/beta" >> $testroot/stdout.expected
632 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/dotgotfoo.link" >> $testroot/stdout.expected
633 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/epsilon/beta.link" >> $testroot/stdout.expected
634 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
635 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/epsilon.link" >> $testroot/stdout.expected
636 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
637 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/nonexistent.link" >> $testroot/stdout.expected
638 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/passwd.link" >> $testroot/stdout.expected
639 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/passwd2.link" >> $testroot/stdout.expected
640 08e5873e 2021-09-14 stsp echo "Checked out refs/heads/master: $commit_id" \
641 08e5873e 2021-09-14 stsp >> $testroot/stdout.expected
642 b7422a2f 2020-07-23 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
643 8ba819a3 2020-07-23 stsp
644 b7422a2f 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
645 fc414659 2022-04-16 thomas ret=$?
646 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
647 b7422a2f 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
648 b7422a2f 2020-07-23 stsp test_done "$testroot" "$ret"
649 b7422a2f 2020-07-23 stsp return 1
650 b7422a2f 2020-07-23 stsp fi
651 b7422a2f 2020-07-23 stsp
652 8ba819a3 2020-07-23 stsp if ! [ -h $testroot/wt/alpha.link ]; then
653 8ba819a3 2020-07-23 stsp echo "alpha.link is not a symlink"
654 8ba819a3 2020-07-23 stsp test_done "$testroot" "1"
655 8ba819a3 2020-07-23 stsp return 1
656 8ba819a3 2020-07-23 stsp fi
657 8ba819a3 2020-07-23 stsp
658 8ba819a3 2020-07-23 stsp readlink $testroot/wt/alpha.link > $testroot/stdout
659 8ba819a3 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
660 8ba819a3 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
661 fc414659 2022-04-16 thomas ret=$?
662 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
663 8ba819a3 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
664 8ba819a3 2020-07-23 stsp test_done "$testroot" "$ret"
665 8ba819a3 2020-07-23 stsp return 1
666 8ba819a3 2020-07-23 stsp fi
667 bb51a5b4 2020-01-13 stsp
668 8ba819a3 2020-07-23 stsp if ! [ -h $testroot/wt/epsilon.link ]; then
669 8ba819a3 2020-07-23 stsp echo "epsilon.link is not a symlink"
670 8ba819a3 2020-07-23 stsp test_done "$testroot" "1"
671 8ba819a3 2020-07-23 stsp return 1
672 8ba819a3 2020-07-23 stsp fi
673 8ba819a3 2020-07-23 stsp
674 8ba819a3 2020-07-23 stsp readlink $testroot/wt/epsilon.link > $testroot/stdout
675 8ba819a3 2020-07-23 stsp echo "epsilon" > $testroot/stdout.expected
676 bb51a5b4 2020-01-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
677 fc414659 2022-04-16 thomas ret=$?
678 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
679 bb51a5b4 2020-01-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
680 8ba819a3 2020-07-23 stsp test_done "$testroot" "$ret"
681 8ba819a3 2020-07-23 stsp return 1
682 bb51a5b4 2020-01-13 stsp fi
683 8ba819a3 2020-07-23 stsp
684 8ba819a3 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
685 8ba819a3 2020-07-23 stsp echo -n "passwd.link symlink points outside of work tree: " >&2
686 8ba819a3 2020-07-23 stsp readlink $testroot/wt/passwd.link >&2
687 8ba819a3 2020-07-23 stsp test_done "$testroot" "1"
688 8ba819a3 2020-07-23 stsp return 1
689 8ba819a3 2020-07-23 stsp fi
690 8ba819a3 2020-07-23 stsp
691 8ba819a3 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
692 8ba819a3 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
693 8ba819a3 2020-07-23 stsp
694 8ba819a3 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
695 fc414659 2022-04-16 thomas ret=$?
696 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
697 8ba819a3 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
698 0ab20ee9 2020-07-23 stsp test_done "$testroot" "$ret"
699 0ab20ee9 2020-07-23 stsp return 1
700 0ab20ee9 2020-07-23 stsp fi
701 8ba819a3 2020-07-23 stsp
702 b7422a2f 2020-07-23 stsp if ! [ -h $testroot/wt/passwd2.link ]; then
703 b7422a2f 2020-07-23 stsp echo "passwd2.link is not a symlink"
704 b7422a2f 2020-07-23 stsp test_done "$testroot" "1"
705 b7422a2f 2020-07-23 stsp return 1
706 b7422a2f 2020-07-23 stsp fi
707 b7422a2f 2020-07-23 stsp
708 b7422a2f 2020-07-23 stsp readlink $testroot/wt/passwd2.link > $testroot/stdout
709 b7422a2f 2020-07-23 stsp echo "passwd.link" > $testroot/stdout.expected
710 b7422a2f 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
711 fc414659 2022-04-16 thomas ret=$?
712 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
713 b7422a2f 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
714 b7422a2f 2020-07-23 stsp test_done "$testroot" "$ret"
715 b7422a2f 2020-07-23 stsp return 1
716 b7422a2f 2020-07-23 stsp fi
717 b7422a2f 2020-07-23 stsp
718 0ab20ee9 2020-07-23 stsp readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
719 0ab20ee9 2020-07-23 stsp echo "../beta" > $testroot/stdout.expected
720 0ab20ee9 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
721 fc414659 2022-04-16 thomas ret=$?
722 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
723 0ab20ee9 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
724 0ab20ee9 2020-07-23 stsp test_done "$testroot" "$ret"
725 0ab20ee9 2020-07-23 stsp return 1
726 0ab20ee9 2020-07-23 stsp fi
727 0ab20ee9 2020-07-23 stsp
728 0ab20ee9 2020-07-23 stsp readlink $testroot/wt/nonexistent.link > $testroot/stdout
729 0ab20ee9 2020-07-23 stsp echo "nonexistent" > $testroot/stdout.expected
730 0ab20ee9 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
731 fc414659 2022-04-16 thomas ret=$?
732 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
733 0ab20ee9 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
734 906c123b 2020-07-23 stsp test_done "$testroot" "$ret"
735 41806587 2020-07-23 stsp return 1
736 906c123b 2020-07-23 stsp fi
737 906c123b 2020-07-23 stsp
738 906c123b 2020-07-23 stsp if [ -h $testroot/wt/dotgotfoo.link ]; then
739 906c123b 2020-07-23 stsp echo -n "dotgotfoo.link symlink points into .got dir: " >&2
740 906c123b 2020-07-23 stsp readlink $testroot/wt/dotgotfoo.link >&2
741 906c123b 2020-07-23 stsp test_done "$testroot" "1"
742 906c123b 2020-07-23 stsp return 1
743 906c123b 2020-07-23 stsp fi
744 906c123b 2020-07-23 stsp
745 906c123b 2020-07-23 stsp echo -n ".got/foo" > $testroot/content.expected
746 906c123b 2020-07-23 stsp cp $testroot/wt/dotgotfoo.link $testroot/content
747 906c123b 2020-07-23 stsp
748 906c123b 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
749 fc414659 2022-04-16 thomas ret=$?
750 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
751 906c123b 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
752 0ab20ee9 2020-07-23 stsp fi
753 0ab20ee9 2020-07-23 stsp test_done "$testroot" "$ret"
754 bb51a5b4 2020-01-13 stsp }
755 7d61d891 2020-07-23 stsp
756 f6cae3ed 2020-09-13 naddy test_checkout_symlink_relative_wtpath() {
757 7d61d891 2020-07-23 stsp local testroot=`test_init checkout_symlink_with_wtpath`
758 7d61d891 2020-07-23 stsp
759 7d61d891 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
760 7d61d891 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
761 7d61d891 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
762 7d61d891 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
763 7d61d891 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
764 7d61d891 2020-07-23 stsp (cd $testroot/repo && ln -s .got/foo dotgotfoo.link)
765 d1e03b8c 2023-10-08 thomas git -C $testroot/repo add .
766 7d61d891 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
767 7d61d891 2020-07-23 stsp
768 7d61d891 2020-07-23 stsp (cd $testroot && got checkout $testroot/repo wt > /dev/null)
769 fc414659 2022-04-16 thomas ret=$?
770 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
771 7d61d891 2020-07-23 stsp test_done "$testroot" "$ret"
772 7d61d891 2020-07-23 stsp return 1
773 7d61d891 2020-07-23 stsp fi
774 bb51a5b4 2020-01-13 stsp
775 7d61d891 2020-07-23 stsp if ! [ -h $testroot/wt/alpha.link ]; then
776 7d61d891 2020-07-23 stsp echo "alpha.link is not a symlink"
777 7d61d891 2020-07-23 stsp test_done "$testroot" "1"
778 7d61d891 2020-07-23 stsp return 1
779 7d61d891 2020-07-23 stsp fi
780 7d61d891 2020-07-23 stsp
781 7d61d891 2020-07-23 stsp readlink $testroot/wt/alpha.link > $testroot/stdout
782 7d61d891 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
783 7d61d891 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
784 fc414659 2022-04-16 thomas ret=$?
785 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
786 7d61d891 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
787 7d61d891 2020-07-23 stsp test_done "$testroot" "$ret"
788 7d61d891 2020-07-23 stsp return 1
789 7d61d891 2020-07-23 stsp fi
790 7d61d891 2020-07-23 stsp
791 7d61d891 2020-07-23 stsp if ! [ -h $testroot/wt/epsilon.link ]; then
792 7d61d891 2020-07-23 stsp echo "epsilon.link is not a symlink"
793 7d61d891 2020-07-23 stsp test_done "$testroot" "1"
794 7d61d891 2020-07-23 stsp return 1
795 7d61d891 2020-07-23 stsp fi
796 7d61d891 2020-07-23 stsp
797 7d61d891 2020-07-23 stsp readlink $testroot/wt/epsilon.link > $testroot/stdout
798 7d61d891 2020-07-23 stsp echo "epsilon" > $testroot/stdout.expected
799 7d61d891 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
800 fc414659 2022-04-16 thomas ret=$?
801 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
802 7d61d891 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
803 7d61d891 2020-07-23 stsp test_done "$testroot" "$ret"
804 7d61d891 2020-07-23 stsp return 1
805 7d61d891 2020-07-23 stsp fi
806 7d61d891 2020-07-23 stsp
807 7d61d891 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
808 7d61d891 2020-07-23 stsp echo -n "passwd.link symlink points outside of work tree: " >&2
809 7d61d891 2020-07-23 stsp readlink $testroot/wt/passwd.link >&2
810 7d61d891 2020-07-23 stsp test_done "$testroot" "1"
811 7d61d891 2020-07-23 stsp return 1
812 7d61d891 2020-07-23 stsp fi
813 7d61d891 2020-07-23 stsp
814 7d61d891 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
815 7d61d891 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
816 7d61d891 2020-07-23 stsp
817 7d61d891 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
818 fc414659 2022-04-16 thomas ret=$?
819 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
820 7d61d891 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
821 7d61d891 2020-07-23 stsp test_done "$testroot" "$ret"
822 7d61d891 2020-07-23 stsp return 1
823 7d61d891 2020-07-23 stsp fi
824 7d61d891 2020-07-23 stsp
825 7d61d891 2020-07-23 stsp readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
826 7d61d891 2020-07-23 stsp echo "../beta" > $testroot/stdout.expected
827 7d61d891 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
828 fc414659 2022-04-16 thomas ret=$?
829 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
830 7d61d891 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
831 7d61d891 2020-07-23 stsp test_done "$testroot" "$ret"
832 7d61d891 2020-07-23 stsp return 1
833 7d61d891 2020-07-23 stsp fi
834 7d61d891 2020-07-23 stsp
835 7d61d891 2020-07-23 stsp readlink $testroot/wt/nonexistent.link > $testroot/stdout
836 7d61d891 2020-07-23 stsp echo "nonexistent" > $testroot/stdout.expected
837 7d61d891 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
838 fc414659 2022-04-16 thomas ret=$?
839 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
840 7d61d891 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
841 7d61d891 2020-07-23 stsp test_done "$testroot" "$ret"
842 41806587 2020-07-23 stsp return 1
843 7d61d891 2020-07-23 stsp fi
844 7d61d891 2020-07-23 stsp
845 7d61d891 2020-07-23 stsp if [ -h $testroot/wt/dotgotfoo.link ]; then
846 7d61d891 2020-07-23 stsp echo -n "dotgotfoo.link symlink points into .got dir: " >&2
847 7d61d891 2020-07-23 stsp readlink $testroot/wt/dotgotfoo.link >&2
848 7d61d891 2020-07-23 stsp test_done "$testroot" "1"
849 7d61d891 2020-07-23 stsp return 1
850 7d61d891 2020-07-23 stsp fi
851 7d61d891 2020-07-23 stsp
852 7d61d891 2020-07-23 stsp echo -n ".got/foo" > $testroot/content.expected
853 7d61d891 2020-07-23 stsp cp $testroot/wt/dotgotfoo.link $testroot/content
854 7d61d891 2020-07-23 stsp
855 7d61d891 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
856 fc414659 2022-04-16 thomas ret=$?
857 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
858 7d61d891 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
859 7d61d891 2020-07-23 stsp fi
860 7d61d891 2020-07-23 stsp test_done "$testroot" "$ret"
861 7d61d891 2020-07-23 stsp }
862 20b7abb3 2020-10-22 stsp
863 20b7abb3 2020-10-22 stsp test_checkout_repo_with_unknown_extension() {
864 20b7abb3 2020-10-22 stsp local testroot=`test_init checkout_repo_with_unknown_extension`
865 20b7abb3 2020-10-22 stsp
866 d1e03b8c 2023-10-08 thomas git -C $testroot/repo config --add extensions.badExtension foobar
867 d1e03b8c 2023-10-08 thomas git -C $testroot/repo config --add extensions.otherBadExtension 0
868 7d61d891 2020-07-23 stsp
869 20b7abb3 2020-10-22 stsp echo "got: badExtension: unsupported repository format extension" \
870 20b7abb3 2020-10-22 stsp > $testroot/stderr.expected
871 20b7abb3 2020-10-22 stsp got checkout $testroot/repo $testroot/wt \
872 20b7abb3 2020-10-22 stsp > $testroot/stdout 2> $testroot/stderr
873 20b7abb3 2020-10-22 stsp
874 fc414659 2022-04-16 thomas ret=$?
875 fc414659 2022-04-16 thomas if [ $ret -eq 0 ]; then
876 20b7abb3 2020-10-22 stsp echo "got checkout command succeeded unexpectedly" >&2
877 20b7abb3 2020-10-22 stsp test_done "$testroot" "1"
878 20b7abb3 2020-10-22 stsp return 1
879 20b7abb3 2020-10-22 stsp fi
880 20b7abb3 2020-10-22 stsp
881 20b7abb3 2020-10-22 stsp cmp -s $testroot/stderr.expected $testroot/stderr
882 fc414659 2022-04-16 thomas ret=$?
883 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
884 20b7abb3 2020-10-22 stsp diff -u $testroot/stderr.expected $testroot/stderr
885 67c65ed7 2021-09-14 tracey fi
886 67c65ed7 2021-09-14 tracey test_done "$testroot" "$ret"
887 67c65ed7 2021-09-14 tracey }
888 67c65ed7 2021-09-14 tracey
889 67c65ed7 2021-09-14 tracey test_checkout_quiet() {
890 67c65ed7 2021-09-14 tracey local testroot=`test_init checkout_quiet`
891 67c65ed7 2021-09-14 tracey
892 67c65ed7 2021-09-14 tracey echo -n "Checked out refs/heads/master: " >> $testroot/stdout.expected
893 67c65ed7 2021-09-14 tracey git_show_head $testroot/repo >> $testroot/stdout.expected
894 67d7451c 2021-09-15 naddy printf "\nNow shut up and hack\n" >> $testroot/stdout.expected
895 67c65ed7 2021-09-14 tracey
896 67c65ed7 2021-09-14 tracey got checkout -q $testroot/repo $testroot/wt > $testroot/stdout
897 fc414659 2022-04-16 thomas ret=$?
898 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
899 67c65ed7 2021-09-14 tracey test_done "$testroot" "$ret"
900 67c65ed7 2021-09-14 tracey return 1
901 67c65ed7 2021-09-14 tracey fi
902 67c65ed7 2021-09-14 tracey
903 67c65ed7 2021-09-14 tracey cmp -s $testroot/stdout.expected $testroot/stdout
904 fc414659 2022-04-16 thomas ret=$?
905 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
906 67c65ed7 2021-09-14 tracey diff -u $testroot/stdout.expected $testroot/stdout
907 67c65ed7 2021-09-14 tracey test_done "$testroot" "$ret"
908 67c65ed7 2021-09-14 tracey return 1
909 20b7abb3 2020-10-22 stsp fi
910 67c65ed7 2021-09-14 tracey
911 67c65ed7 2021-09-14 tracey echo "alpha" > $testroot/content.expected
912 67c65ed7 2021-09-14 tracey echo "beta" >> $testroot/content.expected
913 67c65ed7 2021-09-14 tracey echo "zeta" >> $testroot/content.expected
914 67c65ed7 2021-09-14 tracey echo "delta" >> $testroot/content.expected
915 67c65ed7 2021-09-14 tracey cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
916 67c65ed7 2021-09-14 tracey $testroot/wt/gamma/delta > $testroot/content
917 67c65ed7 2021-09-14 tracey
918 67c65ed7 2021-09-14 tracey cmp -s $testroot/content.expected $testroot/content
919 fc414659 2022-04-16 thomas ret=$?
920 fc414659 2022-04-16 thomas if [ $ret -ne 0 ]; then
921 67c65ed7 2021-09-14 tracey diff -u $testroot/content.expected $testroot/content
922 67c65ed7 2021-09-14 tracey fi
923 20b7abb3 2020-10-22 stsp test_done "$testroot" "$ret"
924 a2c162eb 2022-10-30 thomas }
925 a2c162eb 2022-10-30 thomas
926 a2c162eb 2022-10-30 thomas test_checkout_umask() {
927 a2c162eb 2022-10-30 thomas local testroot=`test_init checkout_umask`
928 a2c162eb 2022-10-30 thomas
929 a2c162eb 2022-10-30 thomas # using a subshell to avoid clobbering global umask
930 a2c162eb 2022-10-30 thomas (umask 044 && got checkout "$testroot/repo" "$testroot/wt") \
931 a2c162eb 2022-10-30 thomas >/dev/null
932 a2c162eb 2022-10-30 thomas ret=$?
933 a2c162eb 2022-10-30 thomas if [ $ret -ne 0 ]; then
934 a2c162eb 2022-10-30 thomas test_done "$testroot" $ret
935 a2c162eb 2022-10-30 thomas return 1
936 a2c162eb 2022-10-30 thomas fi
937 a2c162eb 2022-10-30 thomas
938 a2c162eb 2022-10-30 thomas for f in alpha beta epsilon/zeta gamma/delta; do
939 a2c162eb 2022-10-30 thomas ls -l "$testroot/wt/$f" | grep -q ^-rw-------
940 a2c162eb 2022-10-30 thomas if [ $? -ne 0 ]; then
941 a2c162eb 2022-10-30 thomas echo "$f is not 0600 after checkout" >&2
942 a2c162eb 2022-10-30 thomas ls -l "$testroot/wt/$f" >&2
943 a2c162eb 2022-10-30 thomas test_done "$testroot" 1
944 a2c162eb 2022-10-30 thomas return 1
945 a2c162eb 2022-10-30 thomas fi
946 a2c162eb 2022-10-30 thomas done
947 a2c162eb 2022-10-30 thomas
948 a2c162eb 2022-10-30 thomas for d in epsilon gamma; do
949 a2c162eb 2022-10-30 thomas ls -ld "$testroot/wt/$d" | grep -q ^drwx--x--x
950 a2c162eb 2022-10-30 thomas if [ $? -ne 0 ]; then
951 a2c162eb 2022-10-30 thomas echo "$d is not 711 after checkout" >&2
952 a2c162eb 2022-10-30 thomas ls -ld "$testroot/wt/$d" >&2
953 a2c162eb 2022-10-30 thomas test_done "$testroot" 1
954 a2c162eb 2022-10-30 thomas return 1
955 a2c162eb 2022-10-30 thomas fi
956 a2c162eb 2022-10-30 thomas done
957 a2c162eb 2022-10-30 thomas
958 a2c162eb 2022-10-30 thomas test_done "$testroot" 0
959 e0220e74 2022-10-31 thomas }
960 e0220e74 2022-10-31 thomas
961 e0220e74 2022-10-31 thomas test_checkout_ulimit_n() {
962 e0220e74 2022-10-31 thomas local testroot=`test_init checkout_ulimit_n`
963 e0220e74 2022-10-31 thomas
964 e0220e74 2022-10-31 thomas echo -n "Checked out refs/heads/master: " >> $testroot/stdout.expected
965 e0220e74 2022-10-31 thomas git_show_head $testroot/repo >> $testroot/stdout.expected
966 e0220e74 2022-10-31 thomas printf "\nNow shut up and hack\n" >> $testroot/stdout.expected
967 e0220e74 2022-10-31 thomas
968 e0220e74 2022-10-31 thomas # Drastically reduce the number of files we are allowed to use.
969 e0220e74 2022-10-31 thomas # This tests our down-scaling of caches which store open file handles.
970 e0220e74 2022-10-31 thomas # Checkout should still work; if it does not, then either there is
971 e0220e74 2022-10-31 thomas # a bug or the fixed limit used by this test case is no longer valid
972 61d05f0f 2022-10-31 thomas # and must be raised. Use a subshell to avoid changing global ulimit.
973 4838433d 2023-01-28 thomas (ulimit -n 33; got checkout -q $testroot/repo $testroot/wt \
974 61d05f0f 2022-10-31 thomas > $testroot/stdout)
975 e0220e74 2022-10-31 thomas ret=$?
976 e0220e74 2022-10-31 thomas if [ $ret -ne 0 ]; then
977 e0220e74 2022-10-31 thomas test_done "$testroot" "$ret"
978 e0220e74 2022-10-31 thomas return 1
979 e0220e74 2022-10-31 thomas fi
980 e0220e74 2022-10-31 thomas
981 e0220e74 2022-10-31 thomas cmp -s $testroot/stdout.expected $testroot/stdout
982 e0220e74 2022-10-31 thomas ret=$?
983 e0220e74 2022-10-31 thomas if [ $ret -ne 0 ]; then
984 e0220e74 2022-10-31 thomas diff -u $testroot/stdout.expected $testroot/stdout
985 e0220e74 2022-10-31 thomas test_done "$testroot" "$ret"
986 e0220e74 2022-10-31 thomas return 1
987 e0220e74 2022-10-31 thomas fi
988 e0220e74 2022-10-31 thomas
989 e0220e74 2022-10-31 thomas echo "alpha" > $testroot/content.expected
990 e0220e74 2022-10-31 thomas echo "beta" >> $testroot/content.expected
991 e0220e74 2022-10-31 thomas echo "zeta" >> $testroot/content.expected
992 e0220e74 2022-10-31 thomas echo "delta" >> $testroot/content.expected
993 e0220e74 2022-10-31 thomas cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
994 e0220e74 2022-10-31 thomas $testroot/wt/gamma/delta > $testroot/content
995 e0220e74 2022-10-31 thomas
996 e0220e74 2022-10-31 thomas cmp -s $testroot/content.expected $testroot/content
997 e0220e74 2022-10-31 thomas ret=$?
998 e0220e74 2022-10-31 thomas if [ $ret -ne 0 ]; then
999 e0220e74 2022-10-31 thomas diff -u $testroot/content.expected $testroot/content
1000 fb885120 2023-07-19 thomas fi
1001 fb885120 2023-07-19 thomas test_done "$testroot" "$ret"
1002 fb885120 2023-07-19 thomas }
1003 fb885120 2023-07-19 thomas
1004 fb885120 2023-07-19 thomas test_checkout_commit_keywords() {
1005 fb885120 2023-07-19 thomas local testroot=$(test_init checkout_commit_keywords)
1006 fb885120 2023-07-19 thomas
1007 8642913b 2023-07-26 thomas set -- "$(git_show_head $testroot/repo)"
1008 fb885120 2023-07-19 thomas
1009 fb885120 2023-07-19 thomas got checkout $testroot/repo $testroot/wt > /dev/null
1010 fb885120 2023-07-19 thomas ret=$?
1011 fb885120 2023-07-19 thomas if [ $ret -ne 0 ]; then
1012 fb885120 2023-07-19 thomas echo "checkout failed unexpectedly" >&2
1013 fb885120 2023-07-19 thomas test_done "$testroot" "$ret"
1014 fb885120 2023-07-19 thomas return 1
1015 fb885120 2023-07-19 thomas fi
1016 fb885120 2023-07-19 thomas
1017 fb885120 2023-07-19 thomas for i in $(seq 4); do
1018 fb885120 2023-07-19 thomas echo "zeta change $i" > "$testroot/wt/epsilon/zeta"
1019 fb885120 2023-07-19 thomas
1020 fb885120 2023-07-19 thomas (cd "$testroot/wt" && got ci -m "commit number $i" > /dev/null)
1021 fb885120 2023-07-19 thomas ret=$?
1022 fb885120 2023-07-19 thomas if [ $ret -ne 0 ]; then
1023 fb885120 2023-07-19 thomas echo "commit failed unexpectedly" >&2
1024 fb885120 2023-07-19 thomas test_done "$testroot" "$ret"
1025 fb885120 2023-07-19 thomas return 1
1026 fb885120 2023-07-19 thomas fi
1027 8642913b 2023-07-26 thomas set -- "$@" "$(git_show_head $testroot/repo)"
1028 fb885120 2023-07-19 thomas done
1029 fb885120 2023-07-19 thomas
1030 fb885120 2023-07-19 thomas echo "A $testroot/wt2/alpha" > $testroot/stdout.expected
1031 fb885120 2023-07-19 thomas echo "A $testroot/wt2/beta" >> $testroot/stdout.expected
1032 fb885120 2023-07-19 thomas echo "A $testroot/wt2/epsilon/zeta" >> $testroot/stdout.expected
1033 fb885120 2023-07-19 thomas echo "A $testroot/wt2/gamma/delta" >> $testroot/stdout.expected
1034 8642913b 2023-07-26 thomas echo "Checked out refs/heads/master: $(pop_idx 4 $@)" \
1035 fb885120 2023-07-19 thomas >> $testroot/stdout.expected
1036 fb885120 2023-07-19 thomas echo "Now shut up and hack" >> $testroot/stdout.expected
1037 fb885120 2023-07-19 thomas
1038 fb885120 2023-07-19 thomas got co -c :head:- $testroot/repo $testroot/wt2 > $testroot/stdout
1039 fb885120 2023-07-19 thomas ret=$?
1040 fb885120 2023-07-19 thomas if [ $ret -ne 0 ]; then
1041 fb885120 2023-07-19 thomas test_done "$testroot" "$ret"
1042 fb885120 2023-07-19 thomas return 1
1043 e0220e74 2022-10-31 thomas fi
1044 fb885120 2023-07-19 thomas
1045 fb885120 2023-07-19 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1046 fb885120 2023-07-19 thomas ret=$?
1047 fb885120 2023-07-19 thomas if [ $ret -ne 0 ]; then
1048 fb885120 2023-07-19 thomas diff -u $testroot/stdout.expected $testroot/stdout
1049 fb885120 2023-07-19 thomas test_done "$testroot" "$ret"
1050 fb885120 2023-07-19 thomas return 1
1051 fb885120 2023-07-19 thomas fi
1052 fb885120 2023-07-19 thomas
1053 fb885120 2023-07-19 thomas echo "A $testroot/wt3/alpha" > $testroot/stdout.expected
1054 fb885120 2023-07-19 thomas echo "A $testroot/wt3/beta" >> $testroot/stdout.expected
1055 fb885120 2023-07-19 thomas echo "A $testroot/wt3/epsilon/zeta" >> $testroot/stdout.expected
1056 fb885120 2023-07-19 thomas echo "A $testroot/wt3/gamma/delta" >> $testroot/stdout.expected
1057 8642913b 2023-07-26 thomas echo "Checked out refs/heads/master: $(pop_idx 4 $@)" \
1058 fb885120 2023-07-19 thomas >> $testroot/stdout.expected
1059 fb885120 2023-07-19 thomas echo "Now shut up and hack" >> $testroot/stdout.expected
1060 fb885120 2023-07-19 thomas
1061 fb885120 2023-07-19 thomas got co -bmaster -c:base:- $testroot/repo $testroot/wt3 > \
1062 fb885120 2023-07-19 thomas $testroot/stdout
1063 fb885120 2023-07-19 thomas ret=$?
1064 fb885120 2023-07-19 thomas if [ $ret -ne 0 ]; then
1065 fb885120 2023-07-19 thomas test_done "$testroot" "$ret"
1066 fb885120 2023-07-19 thomas return 1
1067 fb885120 2023-07-19 thomas fi
1068 fb885120 2023-07-19 thomas
1069 fb885120 2023-07-19 thomas cmp -s $testroot/stdout.expected $testroot/stdout
1070 fb885120 2023-07-19 thomas ret=$?
1071 fb885120 2023-07-19 thomas if [ $ret -ne 0 ]; then
1072 fb885120 2023-07-19 thomas diff -u $testroot/stdout.expected $testroot/stdout
1073 fb885120 2023-07-19 thomas fi
1074 fb885120 2023-07-19 thomas
1075 e0220e74 2022-10-31 thomas test_done "$testroot" "$ret"
1076 20b7abb3 2020-10-22 stsp }
1077 20b7abb3 2020-10-22 stsp
1078 7fb414ae 2020-08-08 stsp test_parseargs "$@"
1079 0e673013 2019-01-02 stsp run_test test_checkout_basic
1080 80c1b583 2019-08-07 stsp run_test test_checkout_dir_exists
1081 80c1b583 2019-08-07 stsp run_test test_checkout_dir_not_empty
1082 484d974b 2023-08-29 thomas run_test test_checkout_into_repo
1083 484d974b 2023-08-29 thomas run_test test_checkout_overlap_repo
1084 68ed9ba5 2019-02-10 stsp run_test test_checkout_sets_xbit
1085 45d344f6 2019-05-14 stsp run_test test_checkout_commit_from_wrong_branch
1086 303e2782 2019-08-09 stsp run_test test_checkout_tag
1087 63c5ca5d 2019-08-24 stsp run_test test_checkout_ignores_submodules
1088 7f47418f 2019-12-20 stsp run_test test_checkout_read_only
1089 bb51a5b4 2020-01-13 stsp run_test test_checkout_into_nonempty_dir
1090 8ba819a3 2020-07-23 stsp run_test test_checkout_symlink
1091 7d61d891 2020-07-23 stsp run_test test_checkout_symlink_relative_wtpath
1092 20b7abb3 2020-10-22 stsp run_test test_checkout_repo_with_unknown_extension
1093 67c65ed7 2021-09-14 tracey run_test test_checkout_quiet
1094 a2c162eb 2022-10-30 thomas run_test test_checkout_umask
1095 e0220e74 2022-10-31 thomas run_test test_checkout_ulimit_n
1096 fb885120 2023-07-19 thomas run_test test_checkout_commit_keywords