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 0e673013 2019-01-02 stsp
22 0e673013 2019-01-02 stsp echo "A $testroot/wt/alpha" > $testroot/stdout.expected
23 0e673013 2019-01-02 stsp echo "A $testroot/wt/beta" >> $testroot/stdout.expected
24 0e673013 2019-01-02 stsp echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
25 0e673013 2019-01-02 stsp echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
26 0e673013 2019-01-02 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
27 0e673013 2019-01-02 stsp
28 0e673013 2019-01-02 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
29 e60e7f5b 2019-02-10 stsp ret="$?"
30 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
31 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
32 0e673013 2019-01-02 stsp return 1
33 0e673013 2019-01-02 stsp fi
34 0e673013 2019-01-02 stsp
35 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
36 e60e7f5b 2019-02-10 stsp ret="$?"
37 e60e7f5b 2019-02-10 stsp if [ "$ret" != "0" ]; then
38 0e673013 2019-01-02 stsp diff -u $testroot/stdout.expected $testroot/stdout
39 e60e7f5b 2019-02-10 stsp test_done "$testroot" "$ret"
40 0e673013 2019-01-02 stsp return 1
41 0e673013 2019-01-02 stsp fi
42 0e673013 2019-01-02 stsp
43 0e673013 2019-01-02 stsp echo "alpha" > $testroot/content.expected
44 0e673013 2019-01-02 stsp echo "beta" >> $testroot/content.expected
45 0e673013 2019-01-02 stsp echo "zeta" >> $testroot/content.expected
46 0e673013 2019-01-02 stsp echo "delta" >> $testroot/content.expected
47 0e673013 2019-01-02 stsp cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
48 0e673013 2019-01-02 stsp $testroot/wt/gamma/delta > $testroot/content
49 0e673013 2019-01-02 stsp
50 8d301dd9 2019-05-14 stsp cmp -s $testroot/content.expected $testroot/content
51 693719bc 2019-01-03 stsp ret="$?"
52 693719bc 2019-01-03 stsp if [ "$ret" != "0" ]; then
53 0e673013 2019-01-02 stsp diff -u $testroot/content.expected $testroot/content
54 0e673013 2019-01-02 stsp fi
55 693719bc 2019-01-03 stsp test_done "$testroot" "$ret"
56 0e673013 2019-01-02 stsp }
57 0e673013 2019-01-02 stsp
58 f6cae3ed 2020-09-13 naddy test_checkout_dir_exists() {
59 80c1b583 2019-08-07 stsp local testroot=`test_init checkout_dir_exists`
60 80c1b583 2019-08-07 stsp
61 80c1b583 2019-08-07 stsp echo "A $testroot/wt/alpha" > $testroot/stdout.expected
62 80c1b583 2019-08-07 stsp echo "A $testroot/wt/beta" >> $testroot/stdout.expected
63 80c1b583 2019-08-07 stsp echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
64 80c1b583 2019-08-07 stsp echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
65 80c1b583 2019-08-07 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
66 80c1b583 2019-08-07 stsp
67 80c1b583 2019-08-07 stsp mkdir $testroot/wt
68 80c1b583 2019-08-07 stsp
69 80c1b583 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
70 80c1b583 2019-08-07 stsp ret="$?"
71 80c1b583 2019-08-07 stsp if [ "$ret" != "0" ]; then
72 80c1b583 2019-08-07 stsp test_done "$testroot" "$ret"
73 80c1b583 2019-08-07 stsp return 1
74 80c1b583 2019-08-07 stsp fi
75 80c1b583 2019-08-07 stsp
76 80c1b583 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
77 80c1b583 2019-08-07 stsp ret="$?"
78 80c1b583 2019-08-07 stsp if [ "$ret" != "0" ]; then
79 80c1b583 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
80 80c1b583 2019-08-07 stsp test_done "$testroot" "$ret"
81 80c1b583 2019-08-07 stsp return 1
82 80c1b583 2019-08-07 stsp fi
83 80c1b583 2019-08-07 stsp
84 80c1b583 2019-08-07 stsp echo "alpha" > $testroot/content.expected
85 80c1b583 2019-08-07 stsp echo "beta" >> $testroot/content.expected
86 80c1b583 2019-08-07 stsp echo "zeta" >> $testroot/content.expected
87 80c1b583 2019-08-07 stsp echo "delta" >> $testroot/content.expected
88 80c1b583 2019-08-07 stsp cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
89 80c1b583 2019-08-07 stsp $testroot/wt/gamma/delta > $testroot/content
90 80c1b583 2019-08-07 stsp
91 80c1b583 2019-08-07 stsp cmp -s $testroot/content.expected $testroot/content
92 80c1b583 2019-08-07 stsp ret="$?"
93 80c1b583 2019-08-07 stsp if [ "$ret" != "0" ]; then
94 80c1b583 2019-08-07 stsp diff -u $testroot/content.expected $testroot/content
95 80c1b583 2019-08-07 stsp fi
96 80c1b583 2019-08-07 stsp test_done "$testroot" "$ret"
97 80c1b583 2019-08-07 stsp }
98 80c1b583 2019-08-07 stsp
99 f6cae3ed 2020-09-13 naddy test_checkout_dir_not_empty() {
100 80c1b583 2019-08-07 stsp local testroot=`test_init checkout_dir_not_empty`
101 80c1b583 2019-08-07 stsp
102 80c1b583 2019-08-07 stsp echo "A $testroot/wt/alpha" > $testroot/stdout.expected
103 80c1b583 2019-08-07 stsp echo "A $testroot/wt/beta" >> $testroot/stdout.expected
104 80c1b583 2019-08-07 stsp echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
105 80c1b583 2019-08-07 stsp echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
106 80c1b583 2019-08-07 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
107 80c1b583 2019-08-07 stsp
108 80c1b583 2019-08-07 stsp mkdir $testroot/wt
109 80c1b583 2019-08-07 stsp touch $testroot/wt/foo
110 80c1b583 2019-08-07 stsp
111 80c1b583 2019-08-07 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout \
112 80c1b583 2019-08-07 stsp 2> $testroot/stderr
113 80c1b583 2019-08-07 stsp ret="$?"
114 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
115 80c1b583 2019-08-07 stsp echo "checkout succeeded unexpectedly" >&2
116 80c1b583 2019-08-07 stsp test_done "$testroot" "1"
117 80c1b583 2019-08-07 stsp return 1
118 80c1b583 2019-08-07 stsp fi
119 80c1b583 2019-08-07 stsp
120 80c1b583 2019-08-07 stsp echo "got: $testroot/wt: directory exists and is not empty" \
121 80c1b583 2019-08-07 stsp > $testroot/stderr.expected
122 80c1b583 2019-08-07 stsp cmp -s $testroot/stderr.expected $testroot/stderr
123 80c1b583 2019-08-07 stsp ret="$?"
124 80c1b583 2019-08-07 stsp if [ "$ret" != "0" ]; then
125 80c1b583 2019-08-07 stsp diff -u $testroot/stderr.expected $testroot/stderr
126 80c1b583 2019-08-07 stsp test_done "$testroot" "$ret"
127 80c1b583 2019-08-07 stsp return 1
128 80c1b583 2019-08-07 stsp fi
129 80c1b583 2019-08-07 stsp
130 80c1b583 2019-08-07 stsp echo -n > $testroot/stdout.expected
131 80c1b583 2019-08-07 stsp cmp -s $testroot/stdout.expected $testroot/stdout
132 80c1b583 2019-08-07 stsp ret="$?"
133 80c1b583 2019-08-07 stsp if [ "$ret" != "0" ]; then
134 80c1b583 2019-08-07 stsp diff -u $testroot/stdout.expected $testroot/stdout
135 80c1b583 2019-08-07 stsp fi
136 80c1b583 2019-08-07 stsp test_done "$testroot" "$ret"
137 80c1b583 2019-08-07 stsp
138 80c1b583 2019-08-07 stsp }
139 80c1b583 2019-08-07 stsp
140 f6cae3ed 2020-09-13 naddy test_checkout_sets_xbit() {
141 68ed9ba5 2019-02-10 stsp local testroot=`test_init checkout_sets_xbit 1`
142 68ed9ba5 2019-02-10 stsp
143 68ed9ba5 2019-02-10 stsp touch $testroot/repo/xfile
144 68ed9ba5 2019-02-10 stsp chmod +x $testroot/repo/xfile
145 68ed9ba5 2019-02-10 stsp (cd $testroot/repo && git add .)
146 68ed9ba5 2019-02-10 stsp git_commit $testroot/repo -m "adding executable file"
147 68ed9ba5 2019-02-10 stsp
148 68ed9ba5 2019-02-10 stsp echo "A $testroot/wt/xfile" > $testroot/stdout.expected
149 68ed9ba5 2019-02-10 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
150 68ed9ba5 2019-02-10 stsp
151 68ed9ba5 2019-02-10 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
152 68ed9ba5 2019-02-10 stsp ret="$?"
153 68ed9ba5 2019-02-10 stsp if [ "$ret" != "0" ]; then
154 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
155 68ed9ba5 2019-02-10 stsp return 1
156 68ed9ba5 2019-02-10 stsp fi
157 68ed9ba5 2019-02-10 stsp
158 8d301dd9 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
159 68ed9ba5 2019-02-10 stsp ret="$?"
160 68ed9ba5 2019-02-10 stsp if [ "$ret" != "0" ]; then
161 68ed9ba5 2019-02-10 stsp diff -u $testroot/stdout.expected $testroot/stdout
162 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
163 68ed9ba5 2019-02-10 stsp return 1
164 68ed9ba5 2019-02-10 stsp fi
165 68ed9ba5 2019-02-10 stsp
166 68ed9ba5 2019-02-10 stsp ls -l $testroot/wt/xfile | grep -q '^-rwx'
167 68ed9ba5 2019-02-10 stsp ret="$?"
168 68ed9ba5 2019-02-10 stsp if [ "$ret" != "0" ]; then
169 68ed9ba5 2019-02-10 stsp echo "file is not executable" >&2
170 68ed9ba5 2019-02-10 stsp ls -l $testroot/wt/xfile >&2
171 68ed9ba5 2019-02-10 stsp fi
172 68ed9ba5 2019-02-10 stsp test_done "$testroot" "$ret"
173 68ed9ba5 2019-02-10 stsp }
174 68ed9ba5 2019-02-10 stsp
175 f6cae3ed 2020-09-13 naddy test_checkout_commit_from_wrong_branch() {
176 45d344f6 2019-05-14 stsp local testroot=`test_init checkout_commit_from_wrong_branch`
177 45d344f6 2019-05-14 stsp
178 45d344f6 2019-05-14 stsp (cd $testroot/repo && git checkout -q -b newbranch)
179 45d344f6 2019-05-14 stsp echo "modified alpha on new branch" > $testroot/repo/alpha
180 45d344f6 2019-05-14 stsp git_commit $testroot/repo -m "modified alpha on new branch"
181 45d344f6 2019-05-14 stsp
182 45d344f6 2019-05-14 stsp local head_rev=`git_show_head $testroot/repo`
183 45d344f6 2019-05-14 stsp got checkout -b master -c $head_rev $testroot/repo $testroot/wt \
184 45d344f6 2019-05-14 stsp > $testroot/stdout 2> $testroot/stderr
185 45d344f6 2019-05-14 stsp ret="$?"
186 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
187 45d344f6 2019-05-14 stsp test_done "$testroot" "1"
188 45d344f6 2019-05-14 stsp return 1
189 45d344f6 2019-05-14 stsp fi
190 45d344f6 2019-05-14 stsp
191 45d344f6 2019-05-14 stsp echo -n "" > $testroot/stdout.expected
192 45d344f6 2019-05-14 stsp cmp -s $testroot/stdout.expected $testroot/stdout
193 45d344f6 2019-05-14 stsp ret="$?"
194 45d344f6 2019-05-14 stsp if [ "$ret" != "0" ]; then
195 45d344f6 2019-05-14 stsp diff -u $testroot/stdout.expected $testroot/stdout
196 45d344f6 2019-05-14 stsp test_done "$testroot" "$ret"
197 45d344f6 2019-05-14 stsp return 1
198 45d344f6 2019-05-14 stsp fi
199 45d344f6 2019-05-14 stsp
200 4b6c9460 2020-03-05 stsp echo -n "got: target commit is not contained in branch 'master'; " \
201 45d344f6 2019-05-14 stsp > $testroot/stderr.expected
202 4b6c9460 2020-03-05 stsp echo -n "the branch to use must be specified with -b; if necessary " \
203 4b6c9460 2020-03-05 stsp >> $testroot/stderr.expected
204 4b6c9460 2020-03-05 stsp echo -n "a new branch can be created for this commit with "\
205 4b6c9460 2020-03-05 stsp >> $testroot/stderr.expected
206 4b6c9460 2020-03-05 stsp echo "'got branch -c $head_rev BRANCH_NAME'" \
207 4b6c9460 2020-03-05 stsp >> $testroot/stderr.expected
208 45d344f6 2019-05-14 stsp cmp -s $testroot/stderr.expected $testroot/stderr
209 45d344f6 2019-05-14 stsp ret="$?"
210 45d344f6 2019-05-14 stsp if [ "$ret" != "0" ]; then
211 45d344f6 2019-05-14 stsp diff -u $testroot/stderr.expected $testroot/stderr
212 45d344f6 2019-05-14 stsp test_done "$testroot" "$ret"
213 45d344f6 2019-05-14 stsp return 1
214 45d344f6 2019-05-14 stsp fi
215 45d344f6 2019-05-14 stsp
216 45d344f6 2019-05-14 stsp test_done "$testroot" "$ret"
217 45d344f6 2019-05-14 stsp }
218 45d344f6 2019-05-14 stsp
219 f6cae3ed 2020-09-13 naddy test_checkout_tag() {
220 303e2782 2019-08-09 stsp local testroot=`test_init checkout_tag`
221 303e2782 2019-08-09 stsp local tag="1.0.0"
222 303e2782 2019-08-09 stsp
223 303e2782 2019-08-09 stsp (cd $testroot/repo && git tag -a -m "test" $tag)
224 303e2782 2019-08-09 stsp
225 303e2782 2019-08-09 stsp echo "A $testroot/wt/alpha" > $testroot/stdout.expected
226 303e2782 2019-08-09 stsp echo "A $testroot/wt/beta" >> $testroot/stdout.expected
227 303e2782 2019-08-09 stsp echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
228 303e2782 2019-08-09 stsp echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
229 303e2782 2019-08-09 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
230 303e2782 2019-08-09 stsp
231 303e2782 2019-08-09 stsp got checkout -c $tag $testroot/repo $testroot/wt > $testroot/stdout
232 303e2782 2019-08-09 stsp ret="$?"
233 303e2782 2019-08-09 stsp if [ "$ret" != "0" ]; then
234 303e2782 2019-08-09 stsp test_done "$testroot" "$ret"
235 303e2782 2019-08-09 stsp return 1
236 303e2782 2019-08-09 stsp fi
237 303e2782 2019-08-09 stsp
238 303e2782 2019-08-09 stsp cmp -s $testroot/stdout.expected $testroot/stdout
239 303e2782 2019-08-09 stsp ret="$?"
240 303e2782 2019-08-09 stsp if [ "$ret" != "0" ]; then
241 303e2782 2019-08-09 stsp diff -u $testroot/stdout.expected $testroot/stdout
242 303e2782 2019-08-09 stsp test_done "$testroot" "$ret"
243 303e2782 2019-08-09 stsp return 1
244 303e2782 2019-08-09 stsp fi
245 303e2782 2019-08-09 stsp
246 303e2782 2019-08-09 stsp echo "alpha" > $testroot/content.expected
247 303e2782 2019-08-09 stsp echo "beta" >> $testroot/content.expected
248 303e2782 2019-08-09 stsp echo "zeta" >> $testroot/content.expected
249 303e2782 2019-08-09 stsp echo "delta" >> $testroot/content.expected
250 303e2782 2019-08-09 stsp cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
251 303e2782 2019-08-09 stsp $testroot/wt/gamma/delta > $testroot/content
252 303e2782 2019-08-09 stsp
253 303e2782 2019-08-09 stsp cmp -s $testroot/content.expected $testroot/content
254 303e2782 2019-08-09 stsp ret="$?"
255 303e2782 2019-08-09 stsp if [ "$ret" != "0" ]; then
256 303e2782 2019-08-09 stsp diff -u $testroot/content.expected $testroot/content
257 303e2782 2019-08-09 stsp fi
258 303e2782 2019-08-09 stsp test_done "$testroot" "$ret"
259 303e2782 2019-08-09 stsp }
260 63c5ca5d 2019-08-24 stsp
261 f6cae3ed 2020-09-13 naddy test_checkout_ignores_submodules() {
262 63c5ca5d 2019-08-24 stsp local testroot=`test_init checkout_ignores_submodules`
263 63c5ca5d 2019-08-24 stsp
264 e7303626 2020-05-14 stsp make_single_file_repo $testroot/repo2 foo
265 e7303626 2020-05-14 stsp
266 63c5ca5d 2019-08-24 stsp (cd $testroot/repo && git submodule -q add ../repo2)
267 63c5ca5d 2019-08-24 stsp (cd $testroot/repo && git commit -q -m 'adding submodule')
268 63c5ca5d 2019-08-24 stsp
269 63c5ca5d 2019-08-24 stsp echo "A $testroot/wt/.gitmodules" > $testroot/stdout.expected
270 63c5ca5d 2019-08-24 stsp echo "A $testroot/wt/alpha" >> $testroot/stdout.expected
271 63c5ca5d 2019-08-24 stsp echo "A $testroot/wt/beta" >> $testroot/stdout.expected
272 63c5ca5d 2019-08-24 stsp echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
273 63c5ca5d 2019-08-24 stsp echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
274 63c5ca5d 2019-08-24 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
275 303e2782 2019-08-09 stsp
276 63c5ca5d 2019-08-24 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
277 63c5ca5d 2019-08-24 stsp ret="$?"
278 63c5ca5d 2019-08-24 stsp if [ "$ret" != "0" ]; then
279 63c5ca5d 2019-08-24 stsp test_done "$testroot" "$ret"
280 63c5ca5d 2019-08-24 stsp return 1
281 63c5ca5d 2019-08-24 stsp fi
282 63c5ca5d 2019-08-24 stsp
283 63c5ca5d 2019-08-24 stsp cmp -s $testroot/stdout.expected $testroot/stdout
284 63c5ca5d 2019-08-24 stsp ret="$?"
285 63c5ca5d 2019-08-24 stsp if [ "$ret" != "0" ]; then
286 63c5ca5d 2019-08-24 stsp diff -u $testroot/stdout.expected $testroot/stdout
287 63c5ca5d 2019-08-24 stsp test_done "$testroot" "$ret"
288 63c5ca5d 2019-08-24 stsp return 1
289 63c5ca5d 2019-08-24 stsp fi
290 63c5ca5d 2019-08-24 stsp
291 63c5ca5d 2019-08-24 stsp echo "alpha" > $testroot/content.expected
292 63c5ca5d 2019-08-24 stsp echo "beta" >> $testroot/content.expected
293 63c5ca5d 2019-08-24 stsp echo "zeta" >> $testroot/content.expected
294 63c5ca5d 2019-08-24 stsp echo "delta" >> $testroot/content.expected
295 63c5ca5d 2019-08-24 stsp cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
296 63c5ca5d 2019-08-24 stsp $testroot/wt/gamma/delta > $testroot/content
297 63c5ca5d 2019-08-24 stsp
298 63c5ca5d 2019-08-24 stsp cmp -s $testroot/content.expected $testroot/content
299 63c5ca5d 2019-08-24 stsp ret="$?"
300 63c5ca5d 2019-08-24 stsp if [ "$ret" != "0" ]; then
301 63c5ca5d 2019-08-24 stsp diff -u $testroot/content.expected $testroot/content
302 63c5ca5d 2019-08-24 stsp fi
303 63c5ca5d 2019-08-24 stsp test_done "$testroot" "$ret"
304 63c5ca5d 2019-08-24 stsp }
305 7f47418f 2019-12-20 stsp
306 f6cae3ed 2020-09-13 naddy test_checkout_read_only() {
307 7f47418f 2019-12-20 stsp local testroot=`test_init checkout_read_only`
308 7f47418f 2019-12-20 stsp
309 7f47418f 2019-12-20 stsp # Make the repostiory read-only
310 7f47418f 2019-12-20 stsp chmod -R a-w $testroot/repo
311 7f47418f 2019-12-20 stsp
312 7f47418f 2019-12-20 stsp echo "A $testroot/wt/alpha" > $testroot/stdout.expected
313 7f47418f 2019-12-20 stsp echo "A $testroot/wt/beta" >> $testroot/stdout.expected
314 7f47418f 2019-12-20 stsp echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
315 7f47418f 2019-12-20 stsp echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
316 7f47418f 2019-12-20 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
317 7f47418f 2019-12-20 stsp
318 7f47418f 2019-12-20 stsp got checkout $testroot/repo $testroot/wt \
319 7f47418f 2019-12-20 stsp > $testroot/stdout 2> $testroot/stderr
320 7f47418f 2019-12-20 stsp ret="$?"
321 7f47418f 2019-12-20 stsp if [ "$ret" != "0" ]; then
322 7f47418f 2019-12-20 stsp test_done "$testroot" "$ret"
323 7f47418f 2019-12-20 stsp return 1
324 7f47418f 2019-12-20 stsp fi
325 63c5ca5d 2019-08-24 stsp
326 7f47418f 2019-12-20 stsp cmp -s $testroot/stdout.expected $testroot/stdout
327 7f47418f 2019-12-20 stsp ret="$?"
328 7f47418f 2019-12-20 stsp if [ "$ret" != "0" ]; then
329 7f47418f 2019-12-20 stsp diff -u $testroot/stdout.expected $testroot/stdout
330 7f47418f 2019-12-20 stsp test_done "$testroot" "$ret"
331 7f47418f 2019-12-20 stsp return 1
332 7f47418f 2019-12-20 stsp fi
333 7f47418f 2019-12-20 stsp
334 7f47418f 2019-12-20 stsp echo -n "got: warning: could not create a reference " \
335 7f47418f 2019-12-20 stsp > $testroot/stderr.expected
336 7f47418f 2019-12-20 stsp echo -n "to the work tree's base commit; the commit could " \
337 7f47418f 2019-12-20 stsp >> $testroot/stderr.expected
338 e6786710 2021-07-03 stsp echo -n "be garbage-collected by Git or 'gotadmin cleanup'; " \
339 7f47418f 2019-12-20 stsp >> $testroot/stderr.expected
340 e6786710 2021-07-03 stsp echo -n "making the repository " >> $testroot/stderr.expected
341 7f47418f 2019-12-20 stsp echo "writable and running 'got update' will prevent this" \
342 7f47418f 2019-12-20 stsp >> $testroot/stderr.expected
343 7f47418f 2019-12-20 stsp cmp -s $testroot/stderr.expected $testroot/stderr
344 7f47418f 2019-12-20 stsp ret="$?"
345 7f47418f 2019-12-20 stsp if [ "$ret" != "0" ]; then
346 7f47418f 2019-12-20 stsp diff -u $testroot/stderr.expected $testroot/stderr
347 7f47418f 2019-12-20 stsp test_done "$testroot" "$ret"
348 7f47418f 2019-12-20 stsp return 1
349 7f47418f 2019-12-20 stsp fi
350 7f47418f 2019-12-20 stsp
351 7f47418f 2019-12-20 stsp echo "alpha" > $testroot/content.expected
352 7f47418f 2019-12-20 stsp echo "beta" >> $testroot/content.expected
353 7f47418f 2019-12-20 stsp echo "zeta" >> $testroot/content.expected
354 7f47418f 2019-12-20 stsp echo "delta" >> $testroot/content.expected
355 7f47418f 2019-12-20 stsp cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
356 7f47418f 2019-12-20 stsp $testroot/wt/gamma/delta > $testroot/content
357 7f47418f 2019-12-20 stsp
358 7f47418f 2019-12-20 stsp cmp -s $testroot/content.expected $testroot/content
359 7f47418f 2019-12-20 stsp ret="$?"
360 7f47418f 2019-12-20 stsp if [ "$ret" != "0" ]; then
361 7f47418f 2019-12-20 stsp diff -u $testroot/content.expected $testroot/content
362 7f47418f 2019-12-20 stsp fi
363 7f47418f 2019-12-20 stsp chmod -R u+w $testroot/repo # make repo cleanup work
364 7f47418f 2019-12-20 stsp test_done "$testroot" "$ret"
365 7f47418f 2019-12-20 stsp }
366 bb51a5b4 2020-01-13 stsp
367 f6cae3ed 2020-09-13 naddy test_checkout_into_nonempty_dir() {
368 bb51a5b4 2020-01-13 stsp local testroot=`test_init checkout_into_nonempty_dir`
369 bb51a5b4 2020-01-13 stsp
370 bb51a5b4 2020-01-13 stsp mkdir -p $testroot/wt
371 bb51a5b4 2020-01-13 stsp make_test_tree $testroot/wt
372 bb51a5b4 2020-01-13 stsp
373 bb51a5b4 2020-01-13 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout \
374 bb51a5b4 2020-01-13 stsp 2> $testroot/stderr
375 bb51a5b4 2020-01-13 stsp ret="$?"
376 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
377 bb51a5b4 2020-01-13 stsp echo "checkout succeeded unexpectedly" >&2
378 bb51a5b4 2020-01-13 stsp test_done "$testroot" "1"
379 bb51a5b4 2020-01-13 stsp return 1
380 bb51a5b4 2020-01-13 stsp fi
381 bb51a5b4 2020-01-13 stsp
382 bb51a5b4 2020-01-13 stsp echo -n > $testroot/stdout.expected
383 bb51a5b4 2020-01-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
384 bb51a5b4 2020-01-13 stsp ret="$?"
385 bb51a5b4 2020-01-13 stsp if [ "$ret" != "0" ]; then
386 bb51a5b4 2020-01-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
387 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
388 bb51a5b4 2020-01-13 stsp return 1
389 bb51a5b4 2020-01-13 stsp fi
390 bb51a5b4 2020-01-13 stsp
391 bb51a5b4 2020-01-13 stsp echo "got: $testroot/wt: directory exists and is not empty" \
392 bb51a5b4 2020-01-13 stsp > $testroot/stderr.expected
393 bb51a5b4 2020-01-13 stsp cmp -s $testroot/stderr.expected $testroot/stderr
394 bb51a5b4 2020-01-13 stsp ret="$?"
395 bb51a5b4 2020-01-13 stsp if [ "$ret" != "0" ]; then
396 bb51a5b4 2020-01-13 stsp diff -u $testroot/stderr.expected $testroot/stderr
397 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
398 bb51a5b4 2020-01-13 stsp return 1
399 bb51a5b4 2020-01-13 stsp fi
400 bb51a5b4 2020-01-13 stsp
401 3b9f0f87 2020-07-23 stsp echo "? $testroot/wt/alpha" > $testroot/stdout.expected
402 3b9f0f87 2020-07-23 stsp echo "? $testroot/wt/beta" >> $testroot/stdout.expected
403 3b9f0f87 2020-07-23 stsp echo "? $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
404 3b9f0f87 2020-07-23 stsp echo "? $testroot/wt/gamma/delta" >> $testroot/stdout.expected
405 bb51a5b4 2020-01-13 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
406 7f47418f 2019-12-20 stsp
407 bb51a5b4 2020-01-13 stsp got checkout -E $testroot/repo $testroot/wt > $testroot/stdout
408 bb51a5b4 2020-01-13 stsp ret="$?"
409 bb51a5b4 2020-01-13 stsp if [ "$ret" != "0" ]; then
410 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
411 bb51a5b4 2020-01-13 stsp return 1
412 bb51a5b4 2020-01-13 stsp fi
413 bb51a5b4 2020-01-13 stsp
414 bb51a5b4 2020-01-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
415 bb51a5b4 2020-01-13 stsp ret="$?"
416 bb51a5b4 2020-01-13 stsp if [ "$ret" != "0" ]; then
417 bb51a5b4 2020-01-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
418 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
419 bb51a5b4 2020-01-13 stsp return 1
420 bb51a5b4 2020-01-13 stsp fi
421 bb51a5b4 2020-01-13 stsp
422 bb51a5b4 2020-01-13 stsp echo "E $testroot/wt/alpha" > $testroot/stdout.expected
423 bb51a5b4 2020-01-13 stsp echo "E $testroot/wt/beta" >> $testroot/stdout.expected
424 bb51a5b4 2020-01-13 stsp echo "E $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
425 bb51a5b4 2020-01-13 stsp echo "E $testroot/wt/gamma/delta" >> $testroot/stdout.expected
426 bb51a5b4 2020-01-13 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
427 bb51a5b4 2020-01-13 stsp
428 bb51a5b4 2020-01-13 stsp got checkout -E $testroot/repo $testroot/wt > $testroot/stdout
429 bb51a5b4 2020-01-13 stsp ret="$?"
430 bb51a5b4 2020-01-13 stsp if [ "$ret" != "0" ]; then
431 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
432 bb51a5b4 2020-01-13 stsp return 1
433 bb51a5b4 2020-01-13 stsp fi
434 bb51a5b4 2020-01-13 stsp
435 bb51a5b4 2020-01-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
436 bb51a5b4 2020-01-13 stsp ret="$?"
437 bb51a5b4 2020-01-13 stsp if [ "$ret" != "0" ]; then
438 bb51a5b4 2020-01-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
439 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
440 bb51a5b4 2020-01-13 stsp return 1
441 bb51a5b4 2020-01-13 stsp fi
442 bb51a5b4 2020-01-13 stsp
443 bb51a5b4 2020-01-13 stsp echo "alpha" > $testroot/content.expected
444 bb51a5b4 2020-01-13 stsp echo "beta" >> $testroot/content.expected
445 bb51a5b4 2020-01-13 stsp echo "zeta" >> $testroot/content.expected
446 bb51a5b4 2020-01-13 stsp echo "delta" >> $testroot/content.expected
447 bb51a5b4 2020-01-13 stsp cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
448 bb51a5b4 2020-01-13 stsp $testroot/wt/gamma/delta > $testroot/content
449 bb51a5b4 2020-01-13 stsp
450 bb51a5b4 2020-01-13 stsp cmp -s $testroot/content.expected $testroot/content
451 bb51a5b4 2020-01-13 stsp ret="$?"
452 bb51a5b4 2020-01-13 stsp if [ "$ret" != "0" ]; then
453 bb51a5b4 2020-01-13 stsp diff -u $testroot/content.expected $testroot/content
454 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
455 bb51a5b4 2020-01-13 stsp return 1
456 bb51a5b4 2020-01-13 stsp fi
457 bb51a5b4 2020-01-13 stsp
458 bb51a5b4 2020-01-13 stsp echo "modified alpha" > $testroot/wt/alpha
459 bb51a5b4 2020-01-13 stsp
460 bb51a5b4 2020-01-13 stsp echo "E $testroot/wt/alpha" > $testroot/stdout.expected
461 bb51a5b4 2020-01-13 stsp echo "E $testroot/wt/beta" >> $testroot/stdout.expected
462 bb51a5b4 2020-01-13 stsp echo "E $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
463 bb51a5b4 2020-01-13 stsp echo "E $testroot/wt/gamma/delta" >> $testroot/stdout.expected
464 bb51a5b4 2020-01-13 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
465 bb51a5b4 2020-01-13 stsp
466 bb51a5b4 2020-01-13 stsp got checkout -E $testroot/repo $testroot/wt > $testroot/stdout
467 bb51a5b4 2020-01-13 stsp ret="$?"
468 bb51a5b4 2020-01-13 stsp if [ "$ret" != "0" ]; then
469 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
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 cmp -s $testroot/stdout.expected $testroot/stdout
474 bb51a5b4 2020-01-13 stsp ret="$?"
475 bb51a5b4 2020-01-13 stsp if [ "$ret" != "0" ]; then
476 bb51a5b4 2020-01-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
477 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
478 bb51a5b4 2020-01-13 stsp return 1
479 bb51a5b4 2020-01-13 stsp fi
480 bb51a5b4 2020-01-13 stsp
481 bb51a5b4 2020-01-13 stsp echo "modified alpha" > $testroot/content.expected
482 bb51a5b4 2020-01-13 stsp echo "beta" >> $testroot/content.expected
483 bb51a5b4 2020-01-13 stsp echo "zeta" >> $testroot/content.expected
484 bb51a5b4 2020-01-13 stsp echo "delta" >> $testroot/content.expected
485 bb51a5b4 2020-01-13 stsp cat $testroot/wt/alpha $testroot/wt/beta $testroot/wt/epsilon/zeta \
486 bb51a5b4 2020-01-13 stsp $testroot/wt/gamma/delta > $testroot/content
487 bb51a5b4 2020-01-13 stsp
488 bb51a5b4 2020-01-13 stsp cmp -s $testroot/content.expected $testroot/content
489 bb51a5b4 2020-01-13 stsp ret="$?"
490 bb51a5b4 2020-01-13 stsp if [ "$ret" != "0" ]; then
491 bb51a5b4 2020-01-13 stsp diff -u $testroot/content.expected $testroot/content
492 bb51a5b4 2020-01-13 stsp test_done "$testroot" "$ret"
493 4da1bbe9 2020-07-19 stsp return 1
494 bb51a5b4 2020-01-13 stsp fi
495 bb51a5b4 2020-01-13 stsp
496 bb51a5b4 2020-01-13 stsp echo 'M alpha' > $testroot/stdout.expected
497 bb51a5b4 2020-01-13 stsp (cd $testroot/wt && got status > $testroot/stdout)
498 8ba819a3 2020-07-23 stsp
499 8ba819a3 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
500 8ba819a3 2020-07-23 stsp ret="$?"
501 8ba819a3 2020-07-23 stsp if [ "$ret" != "0" ]; then
502 8ba819a3 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
503 8ba819a3 2020-07-23 stsp fi
504 8ba819a3 2020-07-23 stsp test_done "$testroot" "$ret"
505 8ba819a3 2020-07-23 stsp }
506 8ba819a3 2020-07-23 stsp
507 f6cae3ed 2020-09-13 naddy test_checkout_symlink() {
508 8ba819a3 2020-07-23 stsp local testroot=`test_init checkout_symlink`
509 8ba819a3 2020-07-23 stsp
510 8ba819a3 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
511 8ba819a3 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
512 8ba819a3 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
513 b7422a2f 2020-07-23 stsp (cd $testroot/repo && ln -s passwd.link passwd2.link)
514 0ab20ee9 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
515 0ab20ee9 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
516 906c123b 2020-07-23 stsp (cd $testroot/repo && ln -s .got/foo dotgotfoo.link)
517 8ba819a3 2020-07-23 stsp (cd $testroot/repo && git add .)
518 0ab20ee9 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
519 8ba819a3 2020-07-23 stsp
520 b7422a2f 2020-07-23 stsp got checkout $testroot/repo $testroot/wt > $testroot/stdout
521 8ba819a3 2020-07-23 stsp ret="$?"
522 8ba819a3 2020-07-23 stsp if [ "$ret" != "0" ]; then
523 b7422a2f 2020-07-23 stsp echo "got checkout failed unexpectedly" >&2
524 8ba819a3 2020-07-23 stsp test_done "$testroot" "$ret"
525 8ba819a3 2020-07-23 stsp return 1
526 8ba819a3 2020-07-23 stsp fi
527 b7422a2f 2020-07-23 stsp
528 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/alpha" > $testroot/stdout.expected
529 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/alpha.link" >> $testroot/stdout.expected
530 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/beta" >> $testroot/stdout.expected
531 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/dotgotfoo.link" >> $testroot/stdout.expected
532 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/epsilon/beta.link" >> $testroot/stdout.expected
533 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/epsilon/zeta" >> $testroot/stdout.expected
534 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/epsilon.link" >> $testroot/stdout.expected
535 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/gamma/delta" >> $testroot/stdout.expected
536 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/nonexistent.link" >> $testroot/stdout.expected
537 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/passwd.link" >> $testroot/stdout.expected
538 b7422a2f 2020-07-23 stsp echo "A $testroot/wt/passwd2.link" >> $testroot/stdout.expected
539 b7422a2f 2020-07-23 stsp echo "Now shut up and hack" >> $testroot/stdout.expected
540 8ba819a3 2020-07-23 stsp
541 b7422a2f 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
542 b7422a2f 2020-07-23 stsp ret="$?"
543 b7422a2f 2020-07-23 stsp if [ "$ret" != "0" ]; then
544 b7422a2f 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
545 b7422a2f 2020-07-23 stsp test_done "$testroot" "$ret"
546 b7422a2f 2020-07-23 stsp return 1
547 b7422a2f 2020-07-23 stsp fi
548 b7422a2f 2020-07-23 stsp
549 8ba819a3 2020-07-23 stsp if ! [ -h $testroot/wt/alpha.link ]; then
550 8ba819a3 2020-07-23 stsp echo "alpha.link is not a symlink"
551 8ba819a3 2020-07-23 stsp test_done "$testroot" "1"
552 8ba819a3 2020-07-23 stsp return 1
553 8ba819a3 2020-07-23 stsp fi
554 8ba819a3 2020-07-23 stsp
555 8ba819a3 2020-07-23 stsp readlink $testroot/wt/alpha.link > $testroot/stdout
556 8ba819a3 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
557 8ba819a3 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
558 8ba819a3 2020-07-23 stsp ret="$?"
559 8ba819a3 2020-07-23 stsp if [ "$ret" != "0" ]; then
560 8ba819a3 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
561 8ba819a3 2020-07-23 stsp test_done "$testroot" "$ret"
562 8ba819a3 2020-07-23 stsp return 1
563 8ba819a3 2020-07-23 stsp fi
564 bb51a5b4 2020-01-13 stsp
565 8ba819a3 2020-07-23 stsp if ! [ -h $testroot/wt/epsilon.link ]; then
566 8ba819a3 2020-07-23 stsp echo "epsilon.link is not a symlink"
567 8ba819a3 2020-07-23 stsp test_done "$testroot" "1"
568 8ba819a3 2020-07-23 stsp return 1
569 8ba819a3 2020-07-23 stsp fi
570 8ba819a3 2020-07-23 stsp
571 8ba819a3 2020-07-23 stsp readlink $testroot/wt/epsilon.link > $testroot/stdout
572 8ba819a3 2020-07-23 stsp echo "epsilon" > $testroot/stdout.expected
573 bb51a5b4 2020-01-13 stsp cmp -s $testroot/stdout.expected $testroot/stdout
574 bb51a5b4 2020-01-13 stsp ret="$?"
575 bb51a5b4 2020-01-13 stsp if [ "$ret" != "0" ]; then
576 bb51a5b4 2020-01-13 stsp diff -u $testroot/stdout.expected $testroot/stdout
577 8ba819a3 2020-07-23 stsp test_done "$testroot" "$ret"
578 8ba819a3 2020-07-23 stsp return 1
579 bb51a5b4 2020-01-13 stsp fi
580 8ba819a3 2020-07-23 stsp
581 8ba819a3 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
582 8ba819a3 2020-07-23 stsp echo -n "passwd.link symlink points outside of work tree: " >&2
583 8ba819a3 2020-07-23 stsp readlink $testroot/wt/passwd.link >&2
584 8ba819a3 2020-07-23 stsp test_done "$testroot" "1"
585 8ba819a3 2020-07-23 stsp return 1
586 8ba819a3 2020-07-23 stsp fi
587 8ba819a3 2020-07-23 stsp
588 8ba819a3 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
589 8ba819a3 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
590 8ba819a3 2020-07-23 stsp
591 8ba819a3 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
592 8ba819a3 2020-07-23 stsp ret="$?"
593 8ba819a3 2020-07-23 stsp if [ "$ret" != "0" ]; then
594 8ba819a3 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
595 0ab20ee9 2020-07-23 stsp test_done "$testroot" "$ret"
596 0ab20ee9 2020-07-23 stsp return 1
597 0ab20ee9 2020-07-23 stsp fi
598 8ba819a3 2020-07-23 stsp
599 b7422a2f 2020-07-23 stsp if ! [ -h $testroot/wt/passwd2.link ]; then
600 b7422a2f 2020-07-23 stsp echo "passwd2.link is not a symlink"
601 b7422a2f 2020-07-23 stsp test_done "$testroot" "1"
602 b7422a2f 2020-07-23 stsp return 1
603 b7422a2f 2020-07-23 stsp fi
604 b7422a2f 2020-07-23 stsp
605 b7422a2f 2020-07-23 stsp readlink $testroot/wt/passwd2.link > $testroot/stdout
606 b7422a2f 2020-07-23 stsp echo "passwd.link" > $testroot/stdout.expected
607 b7422a2f 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
608 b7422a2f 2020-07-23 stsp ret="$?"
609 b7422a2f 2020-07-23 stsp if [ "$ret" != "0" ]; then
610 b7422a2f 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
611 b7422a2f 2020-07-23 stsp test_done "$testroot" "$ret"
612 b7422a2f 2020-07-23 stsp return 1
613 b7422a2f 2020-07-23 stsp fi
614 b7422a2f 2020-07-23 stsp
615 0ab20ee9 2020-07-23 stsp readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
616 0ab20ee9 2020-07-23 stsp echo "../beta" > $testroot/stdout.expected
617 0ab20ee9 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
618 0ab20ee9 2020-07-23 stsp ret="$?"
619 0ab20ee9 2020-07-23 stsp if [ "$ret" != "0" ]; then
620 0ab20ee9 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
621 0ab20ee9 2020-07-23 stsp test_done "$testroot" "$ret"
622 0ab20ee9 2020-07-23 stsp return 1
623 0ab20ee9 2020-07-23 stsp fi
624 0ab20ee9 2020-07-23 stsp
625 0ab20ee9 2020-07-23 stsp readlink $testroot/wt/nonexistent.link > $testroot/stdout
626 0ab20ee9 2020-07-23 stsp echo "nonexistent" > $testroot/stdout.expected
627 0ab20ee9 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
628 0ab20ee9 2020-07-23 stsp ret="$?"
629 0ab20ee9 2020-07-23 stsp if [ "$ret" != "0" ]; then
630 0ab20ee9 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
631 906c123b 2020-07-23 stsp test_done "$testroot" "$ret"
632 41806587 2020-07-23 stsp return 1
633 906c123b 2020-07-23 stsp fi
634 906c123b 2020-07-23 stsp
635 906c123b 2020-07-23 stsp if [ -h $testroot/wt/dotgotfoo.link ]; then
636 906c123b 2020-07-23 stsp echo -n "dotgotfoo.link symlink points into .got dir: " >&2
637 906c123b 2020-07-23 stsp readlink $testroot/wt/dotgotfoo.link >&2
638 906c123b 2020-07-23 stsp test_done "$testroot" "1"
639 906c123b 2020-07-23 stsp return 1
640 906c123b 2020-07-23 stsp fi
641 906c123b 2020-07-23 stsp
642 906c123b 2020-07-23 stsp echo -n ".got/foo" > $testroot/content.expected
643 906c123b 2020-07-23 stsp cp $testroot/wt/dotgotfoo.link $testroot/content
644 906c123b 2020-07-23 stsp
645 906c123b 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
646 906c123b 2020-07-23 stsp ret="$?"
647 906c123b 2020-07-23 stsp if [ "$ret" != "0" ]; then
648 906c123b 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
649 0ab20ee9 2020-07-23 stsp fi
650 0ab20ee9 2020-07-23 stsp test_done "$testroot" "$ret"
651 bb51a5b4 2020-01-13 stsp }
652 7d61d891 2020-07-23 stsp
653 f6cae3ed 2020-09-13 naddy test_checkout_symlink_relative_wtpath() {
654 7d61d891 2020-07-23 stsp local testroot=`test_init checkout_symlink_with_wtpath`
655 7d61d891 2020-07-23 stsp
656 7d61d891 2020-07-23 stsp (cd $testroot/repo && ln -s alpha alpha.link)
657 7d61d891 2020-07-23 stsp (cd $testroot/repo && ln -s epsilon epsilon.link)
658 7d61d891 2020-07-23 stsp (cd $testroot/repo && ln -s /etc/passwd passwd.link)
659 7d61d891 2020-07-23 stsp (cd $testroot/repo && ln -s ../beta epsilon/beta.link)
660 7d61d891 2020-07-23 stsp (cd $testroot/repo && ln -s nonexistent nonexistent.link)
661 7d61d891 2020-07-23 stsp (cd $testroot/repo && ln -s .got/foo dotgotfoo.link)
662 7d61d891 2020-07-23 stsp (cd $testroot/repo && git add .)
663 7d61d891 2020-07-23 stsp git_commit $testroot/repo -m "add symlinks"
664 7d61d891 2020-07-23 stsp
665 7d61d891 2020-07-23 stsp (cd $testroot && got checkout $testroot/repo wt > /dev/null)
666 7d61d891 2020-07-23 stsp ret="$?"
667 7d61d891 2020-07-23 stsp if [ "$ret" != "0" ]; then
668 7d61d891 2020-07-23 stsp test_done "$testroot" "$ret"
669 7d61d891 2020-07-23 stsp return 1
670 7d61d891 2020-07-23 stsp fi
671 bb51a5b4 2020-01-13 stsp
672 7d61d891 2020-07-23 stsp if ! [ -h $testroot/wt/alpha.link ]; then
673 7d61d891 2020-07-23 stsp echo "alpha.link is not a symlink"
674 7d61d891 2020-07-23 stsp test_done "$testroot" "1"
675 7d61d891 2020-07-23 stsp return 1
676 7d61d891 2020-07-23 stsp fi
677 7d61d891 2020-07-23 stsp
678 7d61d891 2020-07-23 stsp readlink $testroot/wt/alpha.link > $testroot/stdout
679 7d61d891 2020-07-23 stsp echo "alpha" > $testroot/stdout.expected
680 7d61d891 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
681 7d61d891 2020-07-23 stsp ret="$?"
682 7d61d891 2020-07-23 stsp if [ "$ret" != "0" ]; then
683 7d61d891 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
684 7d61d891 2020-07-23 stsp test_done "$testroot" "$ret"
685 7d61d891 2020-07-23 stsp return 1
686 7d61d891 2020-07-23 stsp fi
687 7d61d891 2020-07-23 stsp
688 7d61d891 2020-07-23 stsp if ! [ -h $testroot/wt/epsilon.link ]; then
689 7d61d891 2020-07-23 stsp echo "epsilon.link is not a symlink"
690 7d61d891 2020-07-23 stsp test_done "$testroot" "1"
691 7d61d891 2020-07-23 stsp return 1
692 7d61d891 2020-07-23 stsp fi
693 7d61d891 2020-07-23 stsp
694 7d61d891 2020-07-23 stsp readlink $testroot/wt/epsilon.link > $testroot/stdout
695 7d61d891 2020-07-23 stsp echo "epsilon" > $testroot/stdout.expected
696 7d61d891 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
697 7d61d891 2020-07-23 stsp ret="$?"
698 7d61d891 2020-07-23 stsp if [ "$ret" != "0" ]; then
699 7d61d891 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
700 7d61d891 2020-07-23 stsp test_done "$testroot" "$ret"
701 7d61d891 2020-07-23 stsp return 1
702 7d61d891 2020-07-23 stsp fi
703 7d61d891 2020-07-23 stsp
704 7d61d891 2020-07-23 stsp if [ -h $testroot/wt/passwd.link ]; then
705 7d61d891 2020-07-23 stsp echo -n "passwd.link symlink points outside of work tree: " >&2
706 7d61d891 2020-07-23 stsp readlink $testroot/wt/passwd.link >&2
707 7d61d891 2020-07-23 stsp test_done "$testroot" "1"
708 7d61d891 2020-07-23 stsp return 1
709 7d61d891 2020-07-23 stsp fi
710 7d61d891 2020-07-23 stsp
711 7d61d891 2020-07-23 stsp echo -n "/etc/passwd" > $testroot/content.expected
712 7d61d891 2020-07-23 stsp cp $testroot/wt/passwd.link $testroot/content
713 7d61d891 2020-07-23 stsp
714 7d61d891 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
715 7d61d891 2020-07-23 stsp ret="$?"
716 7d61d891 2020-07-23 stsp if [ "$ret" != "0" ]; then
717 7d61d891 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
718 7d61d891 2020-07-23 stsp test_done "$testroot" "$ret"
719 7d61d891 2020-07-23 stsp return 1
720 7d61d891 2020-07-23 stsp fi
721 7d61d891 2020-07-23 stsp
722 7d61d891 2020-07-23 stsp readlink $testroot/wt/epsilon/beta.link > $testroot/stdout
723 7d61d891 2020-07-23 stsp echo "../beta" > $testroot/stdout.expected
724 7d61d891 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
725 7d61d891 2020-07-23 stsp ret="$?"
726 7d61d891 2020-07-23 stsp if [ "$ret" != "0" ]; then
727 7d61d891 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
728 7d61d891 2020-07-23 stsp test_done "$testroot" "$ret"
729 7d61d891 2020-07-23 stsp return 1
730 7d61d891 2020-07-23 stsp fi
731 7d61d891 2020-07-23 stsp
732 7d61d891 2020-07-23 stsp readlink $testroot/wt/nonexistent.link > $testroot/stdout
733 7d61d891 2020-07-23 stsp echo "nonexistent" > $testroot/stdout.expected
734 7d61d891 2020-07-23 stsp cmp -s $testroot/stdout.expected $testroot/stdout
735 7d61d891 2020-07-23 stsp ret="$?"
736 7d61d891 2020-07-23 stsp if [ "$ret" != "0" ]; then
737 7d61d891 2020-07-23 stsp diff -u $testroot/stdout.expected $testroot/stdout
738 7d61d891 2020-07-23 stsp test_done "$testroot" "$ret"
739 41806587 2020-07-23 stsp return 1
740 7d61d891 2020-07-23 stsp fi
741 7d61d891 2020-07-23 stsp
742 7d61d891 2020-07-23 stsp if [ -h $testroot/wt/dotgotfoo.link ]; then
743 7d61d891 2020-07-23 stsp echo -n "dotgotfoo.link symlink points into .got dir: " >&2
744 7d61d891 2020-07-23 stsp readlink $testroot/wt/dotgotfoo.link >&2
745 7d61d891 2020-07-23 stsp test_done "$testroot" "1"
746 7d61d891 2020-07-23 stsp return 1
747 7d61d891 2020-07-23 stsp fi
748 7d61d891 2020-07-23 stsp
749 7d61d891 2020-07-23 stsp echo -n ".got/foo" > $testroot/content.expected
750 7d61d891 2020-07-23 stsp cp $testroot/wt/dotgotfoo.link $testroot/content
751 7d61d891 2020-07-23 stsp
752 7d61d891 2020-07-23 stsp cmp -s $testroot/content.expected $testroot/content
753 7d61d891 2020-07-23 stsp ret="$?"
754 7d61d891 2020-07-23 stsp if [ "$ret" != "0" ]; then
755 7d61d891 2020-07-23 stsp diff -u $testroot/content.expected $testroot/content
756 7d61d891 2020-07-23 stsp fi
757 7d61d891 2020-07-23 stsp test_done "$testroot" "$ret"
758 7d61d891 2020-07-23 stsp }
759 20b7abb3 2020-10-22 stsp
760 20b7abb3 2020-10-22 stsp test_checkout_repo_with_unknown_extension() {
761 20b7abb3 2020-10-22 stsp local testroot=`test_init checkout_repo_with_unknown_extension`
762 20b7abb3 2020-10-22 stsp
763 20b7abb3 2020-10-22 stsp (cd $testroot/repo &&
764 20b7abb3 2020-10-22 stsp git config --add extensions.badExtension true)
765 20b7abb3 2020-10-22 stsp (cd $testroot/repo &&
766 20b7abb3 2020-10-22 stsp git config --add extensions.otherBadExtension 0)
767 7d61d891 2020-07-23 stsp
768 20b7abb3 2020-10-22 stsp echo "got: badExtension: unsupported repository format extension" \
769 20b7abb3 2020-10-22 stsp > $testroot/stderr.expected
770 20b7abb3 2020-10-22 stsp got checkout $testroot/repo $testroot/wt \
771 20b7abb3 2020-10-22 stsp > $testroot/stdout 2> $testroot/stderr
772 20b7abb3 2020-10-22 stsp
773 20b7abb3 2020-10-22 stsp ret="$?"
774 54c39596 2020-12-28 stsp if [ "$ret" = "0" ]; then
775 20b7abb3 2020-10-22 stsp echo "got checkout command succeeded unexpectedly" >&2
776 20b7abb3 2020-10-22 stsp test_done "$testroot" "1"
777 20b7abb3 2020-10-22 stsp return 1
778 20b7abb3 2020-10-22 stsp fi
779 20b7abb3 2020-10-22 stsp
780 20b7abb3 2020-10-22 stsp cmp -s $testroot/stderr.expected $testroot/stderr
781 20b7abb3 2020-10-22 stsp ret="$?"
782 20b7abb3 2020-10-22 stsp if [ "$ret" != "0" ]; then
783 20b7abb3 2020-10-22 stsp diff -u $testroot/stderr.expected $testroot/stderr
784 20b7abb3 2020-10-22 stsp fi
785 20b7abb3 2020-10-22 stsp test_done "$testroot" "$ret"
786 20b7abb3 2020-10-22 stsp }
787 20b7abb3 2020-10-22 stsp
788 7fb414ae 2020-08-08 stsp test_parseargs "$@"
789 0e673013 2019-01-02 stsp run_test test_checkout_basic
790 80c1b583 2019-08-07 stsp run_test test_checkout_dir_exists
791 80c1b583 2019-08-07 stsp run_test test_checkout_dir_not_empty
792 68ed9ba5 2019-02-10 stsp run_test test_checkout_sets_xbit
793 45d344f6 2019-05-14 stsp run_test test_checkout_commit_from_wrong_branch
794 303e2782 2019-08-09 stsp run_test test_checkout_tag
795 63c5ca5d 2019-08-24 stsp run_test test_checkout_ignores_submodules
796 7f47418f 2019-12-20 stsp run_test test_checkout_read_only
797 bb51a5b4 2020-01-13 stsp run_test test_checkout_into_nonempty_dir
798 8ba819a3 2020-07-23 stsp run_test test_checkout_symlink
799 7d61d891 2020-07-23 stsp run_test test_checkout_symlink_relative_wtpath
800 20b7abb3 2020-10-22 stsp run_test test_checkout_repo_with_unknown_extension