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