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