]>
Commit | Line | Data |
---|---|---|
b3b53439 FL |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2007 Frank Lichtenheld | |
4 | # | |
5 | ||
6 | test_description='git-cvsserver access | |
7 | ||
8 | tests read access to a git repository with the | |
9 | cvs CLI client via git-cvsserver server' | |
10 | ||
a881baa2 | 11 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
12 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
13 | ||
b3b53439 FL |
14 | . ./test-lib.sh |
15 | ||
1b19ccd2 | 16 | if ! test_have_prereq PERL; then |
fadb5156 | 17 | skip_all='skipping git cvsserver tests, perl not available' |
1b19ccd2 JK |
18 | test_done |
19 | fi | |
b3b53439 FL |
20 | cvs >/dev/null 2>&1 |
21 | if test $? -ne 1 | |
22 | then | |
fadb5156 | 23 | skip_all='skipping git-cvsserver tests, cvs not found' |
b3b53439 | 24 | test_done |
b3b53439 | 25 | fi |
94221d22 | 26 | perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || { |
fadb5156 | 27 | skip_all='skipping git-cvsserver tests, Perl SQLite interface unavailable' |
469be5b2 | 28 | test_done |
469be5b2 | 29 | } |
b3b53439 | 30 | |
fd318a94 JS |
31 | WORKDIR=$PWD |
32 | SERVERDIR=$PWD/gitcvs.git | |
a25907da | 33 | git_config="$SERVERDIR/config" |
b3b53439 | 34 | CVSROOT=":fork:$SERVERDIR" |
fd318a94 | 35 | CVSWORK="$PWD/cvswork" |
b3b53439 FL |
36 | CVS_SERVER=git-cvsserver |
37 | export CVSROOT CVS_SERVER | |
38 | ||
bffcb4d9 CMAB |
39 | if perl -e 'exit(1) if not defined crypt("", "cv")' |
40 | then | |
41 | PWDHASH='lac2ItudM3.KM' | |
42 | else | |
43 | PWDHASH='$2b$10$t8fGvE/a9eLmfOLzsZme2uOa2QtoMYwIxq9wZA6aBKtF1Yb7FJIzi' | |
44 | fi | |
a7775c7e | 45 | |
b3b53439 | 46 | rm -rf "$CVSWORK" "$SERVERDIR" |
75493765 | 47 | test_expect_success 'setup' ' |
a1c54d7b | 48 | git config push.default matching && |
75493765 | 49 | echo >empty && |
b3b53439 FL |
50 | git add empty && |
51 | git commit -q -m "First Commit" && | |
e509db99 SP |
52 | mkdir secondroot && |
53 | ( cd secondroot && | |
54 | git init && | |
55 | touch secondrootfile && | |
56 | git add secondrootfile && | |
57 | git commit -m "second root") && | |
a881baa2 | 58 | git fetch secondroot main && |
e379fdf3 | 59 | git merge --allow-unrelated-histories FETCH_HEAD && |
7fd3ef1f | 60 | git clone -q --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 && |
b3b53439 | 61 | GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true && |
1dd3f291 ÆAB |
62 | GIT_DIR="$SERVERDIR" git config gitcvs.logfile "$SERVERDIR/gitcvs.log" && |
63 | GIT_DIR="$SERVERDIR" git config gitcvs.authdb "$SERVERDIR/auth.db" && | |
a7775c7e | 64 | echo "cvsuser:$PWDHASH" >"$SERVERDIR/auth.db" |
75493765 | 65 | ' |
b3b53439 FL |
66 | |
67 | # note that cvs doesn't accept absolute pathnames | |
68 | # as argument to co -d | |
447a3b73 JC |
69 | test_expect_success 'basic checkout' ' |
70 | GIT_CONFIG="$git_config" cvs -Q co -d cvswork main && | |
71 | test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | head -n 1))" = "empty/1.1/" && | |
72 | test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | sed -ne \$p))" = "secondrootfile/1.1/" | |
73 | ' | |
b3b53439 | 74 | |
240ba7f2 FL |
75 | #------------------------ |
76 | # PSERVER AUTHENTICATION | |
77 | #------------------------ | |
78 | ||
79 | cat >request-anonymous <<EOF | |
80 | BEGIN AUTH REQUEST | |
81 | $SERVERDIR | |
82 | anonymous | |
83 | ||
84 | END AUTH REQUEST | |
85 | EOF | |
86 | ||
87 | cat >request-git <<EOF | |
88 | BEGIN AUTH REQUEST | |
89 | $SERVERDIR | |
90 | git | |
91 | ||
92 | END AUTH REQUEST | |
93 | EOF | |
94 | ||
24a97d84 FL |
95 | cat >login-anonymous <<EOF |
96 | BEGIN VERIFICATION REQUEST | |
97 | $SERVERDIR | |
98 | anonymous | |
99 | ||
100 | END VERIFICATION REQUEST | |
101 | EOF | |
102 | ||
103 | cat >login-git <<EOF | |
104 | BEGIN VERIFICATION REQUEST | |
105 | $SERVERDIR | |
106 | git | |
107 | ||
108 | END VERIFICATION REQUEST | |
109 | EOF | |
110 | ||
1dd3f291 ÆAB |
111 | cat >login-git-ok <<EOF |
112 | BEGIN VERIFICATION REQUEST | |
113 | $SERVERDIR | |
114 | cvsuser | |
115 | Ah<Z:yZZ30 e | |
116 | END VERIFICATION REQUEST | |
117 | EOF | |
118 | ||
447a3b73 JC |
119 | test_expect_success 'pserver authentication' ' |
120 | cat request-anonymous | git-cvsserver pserver >log 2>&1 && | |
121 | sed -ne \$p log | grep "^I LOVE YOU\$" | |
122 | ' | |
240ba7f2 | 123 | |
447a3b73 JC |
124 | test_expect_success 'pserver authentication failure (non-anonymous user)' ' |
125 | if cat request-git | git-cvsserver pserver >log 2>&1 | |
126 | then | |
127 | false | |
128 | else | |
129 | true | |
130 | fi && | |
131 | sed -ne \$p log | grep "^I HATE YOU\$" | |
132 | ' | |
240ba7f2 | 133 | |
447a3b73 JC |
134 | test_expect_success 'pserver authentication success (non-anonymous user with password)' ' |
135 | cat login-git-ok | git-cvsserver pserver >log 2>&1 && | |
136 | sed -ne \$p log | grep "^I LOVE YOU\$" | |
137 | ' | |
1dd3f291 | 138 | |
447a3b73 JC |
139 | test_expect_success 'pserver authentication (login)' ' |
140 | cat login-anonymous | git-cvsserver pserver >log 2>&1 && | |
141 | sed -ne \$p log | grep "^I LOVE YOU\$" | |
142 | ' | |
24a97d84 | 143 | |
447a3b73 JC |
144 | test_expect_success 'pserver authentication failure (login/non-anonymous user)' ' |
145 | if cat login-git | git-cvsserver pserver >log 2>&1 | |
146 | then | |
147 | false | |
148 | else | |
149 | true | |
150 | fi && | |
151 | sed -ne \$p log | grep "^I HATE YOU\$" | |
152 | ' | |
24a97d84 | 153 | |
240ba7f2 | 154 | |
4890888d FL |
155 | # misuse pserver authentication for testing of req_Root |
156 | ||
157 | cat >request-relative <<EOF | |
158 | BEGIN AUTH REQUEST | |
159 | gitcvs.git | |
160 | anonymous | |
161 | ||
162 | END AUTH REQUEST | |
163 | EOF | |
164 | ||
165 | cat >request-conflict <<EOF | |
166 | BEGIN AUTH REQUEST | |
167 | $SERVERDIR | |
168 | anonymous | |
169 | ||
170 | END AUTH REQUEST | |
171 | Root $WORKDIR | |
172 | EOF | |
173 | ||
447a3b73 JC |
174 | test_expect_success 'req_Root failure (relative pathname)' ' |
175 | if cat request-relative | git-cvsserver pserver >log 2>&1 | |
176 | then | |
177 | echo unexpected success | |
178 | false | |
179 | else | |
180 | true | |
181 | fi && | |
182 | tail log | grep "^error 1 Root must be an absolute pathname$" | |
183 | ' | |
4890888d | 184 | |
447a3b73 JC |
185 | test_expect_success 'req_Root failure (conflicting roots)' ' |
186 | cat request-conflict | git-cvsserver pserver >log 2>&1 && | |
187 | tail log | grep "^error 1 Conflicting roots specified$" | |
188 | ' | |
4890888d | 189 | |
447a3b73 JC |
190 | test_expect_success 'req_Root (strict paths)' ' |
191 | cat request-anonymous | git-cvsserver --strict-paths pserver "$SERVERDIR" >log 2>&1 && | |
192 | sed -ne \$p log | grep "^I LOVE YOU\$" | |
193 | ' | |
693b6327 | 194 | |
41ac414e | 195 | test_expect_success 'req_Root failure (strict-paths)' ' |
447a3b73 JC |
196 | ! cat request-anonymous | |
197 | git-cvsserver --strict-paths pserver "$WORKDIR" >log 2>&1 | |
41ac414e | 198 | ' |
693b6327 | 199 | |
447a3b73 JC |
200 | test_expect_success 'req_Root (w/o strict-paths)' ' |
201 | cat request-anonymous | git-cvsserver pserver "$WORKDIR/" >log 2>&1 && | |
202 | sed -ne \$p log | grep "^I LOVE YOU\$" | |
203 | ' | |
693b6327 | 204 | |
41ac414e | 205 | test_expect_success 'req_Root failure (w/o strict-paths)' ' |
447a3b73 JC |
206 | ! cat request-anonymous | |
207 | git-cvsserver pserver "$WORKDIR/gitcvs" >log 2>&1 | |
41ac414e | 208 | ' |
693b6327 FL |
209 | |
210 | cat >request-base <<EOF | |
211 | BEGIN AUTH REQUEST | |
212 | /gitcvs.git | |
213 | anonymous | |
214 | ||
215 | END AUTH REQUEST | |
fd1cd91e | 216 | Root /gitcvs.git |
693b6327 FL |
217 | EOF |
218 | ||
447a3b73 JC |
219 | test_expect_success 'req_Root (base-path)' ' |
220 | cat request-base | git-cvsserver --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" >log 2>&1 && | |
221 | sed -ne \$p log | grep "^I LOVE YOU\$" | |
222 | ' | |
693b6327 | 223 | |
41ac414e | 224 | test_expect_success 'req_Root failure (base-path)' ' |
447a3b73 JC |
225 | ! cat request-anonymous | |
226 | git-cvsserver --strict-paths --base-path "$WORKDIR" pserver "$SERVERDIR" >log 2>&1 | |
41ac414e | 227 | ' |
4890888d | 228 | |
226bccb9 FL |
229 | GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false || exit 1 |
230 | ||
447a3b73 JC |
231 | test_expect_success 'req_Root (export-all)' ' |
232 | cat request-anonymous | git-cvsserver --export-all pserver "$WORKDIR" >log 2>&1 && | |
233 | sed -ne \$p log | grep "^I LOVE YOU\$" | |
234 | ' | |
226bccb9 | 235 | |
447a3b73 JC |
236 | test_expect_success 'req_Root failure (export-all w/o directory list)' ' |
237 | ! (cat request-anonymous | git-cvsserver --export-all pserver >log 2>&1 || false)' | |
226bccb9 | 238 | |
447a3b73 JC |
239 | test_expect_success 'req_Root (everything together)' ' |
240 | cat request-base | git-cvsserver --export-all --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" >log 2>&1 && | |
241 | sed -ne \$p log | grep "^I LOVE YOU\$" | |
242 | ' | |
226bccb9 FL |
243 | |
244 | GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true || exit 1 | |
245 | ||
1d431b22 FL |
246 | #-------------- |
247 | # CONFIG TESTS | |
248 | #-------------- | |
249 | ||
250 | test_expect_success 'gitcvs.enabled = false' \ | |
251 | 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false && | |
a881baa2 | 252 | if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1 |
1d431b22 FL |
253 | then |
254 | echo unexpected cvs success | |
255 | false | |
256 | else | |
257 | true | |
258 | fi && | |
aadbe44f | 259 | grep "GITCVS emulation disabled" cvs.log && |
1d431b22 FL |
260 | test ! -d cvswork2' |
261 | ||
262 | rm -fr cvswork2 | |
447a3b73 JC |
263 | test_expect_success 'gitcvs.ext.enabled = true' ' |
264 | GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true && | |
265 | GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false && | |
266 | GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1 && | |
267 | test_cmp cvswork cvswork2 | |
268 | ' | |
1d431b22 FL |
269 | |
270 | rm -fr cvswork2 | |
447a3b73 JC |
271 | test_expect_success 'gitcvs.ext.enabled = false' ' |
272 | GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled false && | |
273 | GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true && | |
274 | if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1 | |
275 | then | |
276 | echo unexpected cvs success | |
277 | false | |
278 | else | |
279 | true | |
280 | fi && | |
281 | grep "GITCVS emulation disabled" cvs.log && | |
282 | test ! -d cvswork2 | |
283 | ' | |
1d431b22 FL |
284 | |
285 | rm -fr cvswork2 | |
447a3b73 JC |
286 | test_expect_success 'gitcvs.dbname' ' |
287 | GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true && | |
288 | GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs.%a.%m.sqlite && | |
289 | GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1 && | |
290 | test_cmp cvswork cvswork2 && | |
291 | test -f "$SERVERDIR/gitcvs.ext.main.sqlite" && | |
292 | cmp "$SERVERDIR/gitcvs.main.sqlite" "$SERVERDIR/gitcvs.ext.main.sqlite" | |
293 | ' | |
1d431b22 FL |
294 | |
295 | rm -fr cvswork2 | |
447a3b73 JC |
296 | test_expect_success 'gitcvs.ext.dbname' ' |
297 | GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true && | |
298 | GIT_DIR="$SERVERDIR" git config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite && | |
299 | GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite && | |
300 | GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1 && | |
301 | test_cmp cvswork cvswork2 && | |
302 | test -f "$SERVERDIR/gitcvs1.ext.main.sqlite" && | |
303 | test ! -f "$SERVERDIR/gitcvs2.ext.main.sqlite" && | |
304 | cmp "$SERVERDIR/gitcvs.main.sqlite" "$SERVERDIR/gitcvs1.ext.main.sqlite" | |
305 | ' | |
1d431b22 FL |
306 | |
307 | ||
308 | #------------ | |
309 | # CVS UPDATE | |
310 | #------------ | |
311 | ||
312 | rm -fr "$SERVERDIR" | |
313 | cd "$WORKDIR" && | |
7fd3ef1f | 314 | git clone -q --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 && |
1d431b22 | 315 | GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true && |
db1696b8 | 316 | GIT_DIR="$SERVERDIR" git config gitcvs.logfile "$SERVERDIR/gitcvs.log" || |
1d431b22 FL |
317 | exit 1 |
318 | ||
447a3b73 JC |
319 | test_expect_success 'cvs update (create new file)' ' |
320 | echo testfile1 >testfile1 && | |
321 | git add testfile1 && | |
322 | git commit -q -m "Add testfile1" && | |
323 | git push gitcvs.git >/dev/null && | |
324 | cd cvswork && | |
325 | GIT_CONFIG="$git_config" cvs -Q update && | |
326 | test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.1/" && | |
327 | test_cmp testfile1 ../testfile1 | |
328 | ' | |
b3b53439 FL |
329 | |
330 | cd "$WORKDIR" | |
447a3b73 JC |
331 | test_expect_success 'cvs update (update existing file)' ' |
332 | echo line 2 >>testfile1 && | |
333 | git add testfile1 && | |
334 | git commit -q -m "Append to testfile1" && | |
335 | git push gitcvs.git >/dev/null && | |
336 | cd cvswork && | |
337 | GIT_CONFIG="$git_config" cvs -Q update && | |
338 | test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.2/" && | |
339 | test_cmp testfile1 ../testfile1 | |
340 | ' | |
b3b53439 FL |
341 | |
342 | cd "$WORKDIR" | |
343 | #TODO: cvsserver doesn't support update w/o -d | |
41ac414e | 344 | test_expect_failure "cvs update w/o -d doesn't create subdir (TODO)" ' |
447a3b73 JC |
345 | mkdir test && |
346 | echo >test/empty && | |
347 | git add test && | |
348 | git commit -q -m "Single Subdirectory" && | |
349 | git push gitcvs.git >/dev/null && | |
350 | cd cvswork && | |
351 | GIT_CONFIG="$git_config" cvs -Q update && | |
352 | test ! -d test | |
41ac414e | 353 | ' |
b3b53439 FL |
354 | |
355 | cd "$WORKDIR" | |
447a3b73 JC |
356 | test_expect_success 'cvs update (subdirectories)' ' |
357 | (for dir in A A/B A/B/C A/D E; do | |
358 | mkdir $dir && | |
359 | echo "test file in $dir" >"$dir/file_in_$(echo $dir|sed -e "s#/# #g")" && | |
360 | git add $dir || exit 1 | |
361 | done) && | |
362 | git commit -q -m "deep sub directory structure" && | |
363 | git push gitcvs.git >/dev/null && | |
364 | cd cvswork && | |
365 | GIT_CONFIG="$git_config" cvs -Q update -d && | |
366 | (for dir in A A/B A/B/C A/D E; do | |
367 | filename="file_in_$(echo $dir|sed -e "s#/# #g")" && | |
368 | if test "$(echo $(grep -v ^D $dir/CVS/Entries|cut -d/ -f2,3,5))" = "$filename/1.1/" && | |
369 | test_cmp "$dir/$filename" "../$dir/$filename"; then | |
370 | : | |
371 | else | |
372 | exit 1 | |
373 | fi | |
374 | done) | |
375 | ' | |
b3b53439 FL |
376 | |
377 | cd "$WORKDIR" | |
447a3b73 JC |
378 | test_expect_success 'cvs update (delete file)' ' |
379 | git rm testfile1 && | |
380 | git commit -q -m "Remove testfile1" && | |
381 | git push gitcvs.git >/dev/null && | |
382 | cd cvswork && | |
383 | GIT_CONFIG="$git_config" cvs -Q update && | |
384 | test -z "$(grep testfile1 CVS/Entries)" && | |
385 | test ! -f testfile1 | |
386 | ' | |
b3b53439 FL |
387 | |
388 | cd "$WORKDIR" | |
447a3b73 JC |
389 | test_expect_success 'cvs update (re-add deleted file)' ' |
390 | echo readded testfile >testfile1 && | |
391 | git add testfile1 && | |
392 | git commit -q -m "Re-Add testfile1" && | |
393 | git push gitcvs.git >/dev/null && | |
394 | cd cvswork && | |
395 | GIT_CONFIG="$git_config" cvs -Q update && | |
396 | test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.4/" && | |
397 | test_cmp testfile1 ../testfile1 | |
398 | ' | |
b3b53439 | 399 | |
1978659a | 400 | cd "$WORKDIR" |
447a3b73 JC |
401 | test_expect_success 'cvs update (merge)' ' |
402 | echo Line 0 >expected && | |
403 | for i in 1 2 3 4 5 6 7 | |
404 | do | |
405 | echo Line $i >>merge && | |
406 | echo Line $i >>expected || return 1 | |
407 | done && | |
408 | echo Line 8 >>expected && | |
409 | git add merge && | |
410 | git commit -q -m "Merge test (pre-merge)" && | |
411 | git push gitcvs.git >/dev/null && | |
412 | cd cvswork && | |
413 | GIT_CONFIG="$git_config" cvs -Q update && | |
414 | test "$(echo $(grep merge CVS/Entries|cut -d/ -f2,3,5))" = "merge/1.1/" && | |
415 | test_cmp merge ../merge && | |
416 | ( echo Line 0 && cat merge ) >merge.tmp && | |
417 | mv merge.tmp merge && | |
418 | cd "$WORKDIR" && | |
419 | echo Line 8 >>merge && | |
420 | git add merge && | |
421 | git commit -q -m "Merge test (merge)" && | |
422 | git push gitcvs.git >/dev/null && | |
423 | cd cvswork && | |
424 | sleep 1 && touch merge && | |
425 | GIT_CONFIG="$git_config" cvs -Q update && | |
426 | test_cmp merge ../expected | |
427 | ' | |
1978659a FL |
428 | |
429 | cd "$WORKDIR" | |
430 | ||
431 | cat >expected.C <<EOF | |
432 | <<<<<<< merge.mine | |
433 | Line 0 | |
434 | ======= | |
435 | LINE 0 | |
ab07681f | 436 | >>>>>>> merge.1.3 |
1978659a FL |
437 | EOF |
438 | ||
439 | for i in 1 2 3 4 5 6 7 8 | |
440 | do | |
441 | echo Line $i >>expected.C | |
442 | done | |
443 | ||
447a3b73 JC |
444 | test_expect_success 'cvs update (conflict merge)' ' |
445 | ( echo LINE 0 && cat merge ) >merge.tmp && | |
446 | mv merge.tmp merge && | |
447 | git add merge && | |
448 | git commit -q -m "Merge test (conflict)" && | |
449 | git push gitcvs.git >/dev/null && | |
450 | cd cvswork && | |
451 | GIT_CONFIG="$git_config" cvs -Q update && | |
452 | test_cmp merge ../expected.C | |
453 | ' | |
1978659a FL |
454 | |
455 | cd "$WORKDIR" | |
447a3b73 JC |
456 | test_expect_success 'cvs update (-C)' ' |
457 | cd cvswork && | |
458 | GIT_CONFIG="$git_config" cvs -Q update -C && | |
459 | test_cmp merge ../merge | |
460 | ' | |
1978659a FL |
461 | |
462 | cd "$WORKDIR" | |
447a3b73 JC |
463 | test_expect_success 'cvs update (merge no-op)' ' |
464 | echo Line 9 >>merge && | |
465 | cp merge cvswork/merge && | |
466 | git add merge && | |
467 | git commit -q -m "Merge test (no-op)" && | |
468 | git push gitcvs.git >/dev/null && | |
469 | cd cvswork && | |
470 | sleep 1 && touch merge && | |
471 | GIT_CONFIG="$git_config" cvs -Q update && | |
472 | test_cmp merge ../merge | |
473 | ' | |
1978659a | 474 | |
6e8937a0 DD |
475 | cd "$WORKDIR" |
476 | test_expect_success 'cvs update (-p)' ' | |
447a3b73 JC |
477 | touch really-empty && |
478 | echo Line 1 > no-lf && | |
479 | printf "Line 2" >> no-lf && | |
480 | git add really-empty no-lf && | |
481 | git commit -q -m "Update -p test" && | |
482 | git push gitcvs.git >/dev/null && | |
483 | cd cvswork && | |
484 | GIT_CONFIG="$git_config" cvs update && | |
485 | for i in merge no-lf empty really-empty; do | |
486 | GIT_CONFIG="$git_config" cvs update -p "$i" >$i.out && | |
487 | test_cmp $i.out ../$i || return 1 | |
488 | done | |
6e8937a0 DD |
489 | ' |
490 | ||
b0f2ecf5 LN |
491 | cd "$WORKDIR" |
492 | test_expect_success 'cvs update (module list supports packed refs)' ' | |
447a3b73 JC |
493 | GIT_DIR="$SERVERDIR" git pack-refs --all && |
494 | GIT_CONFIG="$git_config" cvs -n up -d 2> out && | |
495 | grep "cvs update: New directory \`main'\''" < out | |
b0f2ecf5 LN |
496 | ' |
497 | ||
dded801a DD |
498 | #------------ |
499 | # CVS STATUS | |
500 | #------------ | |
501 | ||
502 | cd "$WORKDIR" | |
503 | test_expect_success 'cvs status' ' | |
447a3b73 JC |
504 | mkdir status.dir && |
505 | echo Line > status.dir/status.file && | |
506 | echo Line > status.file && | |
507 | git add status.dir status.file && | |
508 | git commit -q -m "Status test" && | |
509 | git push gitcvs.git >/dev/null && | |
510 | cd cvswork && | |
511 | GIT_CONFIG="$git_config" cvs update && | |
512 | GIT_CONFIG="$git_config" cvs status | grep "^File: status.file" >../out && | |
513 | test_line_count = 2 ../out | |
dded801a DD |
514 | ' |
515 | ||
516 | cd "$WORKDIR" | |
517 | test_expect_success 'cvs status (nonrecursive)' ' | |
447a3b73 JC |
518 | cd cvswork && |
519 | GIT_CONFIG="$git_config" cvs status -l | grep "^File: status.file" >../out && | |
520 | test_line_count = 1 ../out | |
dded801a DD |
521 | ' |
522 | ||
523 | cd "$WORKDIR" | |
524 | test_expect_success 'cvs status (no subdirs in header)' ' | |
447a3b73 JC |
525 | cd cvswork && |
526 | GIT_CONFIG="$git_config" cvs status | grep ^File: >../out && | |
527 | ! grep / <../out | |
dded801a DD |
528 | ' |
529 | ||
42f7a2da FE |
530 | #------------ |
531 | # CVS CHECKOUT | |
532 | #------------ | |
533 | ||
534 | cd "$WORKDIR" | |
535 | test_expect_success 'cvs co -c (shows module database)' ' | |
447a3b73 JC |
536 | GIT_CONFIG="$git_config" cvs co -c > out && |
537 | grep "^main[ ][ ]*main$" <out && | |
538 | ! grep -v "^main[ ][ ]*main$" <out | |
42f7a2da FE |
539 | ' |
540 | ||
ef6fd72b MO |
541 | #------------ |
542 | # CVS LOG | |
543 | #------------ | |
544 | ||
545 | # Known issues with git-cvsserver current log output: | |
546 | # - Hard coded "lines: +2 -3" placeholder, instead of real numbers. | |
547 | # - CVS normally does not internally add a blank first line | |
235e8d59 | 548 | # or a last line with nothing but a space to log messages. |
ef6fd72b MO |
549 | # - The latest cvs 1.12.x server sends +0000 timezone (with some hidden "MT" |
550 | # tagging in the protocol), and if cvs 1.12.x client sees the MT tags, | |
551 | # it converts to local time zone. git-cvsserver doesn't do the +0000 | |
552 | # or the MT tags... | |
553 | # - The latest 1.12.x releases add a "commitid:" field on to the end of the | |
554 | # "date:" line (after "lines:"). Maybe we could stick git's commit id | |
555 | # in it? Or does CVS expect a certain number of bits (too few for | |
556 | # a full sha1)? | |
557 | # | |
558 | # Given the above, expect the following test to break if git-cvsserver's | |
559 | # log output is improved. The test is just to ensure it doesn't | |
560 | # accidentally get worse. | |
561 | ||
562 | sed -e 's/^x//' -e 's/SP$/ /' > "$WORKDIR/expect" <<EOF | |
563 | x | |
a881baa2 | 564 | xRCS file: $WORKDIR/gitcvs.git/main/merge,v |
ef6fd72b MO |
565 | xWorking file: merge |
566 | xhead: 1.4 | |
567 | xbranch: | |
568 | xlocks: strict | |
569 | xaccess list: | |
570 | xsymbolic names: | |
571 | xkeyword substitution: kv | |
572 | xtotal revisions: 4; selected revisions: 4 | |
573 | xdescription: | |
574 | x---------------------------- | |
575 | xrevision 1.4 | |
576 | xdate: __DATE__; author: author; state: Exp; lines: +2 -3 | |
577 | x | |
578 | xMerge test (no-op) | |
579 | xSP | |
580 | x---------------------------- | |
581 | xrevision 1.3 | |
582 | xdate: __DATE__; author: author; state: Exp; lines: +2 -3 | |
583 | x | |
584 | xMerge test (conflict) | |
585 | xSP | |
586 | x---------------------------- | |
587 | xrevision 1.2 | |
588 | xdate: __DATE__; author: author; state: Exp; lines: +2 -3 | |
589 | x | |
590 | xMerge test (merge) | |
591 | xSP | |
592 | x---------------------------- | |
593 | xrevision 1.1 | |
594 | xdate: __DATE__; author: author; state: Exp; lines: +2 -3 | |
595 | x | |
596 | xMerge test (pre-merge) | |
597 | xSP | |
598 | x============================================================================= | |
599 | EOF | |
600 | expectStat="$?" | |
601 | ||
602 | cd "$WORKDIR" | |
603 | test_expect_success 'cvs log' ' | |
447a3b73 JC |
604 | cd cvswork && |
605 | test x"$expectStat" = x"0" && | |
606 | GIT_CONFIG="$git_config" cvs log merge >../out && | |
607 | sed -e "s%2[0-9][0-9][0-9]/[01][0-9]/[0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9]%__DATE__%" ../out > ../actual && | |
608 | test_cmp ../expect ../actual | |
ef6fd72b MO |
609 | ' |
610 | ||
7ceacdff JH |
611 | #------------ |
612 | # CVS ANNOTATE | |
613 | #------------ | |
614 | ||
615 | cd "$WORKDIR" | |
616 | test_expect_success 'cvs annotate' ' | |
447a3b73 JC |
617 | cd cvswork && |
618 | GIT_CONFIG="$git_config" cvs annotate merge >../out && | |
619 | sed -e "s/ .*//" ../out >../actual && | |
620 | printf "1.%d\n" 3 1 1 1 1 1 1 1 2 4 >../expect && | |
621 | test_cmp ../expect ../actual | |
7ceacdff JH |
622 | ' |
623 | ||
9a42c03c JK |
624 | #------------ |
625 | # running via git-shell | |
626 | #------------ | |
627 | ||
628 | cd "$WORKDIR" | |
629 | ||
630 | test_expect_success 'create remote-cvs helper' ' | |
631 | write_script remote-cvs <<-\EOF | |
632 | exec git shell -c "cvs server" | |
633 | EOF | |
634 | ' | |
635 | ||
636 | test_expect_success 'cvs server does not run with vanilla git-shell' ' | |
637 | ( | |
638 | cd cvswork && | |
639 | CVS_SERVER=$WORKDIR/remote-cvs && | |
640 | export CVS_SERVER && | |
41feac6f | 641 | ! cvs log merge |
9a42c03c JK |
642 | ) |
643 | ' | |
644 | ||
645 | test_expect_success 'configure git shell to run cvs server' ' | |
646 | mkdir "$HOME"/git-shell-commands && | |
647 | ||
648 | write_script "$HOME"/git-shell-commands/cvs <<-\EOF && | |
649 | if ! test $# = 1 && test "$1" = "server" | |
650 | then | |
651 | echo >&2 "git-cvsserver only handles \"server\"" | |
652 | exit 1 | |
653 | fi | |
654 | exec git cvsserver server | |
655 | EOF | |
656 | ||
657 | # Should not be used, but part of the recommended setup | |
658 | write_script "$HOME"/git-shell-commands/no-interactive-login <<-\EOF | |
659 | echo Interactive login forbidden | |
660 | EOF | |
661 | ' | |
662 | ||
663 | test_expect_success 'cvs server can run with recommended config' ' | |
664 | ( | |
665 | cd cvswork && | |
666 | CVS_SERVER=$WORKDIR/remote-cvs && | |
667 | export CVS_SERVER && | |
668 | cvs log merge | |
669 | ) | |
670 | ' | |
671 | ||
b3b53439 | 672 | test_done |