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/"'
50 #------------------------
51 # PSERVER AUTHENTICATION
52 #------------------------
54 cat >request-anonymous
<<EOF
62 cat >request-git
<<EOF
70 test_expect_success
'pserver authentication' \
71 'cat request-anonymous | git-cvsserver pserver >log 2>&1 &&
72 tail -n1 log | grep -q "^I LOVE YOU$"'
74 test_expect_success
'pserver authentication failure (non-anonymous user)' \
75 'if cat request-git | git-cvsserver pserver >log 2>&1
81 tail -n1 log | grep -q "^I HATE YOU$"'
88 test_expect_success
'gitcvs.enabled = false' \
89 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false &&
90 if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1
92 echo unexpected cvs success
97 cat cvs.log | grep -q "GITCVS emulation disabled" &&
101 test_expect_success
'gitcvs.ext.enabled = true' \
102 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true &&
103 GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false &&
104 GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 &&
105 diff -q cvswork cvswork2'
108 test_expect_success
'gitcvs.ext.enabled = false' \
109 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled false &&
110 GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true &&
111 if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1
113 echo unexpected cvs success
118 cat cvs.log | grep -q "GITCVS emulation disabled" &&
122 test_expect_success
'gitcvs.dbname' \
123 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true &&
124 GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs.%a.%m.sqlite &&
125 GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 &&
126 diff -q cvswork cvswork2 &&
127 test -f "$SERVERDIR/gitcvs.ext.master.sqlite" &&
128 cmp "$SERVERDIR/gitcvs.master.sqlite" "$SERVERDIR/gitcvs.ext.master.sqlite"'
131 test_expect_success
'gitcvs.ext.dbname' \
132 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true &&
133 GIT_DIR="$SERVERDIR" git config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite &&
134 GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite &&
135 GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 &&
136 diff -q cvswork cvswork2 &&
137 test -f "$SERVERDIR/gitcvs1.ext.master.sqlite" &&
138 test ! -f "$SERVERDIR/gitcvs2.ext.master.sqlite" &&
139 cmp "$SERVERDIR/gitcvs.master.sqlite" "$SERVERDIR/gitcvs1.ext.master.sqlite"'
148 git clone
-q --local --bare "$WORKDIR/.git" "$SERVERDIR" >/dev
/null
2>&1 &&
149 GIT_DIR
="$SERVERDIR" git config
--bool gitcvs.enabled true
&&
150 GIT_DIR
="$SERVERDIR" git config
--bool gitcvs.logfile
"$SERVERDIR/gitcvs.log" ||
153 test_expect_success
'cvs update (create new file)' \
154 'echo testfile1 >testfile1 &&
156 git commit -q -m "Add testfile1" &&
157 git push gitcvs.git >/dev/null &&
159 GIT_CONFIG="$git_config" cvs -Q update &&
160 test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.1/" &&
161 diff -q testfile1 ../testfile1'
164 test_expect_success
'cvs update (update existing file)' \
165 'echo line 2 >>testfile1 &&
167 git commit -q -m "Append to testfile1" &&
168 git push gitcvs.git >/dev/null &&
170 GIT_CONFIG="$git_config" cvs -Q update &&
171 test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.2/" &&
172 diff -q testfile1 ../testfile1'
175 #TODO: cvsserver doesn't support update w/o -d
176 test_expect_failure
"cvs update w/o -d doesn't create subdir (TODO)" \
180 git commit -q -m "Single Subdirectory" &&
181 git push gitcvs.git >/dev/null &&
183 GIT_CONFIG="$git_config" cvs -Q update &&
187 test_expect_success
'cvs update (subdirectories)' \
188 '(for dir in A A/B A/B/C A/D E; do
190 echo "test file in $dir" >"$dir/file_in_$(echo $dir|sed -e "s#/# #g")" &&
193 git commit -q -m "deep sub directory structure" &&
194 git push gitcvs.git >/dev/null &&
196 GIT_CONFIG="$git_config" cvs -Q update -d &&
197 (for dir in A A/B A/B/C A/D E; do
198 filename="file_in_$(echo $dir|sed -e "s#/# #g")" &&
199 if test "$(echo $(grep -v ^D $dir/CVS/Entries|cut -d/ -f2,3,5))" = "$filename/1.1/" &&
200 diff -q "$dir/$filename" "../$dir/$filename"; then
209 test_expect_success
'cvs update (delete file)' \
211 git commit -q -m "Remove testfile1" &&
212 git push gitcvs.git >/dev/null &&
214 GIT_CONFIG="$git_config" cvs -Q update &&
215 test -z "$(grep testfile1 CVS/Entries)" &&
219 test_expect_success
'cvs update (re-add deleted file)' \
220 'echo readded testfile >testfile1 &&
222 git commit -q -m "Re-Add testfile1" &&
223 git push gitcvs.git >/dev/null &&
225 GIT_CONFIG="$git_config" cvs -Q update &&
226 test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.4/" &&
227 diff -q testfile1 ../testfile1'
230 test_expect_success
'cvs update (merge)' \
231 'echo Line 0 >expected &&
232 for i in 1 2 3 4 5 6 7
235 echo Line $i >>expected
237 echo Line 8 >>expected &&
239 git commit -q -m "Merge test (pre-merge)" &&
240 git push gitcvs.git >/dev/null &&
242 GIT_CONFIG="$git_config" cvs -Q update &&
243 test "$(echo $(grep merge CVS/Entries|cut -d/ -f2,3,5))" = "merge/1.1/" &&
244 diff -q merge ../merge &&
245 ( echo Line 0; cat merge ) >merge.tmp &&
246 mv merge.tmp merge &&
248 echo Line 8 >>merge &&
250 git commit -q -m "Merge test (merge)" &&
251 git push gitcvs.git >/dev/null &&
253 GIT_CONFIG="$git_config" cvs -Q update &&
254 diff -q merge ../expected'
258 cat >expected.C
<<EOF
266 for i
in 1 2 3 4 5 6 7 8
268 echo Line
$i >>expected.C
271 test_expect_success
'cvs update (conflict merge)' \
272 '( echo LINE 0; cat merge ) >merge.tmp &&
273 mv merge.tmp merge &&
275 git commit -q -m "Merge test (conflict)" &&
276 git push gitcvs.git >/dev/null &&
278 GIT_CONFIG="$git_config" cvs -Q update &&
279 diff -q merge ../expected.C'
282 test_expect_success
'cvs update (-C)' \
284 GIT_CONFIG="$git_config" cvs -Q update -C &&
285 diff -q merge ../merge'
288 test_expect_success
'cvs update (merge no-op)' \
289 'echo Line 9 >>merge &&
290 cp merge cvswork/merge &&
292 git commit -q -m "Merge test (no-op)" &&
293 git push gitcvs.git >/dev/null &&
295 GIT_CONFIG="$git_config" cvs -Q update &&
296 diff -q merge ../merge'