Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t9400-git-cvsserver-server.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t9400-git-cvsserver-server.sh` 670 lines ยท 17590 bytes Raw Blame History 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 11 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main 12 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME 13 14 . ./test-lib.sh 15 16 if ! test_have_prereq PERL; then 17 skip_all='skipping git cvsserver tests, perl not available' 18 test_done 19 fi 20 21 if ! cvs version >/dev/null 2>&1 22 then 23 skip_all='skipping git-cvsserver tests, cvs not found' 24 test_done 25 fi 26 27 perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || { 28 skip_all='skipping git-cvsserver tests, Perl SQLite interface unavailable' 29 test_done 30 } 31 32 WORKDIR=$PWD 33 SERVERDIR=$PWD/gitcvs.git 34 git_config="$SERVERDIR/config" 35 CVSROOT=":fork:$SERVERDIR" 36 CVSWORK="$PWD/cvswork" 37 CVS_SERVER=git-cvsserver 38 export CVSROOT CVS_SERVER 39 40 if perl -e 'exit(1) if not defined crypt("", "cv")' 41 then 42 PWDHASH='lac2ItudM3.KM' 43 else 44 PWDHASH='$2b$10$t8fGvE/a9eLmfOLzsZme2uOa2QtoMYwIxq9wZA6aBKtF1Yb7FJIzi' 45 fi 46 47 rm -rf "$CVSWORK" "$SERVERDIR" 48 test_expect_success 'setup' ' 49 git config push.default matching && 50 echo >empty && 51 git add empty && 52 git commit -q -m "First Commit" && 53 mkdir secondroot && 54 ( cd secondroot && 55 git init && 56 touch secondrootfile && 57 git add secondrootfile && 58 git commit -m "second root") && 59 git fetch secondroot main && 60 git merge --allow-unrelated-histories FETCH_HEAD && 61 git clone -q --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 && 62 GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true && 63 GIT_DIR="$SERVERDIR" git config gitcvs.logfile "$SERVERDIR/gitcvs.log" && 64 GIT_DIR="$SERVERDIR" git config gitcvs.authdb "$SERVERDIR/auth.db" && 65 echo "cvsuser:$PWDHASH" >"$SERVERDIR/auth.db" 66 ' 67 68 # note that cvs doesn't accept absolute pathnames 69 # as argument to co -d 70 test_expect_success 'basic checkout' ' 71 GIT_CONFIG="$git_config" cvs -Q co -d cvswork main && 72 test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | head -n 1))" = "empty/1.1/" && 73 test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | sed -ne \$p))" = "secondrootfile/1.1/" 74 ' 75 76 #------------------------ 77 # PSERVER AUTHENTICATION 78 #------------------------ 79 80 cat >request-anonymous <request-git <login-anonymous <login-git <login-git-ok <log 2>&1 && 122 sed -ne \$p log | grep "^I LOVE YOU\$" 123 ' 124 125 test_expect_success 'pserver authentication failure (non-anonymous user)' ' 126 if git-cvsserver pserver log 2>&1 127 then 128 false 129 else 130 true 131 fi && 132 sed -ne \$p log | grep "^I HATE YOU\$" 133 ' 134 135 test_expect_success 'pserver authentication success (non-anonymous user with password)' ' 136 git-cvsserver pserver log 2>&1 && 137 sed -ne \$p log | grep "^I LOVE YOU\$" 138 ' 139 140 test_expect_success 'pserver authentication (login)' ' 141 git-cvsserver pserver log 2>&1 && 142 sed -ne \$p log | grep "^I LOVE YOU\$" 143 ' 144 145 test_expect_success 'pserver authentication failure (login/non-anonymous user)' ' 146 if git-cvsserver pserver log 2>&1 147 then 148 false 149 else 150 true 151 fi && 152 sed -ne \$p log | grep "^I HATE YOU\$" 153 ' 154 155 156 # misuse pserver authentication for testing of req_Root 157 158 cat >request-relative <request-conflict <log 2>&1 177 then 178 echo unexpected success 179 false 180 else 181 true 182 fi && 183 tail log | grep "^error 1 Root must be an absolute pathname$" 184 ' 185 186 test_expect_success 'req_Root failure (conflicting roots)' ' 187 git-cvsserver pserver log 2>&1 && 188 tail log | grep "^error 1 Conflicting roots specified$" 189 ' 190 191 test_expect_success 'req_Root (strict paths)' ' 192 git-cvsserver --strict-paths pserver "$SERVERDIR" log 2>&1 && 193 sed -ne \$p log | grep "^I LOVE YOU\$" 194 ' 195 196 test_expect_success 'req_Root failure (strict-paths)' ' 197 ! git-cvsserver --strict-paths pserver "$WORKDIR" log 2>&1 198 ' 199 200 test_expect_success 'req_Root (w/o strict-paths)' ' 201 git-cvsserver pserver "$WORKDIR/" log 2>&1 && 202 sed -ne \$p log | grep "^I LOVE YOU\$" 203 ' 204 205 test_expect_success 'req_Root failure (w/o strict-paths)' ' 206 ! git-cvsserver pserver "$WORKDIR/gitcvs" log 2>&1 207 ' 208 209 cat >request-base <log 2>&1 && 220 sed -ne \$p log | grep "^I LOVE YOU\$" 221 ' 222 223 test_expect_success 'req_Root failure (base-path)' ' 224 ! git-cvsserver --strict-paths --base-path "$WORKDIR" pserver "$SERVERDIR" log 2>&1 225 ' 226 227 GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false || exit 1 228 229 test_expect_success 'req_Root (export-all)' ' 230 git-cvsserver --export-all pserver "$WORKDIR" log 2>&1 && 231 sed -ne \$p log | grep "^I LOVE YOU\$" 232 ' 233 234 test_expect_success 'req_Root failure (export-all w/o directory list)' ' 235 ! (git-cvsserver --export-all pserver log 2>&1 || false)' 236 237 test_expect_success 'req_Root (everything together)' ' 238 git-cvsserver --export-all --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" log 2>&1 && 239 sed -ne \$p log | grep "^I LOVE YOU\$" 240 ' 241 242 GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true || exit 1 243 244 #-------------- 245 # CONFIG TESTS 246 #-------------- 247 248 test_expect_success 'gitcvs.enabled = false' \ 249 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false && 250 if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1 251 then 252 echo unexpected cvs success 253 false 254 else 255 true 256 fi && 257 test_grep "GITCVS emulation disabled" cvs.log && 258 test ! -d cvswork2' 259 260 rm -fr cvswork2 261 test_expect_success 'gitcvs.ext.enabled = true' ' 262 GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true && 263 GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false && 264 GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1 && 265 test_cmp cvswork cvswork2 266 ' 267 268 rm -fr cvswork2 269 test_expect_success 'gitcvs.ext.enabled = false' ' 270 GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled false && 271 GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true && 272 if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1 273 then 274 echo unexpected cvs success 275 false 276 else 277 true 278 fi && 279 test_grep "GITCVS emulation disabled" cvs.log && 280 test ! -d cvswork2 281 ' 282 283 rm -fr cvswork2 284 test_expect_success 'gitcvs.dbname' ' 285 GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true && 286 GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs.%a.%m.sqlite && 287 GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1 && 288 test_cmp cvswork cvswork2 && 289 test -f "$SERVERDIR/gitcvs.ext.main.sqlite" && 290 cmp "$SERVERDIR/gitcvs.main.sqlite" "$SERVERDIR/gitcvs.ext.main.sqlite" 291 ' 292 293 rm -fr cvswork2 294 test_expect_success 'gitcvs.ext.dbname' ' 295 GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true && 296 GIT_DIR="$SERVERDIR" git config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite && 297 GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite && 298 GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1 && 299 test_cmp cvswork cvswork2 && 300 test -f "$SERVERDIR/gitcvs1.ext.main.sqlite" && 301 test ! -f "$SERVERDIR/gitcvs2.ext.main.sqlite" && 302 cmp "$SERVERDIR/gitcvs.main.sqlite" "$SERVERDIR/gitcvs1.ext.main.sqlite" 303 ' 304 305 306 #------------ 307 # CVS UPDATE 308 #------------ 309 310 rm -fr "$SERVERDIR" 311 cd "$WORKDIR" && 312 git clone -q --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 && 313 GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true && 314 GIT_DIR="$SERVERDIR" git config gitcvs.logfile "$SERVERDIR/gitcvs.log" || 315 exit 1 316 317 test_expect_success 'cvs update (create new file)' ' 318 echo testfile1 >testfile1 && 319 git add testfile1 && 320 git commit -q -m "Add testfile1" && 321 git push gitcvs.git >/dev/null && 322 cd cvswork && 323 GIT_CONFIG="$git_config" cvs -Q update && 324 test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.1/" && 325 test_cmp testfile1 ../testfile1 326 ' 327 328 cd "$WORKDIR" 329 test_expect_success 'cvs update (update existing file)' ' 330 echo line 2 >>testfile1 && 331 git add testfile1 && 332 git commit -q -m "Append to testfile1" && 333 git push gitcvs.git >/dev/null && 334 cd cvswork && 335 GIT_CONFIG="$git_config" cvs -Q update && 336 test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.2/" && 337 test_cmp testfile1 ../testfile1 338 ' 339 340 cd "$WORKDIR" 341 #TODO: cvsserver doesn't support update w/o -d 342 test_expect_failure "cvs update w/o -d doesn't create subdir (TODO)" ' 343 mkdir test && 344 echo >test/empty && 345 git add test && 346 git commit -q -m "Single Subdirectory" && 347 git push gitcvs.git >/dev/null && 348 cd cvswork && 349 GIT_CONFIG="$git_config" cvs -Q update && 350 test ! -d test 351 ' 352 353 cd "$WORKDIR" 354 test_expect_success 'cvs update (subdirectories)' ' 355 (for dir in A A/B A/B/C A/D E; do 356 mkdir $dir && 357 echo "test file in $dir" >"$dir/file_in_$(echo $dir|sed -e "s#/# #g")" && 358 git add $dir || exit 1 359 done) && 360 git commit -q -m "deep sub directory structure" && 361 git push gitcvs.git >/dev/null && 362 cd cvswork && 363 GIT_CONFIG="$git_config" cvs -Q update -d && 364 (for dir in A A/B A/B/C A/D E; do 365 filename="file_in_$(echo $dir|sed -e "s#/# #g")" && 366 if test "$(echo $(grep -v ^D $dir/CVS/Entries|cut -d/ -f2,3,5))" = "$filename/1.1/" && 367 test_cmp "$dir/$filename" "../$dir/$filename"; then 368 : 369 else 370 exit 1 371 fi 372 done) 373 ' 374 375 cd "$WORKDIR" 376 test_expect_success 'cvs update (delete file)' ' 377 git rm testfile1 && 378 git commit -q -m "Remove testfile1" && 379 git push gitcvs.git >/dev/null && 380 cd cvswork && 381 GIT_CONFIG="$git_config" cvs -Q update && 382 test -z "$(grep testfile1 CVS/Entries)" && 383 test ! -f testfile1 384 ' 385 386 cd "$WORKDIR" 387 test_expect_success 'cvs update (re-add deleted file)' ' 388 echo readded testfile >testfile1 && 389 git add testfile1 && 390 git commit -q -m "Re-Add testfile1" && 391 git push gitcvs.git >/dev/null && 392 cd cvswork && 393 GIT_CONFIG="$git_config" cvs -Q update && 394 test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.4/" && 395 test_cmp testfile1 ../testfile1 396 ' 397 398 cd "$WORKDIR" 399 test_expect_success 'cvs update (merge)' ' 400 echo Line 0 >expected && 401 for i in 1 2 3 4 5 6 7 402 do 403 echo Line $i >>merge && 404 echo Line $i >>expected || return 1 405 done && 406 echo Line 8 >>expected && 407 git add merge && 408 git commit -q -m "Merge test (pre-merge)" && 409 git push gitcvs.git >/dev/null && 410 cd cvswork && 411 GIT_CONFIG="$git_config" cvs -Q update && 412 test "$(echo $(grep merge CVS/Entries|cut -d/ -f2,3,5))" = "merge/1.1/" && 413 test_cmp merge ../merge && 414 ( echo Line 0 && cat merge ) >merge.tmp && 415 mv merge.tmp merge && 416 cd "$WORKDIR" && 417 echo Line 8 >>merge && 418 git add merge && 419 git commit -q -m "Merge test (merge)" && 420 git push gitcvs.git >/dev/null && 421 cd cvswork && 422 sleep 1 && touch merge && 423 GIT_CONFIG="$git_config" cvs -Q update && 424 test_cmp merge ../expected 425 ' 426 427 cd "$WORKDIR" 428 429 cat >expected.C <>>>>>> merge.1.3 435 EOF 436 437 for i in 1 2 3 4 5 6 7 8 438 do 439 echo Line $i >>expected.C 440 done 441 442 test_expect_success 'cvs update (conflict merge)' ' 443 ( echo LINE 0 && cat merge ) >merge.tmp && 444 mv merge.tmp merge && 445 git add merge && 446 git commit -q -m "Merge test (conflict)" && 447 git push gitcvs.git >/dev/null && 448 cd cvswork && 449 GIT_CONFIG="$git_config" cvs -Q update && 450 test_cmp merge ../expected.C 451 ' 452 453 cd "$WORKDIR" 454 test_expect_success 'cvs update (-C)' ' 455 cd cvswork && 456 GIT_CONFIG="$git_config" cvs -Q update -C && 457 test_cmp merge ../merge 458 ' 459 460 cd "$WORKDIR" 461 test_expect_success 'cvs update (merge no-op)' ' 462 echo Line 9 >>merge && 463 cp merge cvswork/merge && 464 git add merge && 465 git commit -q -m "Merge test (no-op)" && 466 git push gitcvs.git >/dev/null && 467 cd cvswork && 468 sleep 1 && touch merge && 469 GIT_CONFIG="$git_config" cvs -Q update && 470 test_cmp merge ../merge 471 ' 472 473 cd "$WORKDIR" 474 test_expect_success 'cvs update (-p)' ' 475 touch really-empty && 476 echo Line 1 > no-lf && 477 printf "Line 2" >> no-lf && 478 git add really-empty no-lf && 479 git commit -q -m "Update -p test" && 480 git push gitcvs.git >/dev/null && 481 cd cvswork && 482 GIT_CONFIG="$git_config" cvs update && 483 for i in merge no-lf empty really-empty; do 484 GIT_CONFIG="$git_config" cvs update -p "$i" >$i.out && 485 test_cmp $i.out ../$i || return 1 486 done 487 ' 488 489 cd "$WORKDIR" 490 test_expect_success 'cvs update (module list supports packed refs)' ' 491 GIT_DIR="$SERVERDIR" git pack-refs --all && 492 GIT_CONFIG="$git_config" cvs -n up -d 2> out && 493 grep "cvs update: New directory \`main'\''" < out 494 ' 495 496 #------------ 497 # CVS STATUS 498 #------------ 499 500 cd "$WORKDIR" 501 test_expect_success 'cvs status' ' 502 mkdir status.dir && 503 echo Line > status.dir/status.file && 504 echo Line > status.file && 505 git add status.dir status.file && 506 git commit -q -m "Status test" && 507 git push gitcvs.git >/dev/null && 508 cd cvswork && 509 GIT_CONFIG="$git_config" cvs update && 510 GIT_CONFIG="$git_config" cvs status | grep "^File: status.file" >../out && 511 test_line_count = 2 ../out 512 ' 513 514 cd "$WORKDIR" 515 test_expect_success 'cvs status (nonrecursive)' ' 516 cd cvswork && 517 GIT_CONFIG="$git_config" cvs status -l | grep "^File: status.file" >../out && 518 test_line_count = 1 ../out 519 ' 520 521 cd "$WORKDIR" 522 test_expect_success 'cvs status (no subdirs in header)' ' 523 cd cvswork && 524 GIT_CONFIG="$git_config" cvs status | grep ^File: >../out && 525 ! grep / <../out 526 ' 527 528 #------------ 529 # CVS CHECKOUT 530 #------------ 531 532 cd "$WORKDIR" 533 test_expect_success 'cvs co -c (shows module database)' ' 534 GIT_CONFIG="$git_config" cvs co -c > out && 535 grep "^main[ ][ ]*main$"