t / t9400-git-cvsserver-server.shon commit git-add: allow path limiting with -u (93c44d4)
   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
  11. ./test-lib.sh
  12
  13cvs >/dev/null 2>&1
  14if test $? -ne 1
  15then
  16    test_expect_success 'skipping git-cvsserver tests, cvs not found' :
  17    test_done
  18    exit
  19fi
  20perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
  21    test_expect_success 'skipping git-cvsserver tests, Perl SQLite interface unavailable' :
  22    test_done
  23    exit
  24}
  25
  26unset GIT_DIR GIT_CONFIG
  27WORKDIR=$(pwd)
  28SERVERDIR=$(pwd)/gitcvs.git
  29CVSROOT=":fork:$SERVERDIR"
  30CVSWORK=$(pwd)/cvswork
  31CVS_SERVER=git-cvsserver
  32export CVSROOT CVS_SERVER
  33
  34rm -rf "$CVSWORK" "$SERVERDIR"
  35echo >empty &&
  36  git add empty &&
  37  git commit -q -m "First Commit" &&
  38  git clone -q --local --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 &&
  39  GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true &&
  40  GIT_DIR="$SERVERDIR" git config --bool gitcvs.logfile "$SERVERDIR/gitcvs.log" ||
  41  exit 1
  42
  43# note that cvs doesn't accept absolute pathnames
  44# as argument to co -d
  45test_expect_success 'basic checkout' \
  46  'cvs -Q co -d cvswork master &&
  47   test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5))" = "empty/1.1/"'
  48
  49test_expect_success 'cvs update (create new file)' \
  50  'echo testfile1 >testfile1 &&
  51   git add testfile1 &&
  52   git commit -q -m "Add testfile1" &&
  53   git push gitcvs.git >/dev/null &&
  54   cd cvswork &&
  55   cvs -Q update &&
  56   test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.1/" &&
  57   diff -q testfile1 ../testfile1'
  58
  59cd "$WORKDIR"
  60test_expect_success 'cvs update (update existing file)' \
  61  'echo line 2 >>testfile1 &&
  62   git add testfile1 &&
  63   git commit -q -m "Append to testfile1" &&
  64   git push gitcvs.git >/dev/null &&
  65   cd cvswork &&
  66   cvs -Q update &&
  67   test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.2/" &&
  68   diff -q testfile1 ../testfile1'
  69
  70cd "$WORKDIR"
  71#TODO: cvsserver doesn't support update w/o -d
  72test_expect_failure "cvs update w/o -d doesn't create subdir (TODO)" \
  73  'mkdir test &&
  74   echo >test/empty &&
  75   git add test &&
  76   git commit -q -m "Single Subdirectory" &&
  77   git push gitcvs.git >/dev/null &&
  78   cd cvswork &&
  79   cvs -Q update &&
  80   test ! -d test'
  81
  82cd "$WORKDIR"
  83test_expect_success 'cvs update (subdirectories)' \
  84  '(for dir in A A/B A/B/C A/D E; do
  85      mkdir $dir &&
  86      echo "test file in $dir" >"$dir/file_in_$(echo $dir|sed -e "s#/# #g")"  &&
  87      git add $dir;
  88   done) &&
  89   git commit -q -m "deep sub directory structure" &&
  90   git push gitcvs.git >/dev/null &&
  91   cd cvswork &&
  92   cvs -Q update -d &&
  93   (for dir in A A/B A/B/C A/D E; do
  94      filename="file_in_$(echo $dir|sed -e "s#/# #g")" &&
  95      if test "$(echo $(grep -v ^D $dir/CVS/Entries|cut -d/ -f2,3,5))" = "$filename/1.1/" &&
  96           diff -q "$dir/$filename" "../$dir/$filename"; then
  97        :
  98      else
  99        echo >failure
 100      fi
 101    done) &&
 102   test ! -f failure'
 103
 104cd "$WORKDIR"
 105test_expect_success 'cvs update (delete file)' \
 106  'git rm testfile1 &&
 107   git commit -q -m "Remove testfile1" &&
 108   git push gitcvs.git >/dev/null &&
 109   cd cvswork &&
 110   cvs -Q update &&
 111   test -z "$(grep testfile1 CVS/Entries)" &&
 112   test ! -f testfile1'
 113
 114cd "$WORKDIR"
 115test_expect_success 'cvs update (re-add deleted file)' \
 116  'echo readded testfile >testfile1 &&
 117   git add testfile1 &&
 118   git commit -q -m "Re-Add testfile1" &&
 119   git push gitcvs.git >/dev/null &&
 120   cd cvswork &&
 121   cvs -Q update &&
 122   test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.4/" &&
 123   diff -q testfile1 ../testfile1'
 124
 125test_done