fixes to output of git-verify-pack -v
[git/jrn.git] / t / t9400-git-cvsserver-server.sh
blob7f9c6e29b233c785f927293268d97c07eac9db5e
1 #!/bin/sh
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'
11 . ./test-lib.sh
13 cvs >/dev/null 2>&1
14 if test $? -ne 1
15 then
16 test_expect_success 'skipping git-cvsserver tests, cvs not found' :
17 test_done
18 exit
20 perl -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
26 unset GIT_DIR GIT_CONFIG
27 WORKDIR=$(pwd)
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"
36 echo >empty &&
37 git add empty &&
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" ||
42 exit 1
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
55 BEGIN AUTH REQUEST
56 $SERVERDIR
57 anonymous
59 END AUTH REQUEST
60 EOF
62 cat >request-git <<EOF
63 BEGIN AUTH REQUEST
64 $SERVERDIR
65 git
67 END AUTH REQUEST
68 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
76 then
77 false
78 else
79 true
80 fi &&
81 tail -n1 log | grep -q "^I HATE YOU$"'
84 #--------------
85 # CONFIG TESTS
86 #--------------
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
91 then
92 echo unexpected cvs success
93 false
94 else
95 true
96 fi &&
97 cat cvs.log | grep -q "GITCVS emulation disabled" &&
98 test ! -d cvswork2'
100 rm -fr cvswork2
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'
107 rm -fr 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
112 then
113 echo unexpected cvs success
114 false
115 else
116 true
117 fi &&
118 cat cvs.log | grep -q "GITCVS emulation disabled" &&
119 test ! -d cvswork2'
121 rm -fr cvswork2
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"'
130 rm -fr cvswork2
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"'
142 #------------
143 # CVS UPDATE
144 #------------
146 rm -fr "$SERVERDIR"
147 cd "$WORKDIR" &&
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" ||
151 exit 1
153 test_expect_success 'cvs update (create new file)' \
154 'echo testfile1 >testfile1 &&
155 git add testfile1 &&
156 git commit -q -m "Add testfile1" &&
157 git push gitcvs.git >/dev/null &&
158 cd cvswork &&
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'
163 cd "$WORKDIR"
164 test_expect_success 'cvs update (update existing file)' \
165 'echo line 2 >>testfile1 &&
166 git add testfile1 &&
167 git commit -q -m "Append to testfile1" &&
168 git push gitcvs.git >/dev/null &&
169 cd cvswork &&
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'
174 cd "$WORKDIR"
175 #TODO: cvsserver doesn't support update w/o -d
176 test_expect_failure "cvs update w/o -d doesn't create subdir (TODO)" \
177 'mkdir test &&
178 echo >test/empty &&
179 git add test &&
180 git commit -q -m "Single Subdirectory" &&
181 git push gitcvs.git >/dev/null &&
182 cd cvswork &&
183 GIT_CONFIG="$git_config" cvs -Q update &&
184 test ! -d test'
186 cd "$WORKDIR"
187 test_expect_success 'cvs update (subdirectories)' \
188 '(for dir in A A/B A/B/C A/D E; do
189 mkdir $dir &&
190 echo "test file in $dir" >"$dir/file_in_$(echo $dir|sed -e "s#/# #g")" &&
191 git add $dir;
192 done) &&
193 git commit -q -m "deep sub directory structure" &&
194 git push gitcvs.git >/dev/null &&
195 cd cvswork &&
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
202 else
203 echo >failure
205 done) &&
206 test ! -f failure'
208 cd "$WORKDIR"
209 test_expect_success 'cvs update (delete file)' \
210 'git rm testfile1 &&
211 git commit -q -m "Remove testfile1" &&
212 git push gitcvs.git >/dev/null &&
213 cd cvswork &&
214 GIT_CONFIG="$git_config" cvs -Q update &&
215 test -z "$(grep testfile1 CVS/Entries)" &&
216 test ! -f testfile1'
218 cd "$WORKDIR"
219 test_expect_success 'cvs update (re-add deleted file)' \
220 'echo readded testfile >testfile1 &&
221 git add testfile1 &&
222 git commit -q -m "Re-Add testfile1" &&
223 git push gitcvs.git >/dev/null &&
224 cd cvswork &&
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'
229 cd "$WORKDIR"
230 test_expect_success 'cvs update (merge)' \
231 'echo Line 0 >expected &&
232 for i in 1 2 3 4 5 6 7
234 echo Line $i >>merge
235 echo Line $i >>expected
236 done &&
237 echo Line 8 >>expected &&
238 git add merge &&
239 git commit -q -m "Merge test (pre-merge)" &&
240 git push gitcvs.git >/dev/null &&
241 cd cvswork &&
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 &&
247 cd "$WORKDIR" &&
248 echo Line 8 >>merge &&
249 git add merge &&
250 git commit -q -m "Merge test (merge)" &&
251 git push gitcvs.git >/dev/null &&
252 cd cvswork &&
253 GIT_CONFIG="$git_config" cvs -Q update &&
254 diff -q merge ../expected'
256 cd "$WORKDIR"
258 cat >expected.C <<EOF
259 <<<<<<< merge.mine
260 Line 0
261 =======
262 LINE 0
263 >>>>>>> merge.3
266 for i in 1 2 3 4 5 6 7 8
268 echo Line $i >>expected.C
269 done
271 test_expect_success 'cvs update (conflict merge)' \
272 '( echo LINE 0; cat merge ) >merge.tmp &&
273 mv merge.tmp merge &&
274 git add merge &&
275 git commit -q -m "Merge test (conflict)" &&
276 git push gitcvs.git >/dev/null &&
277 cd cvswork &&
278 GIT_CONFIG="$git_config" cvs -Q update &&
279 diff -q merge ../expected.C'
281 cd "$WORKDIR"
282 test_expect_success 'cvs update (-C)' \
283 'cd cvswork &&
284 GIT_CONFIG="$git_config" cvs -Q update -C &&
285 diff -q merge ../merge'
287 cd "$WORKDIR"
288 test_expect_success 'cvs update (merge no-op)' \
289 'echo Line 9 >>merge &&
290 cp merge cvswork/merge &&
291 git add merge &&
292 git commit -q -m "Merge test (no-op)" &&
293 git push gitcvs.git >/dev/null &&
294 cd cvswork &&
295 GIT_CONFIG="$git_config" cvs -Q update &&
296 diff -q merge ../merge'
298 test_done