3 # Copyright (c) 2007 Frank Lichtenheld
6 test_description
='git-cvsserver access
8 tests read access to a git repository with the
9 cvs CLI client via git-cvsserver server'
16 test_expect_success
'skipping git-cvsserver tests, cvs not found' :
20 perl
-e 'use DBI; use DBD::SQLite' >/dev
/null
2>&1 ||
{
21 test_expect_success
'skipping git-cvsserver tests, Perl SQLite interface unavailable' :
26 unset GIT_DIR GIT_CONFIG
28 SERVERDIR
=$
(pwd)/gitcvs.git
29 git_config
="$SERVERDIR/config"
30 CVSROOT
=":fork:$SERVERDIR"
31 CVSWORK
="$(pwd)/cvswork"
32 CVS_SERVER
=git-cvsserver
33 export CVSROOT CVS_SERVER
35 rm -rf "$CVSWORK" "$SERVERDIR"
38 git commit
-q -m "First Commit" &&
39 git clone
-q --local --bare "$WORKDIR/.git" "$SERVERDIR" >/dev
/null
2>&1 &&
40 GIT_DIR
="$SERVERDIR" git config
--bool gitcvs.enabled true
&&
41 GIT_DIR
="$SERVERDIR" git config
--bool gitcvs.logfile
"$SERVERDIR/gitcvs.log" ||
44 # note that cvs doesn't accept absolute pathnames
45 # as argument to co -d
46 test_expect_success
'basic checkout' \
47 'GIT_CONFIG="$git_config" cvs -Q co -d cvswork master &&
48 test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5))" = "empty/1.1/"'
54 test_expect_success
'gitcvs.enabled = false' \
55 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false &&
56 if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1
58 echo unexpected cvs success
63 cat cvs.log | grep -q "GITCVS emulation disabled" &&
67 test_expect_success
'gitcvs.ext.enabled = true' \
68 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true &&
69 GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false &&
70 GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 &&
71 diff -q cvswork cvswork2'
74 test_expect_success
'gitcvs.ext.enabled = false' \
75 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled false &&
76 GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true &&
77 if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1
79 echo unexpected cvs success
84 cat cvs.log | grep -q "GITCVS emulation disabled" &&
88 test_expect_success
'gitcvs.dbname' \
89 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true &&
90 GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs.%a.%m.sqlite &&
91 GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 &&
92 diff -q cvswork cvswork2 &&
93 test -f "$SERVERDIR/gitcvs.ext.master.sqlite" &&
94 cmp "$SERVERDIR/gitcvs.master.sqlite" "$SERVERDIR/gitcvs.ext.master.sqlite"'
97 test_expect_success
'gitcvs.ext.dbname' \
98 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true &&
99 GIT_DIR="$SERVERDIR" git config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite &&
100 GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite &&
101 GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 &&
102 diff -q cvswork cvswork2 &&
103 test -f "$SERVERDIR/gitcvs1.ext.master.sqlite" &&
104 test ! -f "$SERVERDIR/gitcvs2.ext.master.sqlite" &&
105 cmp "$SERVERDIR/gitcvs.master.sqlite" "$SERVERDIR/gitcvs1.ext.master.sqlite"'
114 git clone
-q --local --bare "$WORKDIR/.git" "$SERVERDIR" >/dev
/null
2>&1 &&
115 GIT_DIR
="$SERVERDIR" git config
--bool gitcvs.enabled true
&&
116 GIT_DIR
="$SERVERDIR" git config
--bool gitcvs.logfile
"$SERVERDIR/gitcvs.log" ||
119 test_expect_success
'cvs update (create new file)' \
120 'echo testfile1 >testfile1 &&
122 git commit -q -m "Add testfile1" &&
123 git push gitcvs.git >/dev/null &&
125 GIT_CONFIG="$git_config" cvs -Q update &&
126 test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.1/" &&
127 diff -q testfile1 ../testfile1'
130 test_expect_success
'cvs update (update existing file)' \
131 'echo line 2 >>testfile1 &&
133 git commit -q -m "Append to testfile1" &&
134 git push gitcvs.git >/dev/null &&
136 GIT_CONFIG="$git_config" cvs -Q update &&
137 test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.2/" &&
138 diff -q testfile1 ../testfile1'
141 #TODO: cvsserver doesn't support update w/o -d
142 test_expect_failure
"cvs update w/o -d doesn't create subdir (TODO)" \
146 git commit -q -m "Single Subdirectory" &&
147 git push gitcvs.git >/dev/null &&
149 GIT_CONFIG="$git_config" cvs -Q update &&
153 test_expect_success
'cvs update (subdirectories)' \
154 '(for dir in A A/B A/B/C A/D E; do
156 echo "test file in $dir" >"$dir/file_in_$(echo $dir|sed -e "s#/# #g")" &&
159 git commit -q -m "deep sub directory structure" &&
160 git push gitcvs.git >/dev/null &&
162 GIT_CONFIG="$git_config" cvs -Q update -d &&
163 (for dir in A A/B A/B/C A/D E; do
164 filename="file_in_$(echo $dir|sed -e "s#/# #g")" &&
165 if test "$(echo $(grep -v ^D $dir/CVS/Entries|cut -d/ -f2,3,5))" = "$filename/1.1/" &&
166 diff -q "$dir/$filename" "../$dir/$filename"; then
175 test_expect_success
'cvs update (delete file)' \
177 git commit -q -m "Remove testfile1" &&
178 git push gitcvs.git >/dev/null &&
180 GIT_CONFIG="$git_config" cvs -Q update &&
181 test -z "$(grep testfile1 CVS/Entries)" &&
185 test_expect_success
'cvs update (re-add deleted file)' \
186 'echo readded testfile >testfile1 &&
188 git commit -q -m "Re-Add testfile1" &&
189 git push gitcvs.git >/dev/null &&
191 GIT_CONFIG="$git_config" cvs -Q update &&
192 test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.4/" &&
193 diff -q testfile1 ../testfile1'