| 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 <<EOF |
| 81 | BEGIN AUTH REQUEST |
| 82 | $SERVERDIR |
| 83 | anonymous |
| 84 | |
| 85 | END AUTH REQUEST |
| 86 | EOF |
| 87 | |
| 88 | cat >request-git <<EOF |
| 89 | BEGIN AUTH REQUEST |
| 90 | $SERVERDIR |
| 91 | git |
| 92 | |
| 93 | END AUTH REQUEST |
| 94 | EOF |
| 95 | |
| 96 | cat >login-anonymous <<EOF |
| 97 | BEGIN VERIFICATION REQUEST |
| 98 | $SERVERDIR |
| 99 | anonymous |
| 100 | |
| 101 | END VERIFICATION REQUEST |
| 102 | EOF |
| 103 | |
| 104 | cat >login-git <<EOF |
| 105 | BEGIN VERIFICATION REQUEST |
| 106 | $SERVERDIR |
| 107 | git |
| 108 | |
| 109 | END VERIFICATION REQUEST |
| 110 | EOF |
| 111 | |
| 112 | cat >login-git-ok <<EOF |
| 113 | BEGIN VERIFICATION REQUEST |
| 114 | $SERVERDIR |
| 115 | cvsuser |
| 116 | Ah<Z:yZZ30 e |
| 117 | END VERIFICATION REQUEST |
| 118 | EOF |
| 119 | |
| 120 | test_expect_success 'pserver authentication' ' |
| 121 | git-cvsserver pserver <request-anonymous >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 <request-git >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 <login-git-ok >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 <login-anonymous >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 <login-git >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 <<EOF |
| 159 | BEGIN AUTH REQUEST |
| 160 | gitcvs.git |
| 161 | anonymous |
| 162 | |
| 163 | END AUTH REQUEST |
| 164 | EOF |
| 165 | |
| 166 | cat >request-conflict <<EOF |
| 167 | BEGIN AUTH REQUEST |
| 168 | $SERVERDIR |
| 169 | anonymous |
| 170 | |
| 171 | END AUTH REQUEST |
| 172 | Root $WORKDIR |
| 173 | EOF |
| 174 | |
| 175 | test_expect_success 'req_Root failure (relative pathname)' ' |
| 176 | if git-cvsserver pserver <request-relative >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 <request-conflict >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" <request-anonymous >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" <request-anonymous >log 2>&1 |
| 198 | ' |
| 199 | |
| 200 | test_expect_success 'req_Root (w/o strict-paths)' ' |
| 201 | git-cvsserver pserver "$WORKDIR/" <request-anonymous >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" <request-anonymous >log 2>&1 |
| 207 | ' |
| 208 | |
| 209 | cat >request-base <<EOF |
| 210 | BEGIN AUTH REQUEST |
| 211 | /gitcvs.git |
| 212 | anonymous |
| 213 | |
| 214 | END AUTH REQUEST |
| 215 | Root /gitcvs.git |
| 216 | EOF |
| 217 | |
| 218 | test_expect_success 'req_Root (base-path)' ' |
| 219 | git-cvsserver --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" <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" <request-anonymous >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" <request-anonymous >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 <request-anonymous >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" <request-base >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 <<EOF |
| 430 | <<<<<<< merge.mine |
| 431 | Line 0 |
| 432 | ======= |
| 433 | LINE 0 |
| 434 | >>>>>>> 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$" <out && |
| 536 | ! grep -v "^main[ ][ ]*main$" <out |
| 537 | ' |
| 538 | |
| 539 | #------------ |
| 540 | # CVS LOG |
| 541 | #------------ |
| 542 | |
| 543 | # Known issues with git-cvsserver current log output: |
| 544 | # - Hard coded "lines: +2 -3" placeholder, instead of real numbers. |
| 545 | # - CVS normally does not internally add a blank first line |
| 546 | # or a last line with nothing but a space to log messages. |
| 547 | # - The latest cvs 1.12.x server sends +0000 timezone (with some hidden "MT" |
| 548 | # tagging in the protocol), and if cvs 1.12.x client sees the MT tags, |
| 549 | # it converts to local time zone. git-cvsserver doesn't do the +0000 |
| 550 | # or the MT tags... |
| 551 | # - The latest 1.12.x releases add a "commitid:" field on to the end of the |
| 552 | # "date:" line (after "lines:"). Maybe we could stick git's commit id |
| 553 | # in it? Or does CVS expect a certain number of bits (too few for |
| 554 | # a full sha1)? |
| 555 | # |
| 556 | # Given the above, expect the following test to break if git-cvsserver's |
| 557 | # log output is improved. The test is just to ensure it doesn't |
| 558 | # accidentally get worse. |
| 559 | |
| 560 | sed -e 's/^x//' -e 's/SP$/ /' > "$WORKDIR/expect" <<EOF |
| 561 | x |
| 562 | xRCS file: $WORKDIR/gitcvs.git/main/merge,v |
| 563 | xWorking file: merge |
| 564 | xhead: 1.4 |
| 565 | xbranch: |
| 566 | xlocks: strict |
| 567 | xaccess list: |
| 568 | xsymbolic names: |
| 569 | xkeyword substitution: kv |
| 570 | xtotal revisions: 4; selected revisions: 4 |
| 571 | xdescription: |
| 572 | x---------------------------- |
| 573 | xrevision 1.4 |
| 574 | xdate: __DATE__; author: author; state: Exp; lines: +2 -3 |
| 575 | x |
| 576 | xMerge test (no-op) |
| 577 | xSP |
| 578 | x---------------------------- |
| 579 | xrevision 1.3 |
| 580 | xdate: __DATE__; author: author; state: Exp; lines: +2 -3 |
| 581 | x |
| 582 | xMerge test (conflict) |
| 583 | xSP |
| 584 | x---------------------------- |
| 585 | xrevision 1.2 |
| 586 | xdate: __DATE__; author: author; state: Exp; lines: +2 -3 |
| 587 | x |
| 588 | xMerge test (merge) |
| 589 | xSP |
| 590 | x---------------------------- |
| 591 | xrevision 1.1 |
| 592 | xdate: __DATE__; author: author; state: Exp; lines: +2 -3 |
| 593 | x |
| 594 | xMerge test (pre-merge) |
| 595 | xSP |
| 596 | x============================================================================= |
| 597 | EOF |
| 598 | expectStat="$?" |
| 599 | |
| 600 | cd "$WORKDIR" |
| 601 | test_expect_success 'cvs log' ' |
| 602 | cd cvswork && |
| 603 | test x"$expectStat" = x"0" && |
| 604 | GIT_CONFIG="$git_config" cvs log merge >../out && |
| 605 | 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 && |
| 606 | test_cmp ../expect ../actual |
| 607 | ' |
| 608 | |
| 609 | #------------ |
| 610 | # CVS ANNOTATE |
| 611 | #------------ |
| 612 | |
| 613 | cd "$WORKDIR" |
| 614 | test_expect_success 'cvs annotate' ' |
| 615 | cd cvswork && |
| 616 | GIT_CONFIG="$git_config" cvs annotate merge >../out && |
| 617 | sed -e "s/ .*//" ../out >../actual && |
| 618 | printf "1.%d\n" 3 1 1 1 1 1 1 1 2 4 >../expect && |
| 619 | test_cmp ../expect ../actual |
| 620 | ' |
| 621 | |
| 622 | #------------ |
| 623 | # running via git-shell |
| 624 | #------------ |
| 625 | |
| 626 | cd "$WORKDIR" |
| 627 | |
| 628 | test_expect_success 'create remote-cvs helper' ' |
| 629 | write_script remote-cvs <<-\EOF |
| 630 | exec git shell -c "cvs server" |
| 631 | EOF |
| 632 | ' |
| 633 | |
| 634 | test_expect_success 'cvs server does not run with vanilla git-shell' ' |
| 635 | ( |
| 636 | cd cvswork && |
| 637 | CVS_SERVER=$WORKDIR/remote-cvs && |
| 638 | export CVS_SERVER && |
| 639 | ! cvs log merge |
| 640 | ) |
| 641 | ' |
| 642 | |
| 643 | test_expect_success 'configure git shell to run cvs server' ' |
| 644 | mkdir "$HOME"/git-shell-commands && |
| 645 | |
| 646 | write_script "$HOME"/git-shell-commands/cvs <<-\EOF && |
| 647 | if ! test $# = 1 && test "$1" = "server" |
| 648 | then |
| 649 | echo >&2 "git-cvsserver only handles \"server\"" |
| 650 | exit 1 |
| 651 | fi |
| 652 | exec git cvsserver server |
| 653 | EOF |
| 654 | |
| 655 | # Should not be used, but part of the recommended setup |
| 656 | write_script "$HOME"/git-shell-commands/no-interactive-login <<-\EOF |
| 657 | echo Interactive login forbidden |
| 658 | EOF |
| 659 | ' |
| 660 | |
| 661 | test_expect_success 'cvs server can run with recommended config' ' |
| 662 | ( |
| 663 | cd cvswork && |
| 664 | CVS_SERVER=$WORKDIR/remote-cvs && |
| 665 | export CVS_SERVER && |
| 666 | cvs log merge |
| 667 | ) |
| 668 | ' |
| 669 | |
| 670 | test_done |