]>
Commit | Line | Data |
---|---|---|
b3b53439 FL |
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 | ||
a881baa2 | 11 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
12 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
13 | ||
b3b53439 FL |
14 | . ./test-lib.sh |
15 | ||
1b19ccd2 | 16 | if ! test_have_prereq PERL; then |
fadb5156 | 17 | skip_all='skipping git cvsserver tests, perl not available' |
1b19ccd2 JK |
18 | test_done |
19 | fi | |
b3b53439 FL |
20 | cvs >/dev/null 2>&1 |
21 | if test $? -ne 1 | |
22 | then | |
fadb5156 | 23 | skip_all='skipping git-cvsserver tests, cvs not found' |
b3b53439 | 24 | test_done |
b3b53439 | 25 | fi |
94221d22 | 26 | perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || { |
fadb5156 | 27 | skip_all='skipping git-cvsserver tests, Perl SQLite interface unavailable' |
469be5b2 | 28 | test_done |
469be5b2 | 29 | } |
b3b53439 | 30 | |
fd318a94 JS |
31 | WORKDIR=$PWD |
32 | SERVERDIR=$PWD/gitcvs.git | |
a25907da | 33 | git_config="$SERVERDIR/config" |
b3b53439 | 34 | CVSROOT=":fork:$SERVERDIR" |
fd318a94 | 35 | CVSWORK="$PWD/cvswork" |
b3b53439 FL |
36 | CVS_SERVER=git-cvsserver |
37 | export CVSROOT CVS_SERVER | |
38 | ||
bffcb4d9 CMAB |
39 | if perl -e 'exit(1) if not defined crypt("", "cv")' |
40 | then | |
41 | PWDHASH='lac2ItudM3.KM' | |
42 | else | |
43 | PWDHASH='$2b$10$t8fGvE/a9eLmfOLzsZme2uOa2QtoMYwIxq9wZA6aBKtF1Yb7FJIzi' | |
44 | fi | |
a7775c7e | 45 | |
b3b53439 | 46 | rm -rf "$CVSWORK" "$SERVERDIR" |
75493765 | 47 | test_expect_success 'setup' ' |
a1c54d7b | 48 | git config push.default matching && |
75493765 | 49 | echo >empty && |
b3b53439 FL |
50 | git add empty && |
51 | git commit -q -m "First Commit" && | |
e509db99 SP |
52 | mkdir secondroot && |
53 | ( cd secondroot && | |
54 | git init && | |
55 | touch secondrootfile && | |
56 | git add secondrootfile && | |
57 | git commit -m "second root") && | |
a881baa2 | 58 | git fetch secondroot main && |
e379fdf3 | 59 | git merge --allow-unrelated-histories FETCH_HEAD && |
7fd3ef1f | 60 | git clone -q --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 && |
b3b53439 | 61 | GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true && |
1dd3f291 ÆAB |
62 | GIT_DIR="$SERVERDIR" git config gitcvs.logfile "$SERVERDIR/gitcvs.log" && |
63 | GIT_DIR="$SERVERDIR" git config gitcvs.authdb "$SERVERDIR/auth.db" && | |
a7775c7e | 64 | echo "cvsuser:$PWDHASH" >"$SERVERDIR/auth.db" |
75493765 | 65 | ' |
b3b53439 FL |
66 | |
67 | # note that cvs doesn't accept absolute pathnames | |
68 | # as argument to co -d | |
447a3b73 JC |
69 | test_expect_success 'basic checkout' ' |
70 | GIT_CONFIG="$git_config" cvs -Q co -d cvswork main && | |
71 | test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | head -n 1))" = "empty/1.1/" && | |
72 | test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | sed -ne \$p))" = "secondrootfile/1.1/" | |
73 | ' | |
b3b53439 | 74 | |
240ba7f2 FL |
75 | #------------------------ |
76 | # PSERVER AUTHENTICATION | |
77 | #------------------------ | |
78 | ||
79 | cat >request-anonymous <<EOF | |
80 | BEGIN AUTH REQUEST | |
81 | $SERVERDIR | |
82 | anonymous | |
83 | ||
84 | END AUTH REQUEST | |
85 | EOF | |
86 | ||
87 | cat >request-git <<EOF | |
88 | BEGIN AUTH REQUEST | |
89 | $SERVERDIR | |
90 | git | |
91 | ||
92 | END AUTH REQUEST | |
93 | EOF | |
94 | ||
24a97d84 FL |
95 | cat >login-anonymous <<EOF |
96 | BEGIN VERIFICATION REQUEST | |
97 | $SERVERDIR | |
98 | anonymous | |
99 | ||
100 | END VERIFICATION REQUEST | |
101 | EOF | |
102 | ||
103 | cat >login-git <<EOF | |
104 | BEGIN VERIFICATION REQUEST | |
105 | $SERVERDIR | |
106 | git | |
107 | ||
108 | END VERIFICATION REQUEST | |
109 | EOF | |
110 | ||
1dd3f291 ÆAB |
111 | cat >login-git-ok <<EOF |
112 | BEGIN VERIFICATION REQUEST | |
113 | $SERVERDIR | |
114 | cvsuser | |
115 | Ah<Z:yZZ30 e | |
116 | END VERIFICATION REQUEST | |
117 | EOF | |
118 | ||
447a3b73 | 119 | test_expect_success 'pserver authentication' ' |
af7dd8bd | 120 | git-cvsserver pserver <request-anonymous >log 2>&1 && |
447a3b73 JC |
121 | sed -ne \$p log | grep "^I LOVE YOU\$" |
122 | ' | |
240ba7f2 | 123 | |
447a3b73 | 124 | test_expect_success 'pserver authentication failure (non-anonymous user)' ' |
af7dd8bd | 125 | if git-cvsserver pserver <request-git >log 2>&1 |
447a3b73 JC |
126 | then |
127 | false | |
128 | else | |
129 | true | |
130 | fi && | |
131 | sed -ne \$p log | grep "^I HATE YOU\$" | |
132 | ' | |
240ba7f2 | 133 | |
447a3b73 | 134 | test_expect_success 'pserver authentication success (non-anonymous user with password)' ' |
af7dd8bd | 135 | git-cvsserver pserver <login-git-ok >log 2>&1 && |
447a3b73 JC |
136 | sed -ne \$p log | grep "^I LOVE YOU\$" |
137 | ' | |
1dd3f291 | 138 | |
447a3b73 | 139 | test_expect_success 'pserver authentication (login)' ' |
af7dd8bd | 140 | git-cvsserver pserver <login-anonymous >log 2>&1 && |
447a3b73 JC |
141 | sed -ne \$p log | grep "^I LOVE YOU\$" |
142 | ' | |
24a97d84 | 143 | |
447a3b73 | 144 | test_expect_success 'pserver authentication failure (login/non-anonymous user)' ' |
af7dd8bd | 145 | if git-cvsserver pserver <login-git >log 2>&1 |
447a3b73 JC |
146 | then |
147 | false | |
148 | else | |
149 | true | |
150 | fi && | |
151 | sed -ne \$p log | grep "^I HATE YOU\$" | |
152 | ' | |
24a97d84 | 153 | |
240ba7f2 | 154 | |
4890888d FL |
155 | # misuse pserver authentication for testing of req_Root |
156 | ||
157 | cat >request-relative <<EOF | |
158 | BEGIN AUTH REQUEST | |
159 | gitcvs.git | |
160 | anonymous | |
161 | ||
162 | END AUTH REQUEST | |
163 | EOF | |
164 | ||
165 | cat >request-conflict <<EOF | |
166 | BEGIN AUTH REQUEST | |
167 | $SERVERDIR | |
168 | anonymous | |
169 | ||
170 | END AUTH REQUEST | |
171 | Root $WORKDIR | |
172 | EOF | |
173 | ||
447a3b73 | 174 | test_expect_success 'req_Root failure (relative pathname)' ' |
af7dd8bd | 175 | if git-cvsserver pserver <request-relative >log 2>&1 |
447a3b73 JC |
176 | then |
177 | echo unexpected success | |
178 | false | |
179 | else | |
180 | true | |
181 | fi && | |
182 | tail log | grep "^error 1 Root must be an absolute pathname$" | |
183 | ' | |
4890888d | 184 | |
447a3b73 | 185 | test_expect_success 'req_Root failure (conflicting roots)' ' |
af7dd8bd | 186 | git-cvsserver pserver <request-conflict >log 2>&1 && |
447a3b73 JC |
187 | tail log | grep "^error 1 Conflicting roots specified$" |
188 | ' | |
4890888d | 189 | |
447a3b73 | 190 | test_expect_success 'req_Root (strict paths)' ' |
af7dd8bd | 191 | git-cvsserver --strict-paths pserver "$SERVERDIR" <request-anonymous >log 2>&1 && |
447a3b73 JC |
192 | sed -ne \$p log | grep "^I LOVE YOU\$" |
193 | ' | |
693b6327 | 194 | |
41ac414e | 195 | test_expect_success 'req_Root failure (strict-paths)' ' |
af7dd8bd | 196 | ! git-cvsserver --strict-paths pserver "$WORKDIR" <request-anonymous >log 2>&1 |
41ac414e | 197 | ' |
693b6327 | 198 | |
447a3b73 | 199 | test_expect_success 'req_Root (w/o strict-paths)' ' |
af7dd8bd | 200 | git-cvsserver pserver "$WORKDIR/" <request-anonymous >log 2>&1 && |
447a3b73 JC |
201 | sed -ne \$p log | grep "^I LOVE YOU\$" |
202 | ' | |
693b6327 | 203 | |
41ac414e | 204 | test_expect_success 'req_Root failure (w/o strict-paths)' ' |
af7dd8bd | 205 | ! git-cvsserver pserver "$WORKDIR/gitcvs" <request-anonymous >log 2>&1 |
41ac414e | 206 | ' |
693b6327 FL |
207 | |
208 | cat >request-base <<EOF | |
209 | BEGIN AUTH REQUEST | |
210 | /gitcvs.git | |
211 | anonymous | |
212 | ||
213 | END AUTH REQUEST | |
fd1cd91e | 214 | Root /gitcvs.git |
693b6327 FL |
215 | EOF |
216 | ||
447a3b73 | 217 | test_expect_success 'req_Root (base-path)' ' |
af7dd8bd | 218 | git-cvsserver --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" <request-base >log 2>&1 && |
447a3b73 JC |
219 | sed -ne \$p log | grep "^I LOVE YOU\$" |
220 | ' | |
693b6327 | 221 | |
41ac414e | 222 | test_expect_success 'req_Root failure (base-path)' ' |
af7dd8bd | 223 | ! git-cvsserver --strict-paths --base-path "$WORKDIR" pserver "$SERVERDIR" <request-anonymous >log 2>&1 |
41ac414e | 224 | ' |
4890888d | 225 | |
226bccb9 FL |
226 | GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false || exit 1 |
227 | ||
447a3b73 | 228 | test_expect_success 'req_Root (export-all)' ' |
af7dd8bd | 229 | git-cvsserver --export-all pserver "$WORKDIR" <request-anonymous >log 2>&1 && |
447a3b73 JC |
230 | sed -ne \$p log | grep "^I LOVE YOU\$" |
231 | ' | |
226bccb9 | 232 | |
447a3b73 | 233 | test_expect_success 'req_Root failure (export-all w/o directory list)' ' |
af7dd8bd | 234 | ! (git-cvsserver --export-all pserver <request-anonymous >log 2>&1 || false)' |
226bccb9 | 235 | |
447a3b73 | 236 | test_expect_success 'req_Root (everything together)' ' |
af7dd8bd | 237 | git-cvsserver --export-all --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" <request-base >log 2>&1 && |
447a3b73 JC |
238 | sed -ne \$p log | grep "^I LOVE YOU\$" |
239 | ' | |
226bccb9 FL |
240 | |
241 | GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true || exit 1 | |
242 | ||
1d431b22 FL |
243 | #-------------- |
244 | # CONFIG TESTS | |
245 | #-------------- | |
246 | ||
247 | test_expect_success 'gitcvs.enabled = false' \ | |
248 | 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false && | |
a881baa2 | 249 | if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1 |
1d431b22 FL |
250 | then |
251 | echo unexpected cvs success | |
252 | false | |
253 | else | |
254 | true | |
255 | fi && | |
aadbe44f | 256 | grep "GITCVS emulation disabled" cvs.log && |
1d431b22 FL |
257 | test ! -d cvswork2' |
258 | ||
259 | rm -fr cvswork2 | |
447a3b73 JC |
260 | test_expect_success 'gitcvs.ext.enabled = true' ' |
261 | GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true && | |
262 | GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false && | |
263 | GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1 && | |
264 | test_cmp cvswork cvswork2 | |
265 | ' | |
1d431b22 FL |
266 | |
267 | rm -fr cvswork2 | |
447a3b73 JC |
268 | test_expect_success 'gitcvs.ext.enabled = false' ' |
269 | GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled false && | |
270 | GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true && | |
271 | if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1 | |
272 | then | |
273 | echo unexpected cvs success | |
274 | false | |
275 | else | |
276 | true | |
277 | fi && | |
278 | grep "GITCVS emulation disabled" cvs.log && | |
279 | test ! -d cvswork2 | |
280 | ' | |
1d431b22 FL |
281 | |
282 | rm -fr cvswork2 | |
447a3b73 JC |
283 | test_expect_success 'gitcvs.dbname' ' |
284 | GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true && | |
285 | GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs.%a.%m.sqlite && | |
286 | GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1 && | |
287 | test_cmp cvswork cvswork2 && | |
288 | test -f "$SERVERDIR/gitcvs.ext.main.sqlite" && | |
289 | cmp "$SERVERDIR/gitcvs.main.sqlite" "$SERVERDIR/gitcvs.ext.main.sqlite" | |
290 | ' | |
1d431b22 FL |
291 | |
292 | rm -fr cvswork2 | |
447a3b73 JC |
293 | test_expect_success 'gitcvs.ext.dbname' ' |
294 | GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true && | |
295 | GIT_DIR="$SERVERDIR" git config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite && | |
296 | GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite && | |
297 | GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 main >cvs.log 2>&1 && | |
298 | test_cmp cvswork cvswork2 && | |
299 | test -f "$SERVERDIR/gitcvs1.ext.main.sqlite" && | |
300 | test ! -f "$SERVERDIR/gitcvs2.ext.main.sqlite" && | |
301 | cmp "$SERVERDIR/gitcvs.main.sqlite" "$SERVERDIR/gitcvs1.ext.main.sqlite" | |
302 | ' | |
1d431b22 FL |
303 | |
304 | ||
305 | #------------ | |
306 | # CVS UPDATE | |
307 | #------------ | |
308 | ||
309 | rm -fr "$SERVERDIR" | |
310 | cd "$WORKDIR" && | |
7fd3ef1f | 311 | git clone -q --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 && |
1d431b22 | 312 | GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true && |
db1696b8 | 313 | GIT_DIR="$SERVERDIR" git config gitcvs.logfile "$SERVERDIR/gitcvs.log" || |
1d431b22 FL |
314 | exit 1 |
315 | ||
447a3b73 JC |
316 | test_expect_success 'cvs update (create new file)' ' |
317 | echo testfile1 >testfile1 && | |
318 | git add testfile1 && | |
319 | git commit -q -m "Add testfile1" && | |
320 | git push gitcvs.git >/dev/null && | |
321 | cd cvswork && | |
322 | GIT_CONFIG="$git_config" cvs -Q update && | |
323 | test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.1/" && | |
324 | test_cmp testfile1 ../testfile1 | |
325 | ' | |
b3b53439 FL |
326 | |
327 | cd "$WORKDIR" | |
447a3b73 JC |
328 | test_expect_success 'cvs update (update existing file)' ' |
329 | echo line 2 >>testfile1 && | |
330 | git add testfile1 && | |
331 | git commit -q -m "Append to testfile1" && | |
332 | git push gitcvs.git >/dev/null && | |
333 | cd cvswork && | |
334 | GIT_CONFIG="$git_config" cvs -Q update && | |
335 | test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.2/" && | |
336 | test_cmp testfile1 ../testfile1 | |
337 | ' | |
b3b53439 FL |
338 | |
339 | cd "$WORKDIR" | |
340 | #TODO: cvsserver doesn't support update w/o -d | |
41ac414e | 341 | test_expect_failure "cvs update w/o -d doesn't create subdir (TODO)" ' |
447a3b73 JC |
342 | mkdir test && |
343 | echo >test/empty && | |
344 | git add test && | |
345 | git commit -q -m "Single Subdirectory" && | |
346 | git push gitcvs.git >/dev/null && | |
347 | cd cvswork && | |
348 | GIT_CONFIG="$git_config" cvs -Q update && | |
349 | test ! -d test | |
41ac414e | 350 | ' |
b3b53439 FL |
351 | |
352 | cd "$WORKDIR" | |
447a3b73 JC |
353 | test_expect_success 'cvs update (subdirectories)' ' |
354 | (for dir in A A/B A/B/C A/D E; do | |
355 | mkdir $dir && | |
356 | echo "test file in $dir" >"$dir/file_in_$(echo $dir|sed -e "s#/# #g")" && | |
357 | git add $dir || exit 1 | |
358 | done) && | |
359 | git commit -q -m "deep sub directory structure" && | |
360 | git push gitcvs.git >/dev/null && | |
361 | cd cvswork && | |
362 | GIT_CONFIG="$git_config" cvs -Q update -d && | |
363 | (for dir in A A/B A/B/C A/D E; do | |
364 | filename="file_in_$(echo $dir|sed -e "s#/# #g")" && | |
365 | if test "$(echo $(grep -v ^D $dir/CVS/Entries|cut -d/ -f2,3,5))" = "$filename/1.1/" && | |
366 | test_cmp "$dir/$filename" "../$dir/$filename"; then | |
367 | : | |
368 | else | |
369 | exit 1 | |
370 | fi | |
371 | done) | |
372 | ' | |
b3b53439 FL |
373 | |
374 | cd "$WORKDIR" | |
447a3b73 JC |
375 | test_expect_success 'cvs update (delete file)' ' |
376 | git rm testfile1 && | |
377 | git commit -q -m "Remove testfile1" && | |
378 | git push gitcvs.git >/dev/null && | |
379 | cd cvswork && | |
380 | GIT_CONFIG="$git_config" cvs -Q update && | |
381 | test -z "$(grep testfile1 CVS/Entries)" && | |
382 | test ! -f testfile1 | |
383 | ' | |
b3b53439 FL |
384 | |
385 | cd "$WORKDIR" | |
447a3b73 JC |
386 | test_expect_success 'cvs update (re-add deleted file)' ' |
387 | echo readded testfile >testfile1 && | |
388 | git add testfile1 && | |
389 | git commit -q -m "Re-Add testfile1" && | |
390 | git push gitcvs.git >/dev/null && | |
391 | cd cvswork && | |
392 | GIT_CONFIG="$git_config" cvs -Q update && | |
393 | test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.4/" && | |
394 | test_cmp testfile1 ../testfile1 | |
395 | ' | |
b3b53439 | 396 | |
1978659a | 397 | cd "$WORKDIR" |
447a3b73 JC |
398 | test_expect_success 'cvs update (merge)' ' |
399 | echo Line 0 >expected && | |
400 | for i in 1 2 3 4 5 6 7 | |
401 | do | |
402 | echo Line $i >>merge && | |
403 | echo Line $i >>expected || return 1 | |
404 | done && | |
405 | echo Line 8 >>expected && | |
406 | git add merge && | |
407 | git commit -q -m "Merge test (pre-merge)" && | |
408 | git push gitcvs.git >/dev/null && | |
409 | cd cvswork && | |
410 | GIT_CONFIG="$git_config" cvs -Q update && | |
411 | test "$(echo $(grep merge CVS/Entries|cut -d/ -f2,3,5))" = "merge/1.1/" && | |
412 | test_cmp merge ../merge && | |
413 | ( echo Line 0 && cat merge ) >merge.tmp && | |
414 | mv merge.tmp merge && | |
415 | cd "$WORKDIR" && | |
416 | echo Line 8 >>merge && | |
417 | git add merge && | |
418 | git commit -q -m "Merge test (merge)" && | |
419 | git push gitcvs.git >/dev/null && | |
420 | cd cvswork && | |
421 | sleep 1 && touch merge && | |
422 | GIT_CONFIG="$git_config" cvs -Q update && | |
423 | test_cmp merge ../expected | |
424 | ' | |
1978659a FL |
425 | |
426 | cd "$WORKDIR" | |
427 | ||
428 | cat >expected.C <<EOF | |
429 | <<<<<<< merge.mine | |
430 | Line 0 | |
431 | ======= | |
432 | LINE 0 | |
ab07681f | 433 | >>>>>>> merge.1.3 |
1978659a FL |
434 | EOF |
435 | ||
436 | for i in 1 2 3 4 5 6 7 8 | |
437 | do | |
438 | echo Line $i >>expected.C | |
439 | done | |
440 | ||
447a3b73 JC |
441 | test_expect_success 'cvs update (conflict merge)' ' |
442 | ( echo LINE 0 && cat merge ) >merge.tmp && | |
443 | mv merge.tmp merge && | |
444 | git add merge && | |
445 | git commit -q -m "Merge test (conflict)" && | |
446 | git push gitcvs.git >/dev/null && | |
447 | cd cvswork && | |
448 | GIT_CONFIG="$git_config" cvs -Q update && | |
449 | test_cmp merge ../expected.C | |
450 | ' | |
1978659a FL |
451 | |
452 | cd "$WORKDIR" | |
447a3b73 JC |
453 | test_expect_success 'cvs update (-C)' ' |
454 | cd cvswork && | |
455 | GIT_CONFIG="$git_config" cvs -Q update -C && | |
456 | test_cmp merge ../merge | |
457 | ' | |
1978659a FL |
458 | |
459 | cd "$WORKDIR" | |
447a3b73 JC |
460 | test_expect_success 'cvs update (merge no-op)' ' |
461 | echo Line 9 >>merge && | |
462 | cp merge cvswork/merge && | |
463 | git add merge && | |
464 | git commit -q -m "Merge test (no-op)" && | |
465 | git push gitcvs.git >/dev/null && | |
466 | cd cvswork && | |
467 | sleep 1 && touch merge && | |
468 | GIT_CONFIG="$git_config" cvs -Q update && | |
469 | test_cmp merge ../merge | |
470 | ' | |
1978659a | 471 | |
6e8937a0 DD |
472 | cd "$WORKDIR" |
473 | test_expect_success 'cvs update (-p)' ' | |
447a3b73 JC |
474 | touch really-empty && |
475 | echo Line 1 > no-lf && | |
476 | printf "Line 2" >> no-lf && | |
477 | git add really-empty no-lf && | |
478 | git commit -q -m "Update -p test" && | |
479 | git push gitcvs.git >/dev/null && | |
480 | cd cvswork && | |
481 | GIT_CONFIG="$git_config" cvs update && | |
482 | for i in merge no-lf empty really-empty; do | |
483 | GIT_CONFIG="$git_config" cvs update -p "$i" >$i.out && | |
484 | test_cmp $i.out ../$i || return 1 | |
485 | done | |
6e8937a0 DD |
486 | ' |
487 | ||
b0f2ecf5 LN |
488 | cd "$WORKDIR" |
489 | test_expect_success 'cvs update (module list supports packed refs)' ' | |
447a3b73 JC |
490 | GIT_DIR="$SERVERDIR" git pack-refs --all && |
491 | GIT_CONFIG="$git_config" cvs -n up -d 2> out && | |
492 | grep "cvs update: New directory \`main'\''" < out | |
b0f2ecf5 LN |
493 | ' |
494 | ||
dded801a DD |
495 | #------------ |
496 | # CVS STATUS | |
497 | #------------ | |
498 | ||
499 | cd "$WORKDIR" | |
500 | test_expect_success 'cvs status' ' | |
447a3b73 JC |
501 | mkdir status.dir && |
502 | echo Line > status.dir/status.file && | |
503 | echo Line > status.file && | |
504 | git add status.dir status.file && | |
505 | git commit -q -m "Status test" && | |
506 | git push gitcvs.git >/dev/null && | |
507 | cd cvswork && | |
508 | GIT_CONFIG="$git_config" cvs update && | |
509 | GIT_CONFIG="$git_config" cvs status | grep "^File: status.file" >../out && | |
510 | test_line_count = 2 ../out | |
dded801a DD |
511 | ' |
512 | ||
513 | cd "$WORKDIR" | |
514 | test_expect_success 'cvs status (nonrecursive)' ' | |
447a3b73 JC |
515 | cd cvswork && |
516 | GIT_CONFIG="$git_config" cvs status -l | grep "^File: status.file" >../out && | |
517 | test_line_count = 1 ../out | |
dded801a DD |
518 | ' |
519 | ||
520 | cd "$WORKDIR" | |
521 | test_expect_success 'cvs status (no subdirs in header)' ' | |
447a3b73 JC |
522 | cd cvswork && |
523 | GIT_CONFIG="$git_config" cvs status | grep ^File: >../out && | |
524 | ! grep / <../out | |
dded801a DD |
525 | ' |
526 | ||
42f7a2da FE |
527 | #------------ |
528 | # CVS CHECKOUT | |
529 | #------------ | |
530 | ||
531 | cd "$WORKDIR" | |
532 | test_expect_success 'cvs co -c (shows module database)' ' | |
447a3b73 JC |
533 | GIT_CONFIG="$git_config" cvs co -c > out && |
534 | grep "^main[ ][ ]*main$" <out && | |
535 | ! grep -v "^main[ ][ ]*main$" <out | |
42f7a2da FE |
536 | ' |
537 | ||
ef6fd72b MO |
538 | #------------ |
539 | # CVS LOG | |
540 | #------------ | |
541 | ||
542 | # Known issues with git-cvsserver current log output: | |
543 | # - Hard coded "lines: +2 -3" placeholder, instead of real numbers. | |
544 | # - CVS normally does not internally add a blank first line | |
235e8d59 | 545 | # or a last line with nothing but a space to log messages. |
ef6fd72b MO |
546 | # - The latest cvs 1.12.x server sends +0000 timezone (with some hidden "MT" |
547 | # tagging in the protocol), and if cvs 1.12.x client sees the MT tags, | |
548 | # it converts to local time zone. git-cvsserver doesn't do the +0000 | |
549 | # or the MT tags... | |
550 | # - The latest 1.12.x releases add a "commitid:" field on to the end of the | |
551 | # "date:" line (after "lines:"). Maybe we could stick git's commit id | |
552 | # in it? Or does CVS expect a certain number of bits (too few for | |
553 | # a full sha1)? | |
554 | # | |
555 | # Given the above, expect the following test to break if git-cvsserver's | |
556 | # log output is improved. The test is just to ensure it doesn't | |
557 | # accidentally get worse. | |
558 | ||
559 | sed -e 's/^x//' -e 's/SP$/ /' > "$WORKDIR/expect" <<EOF | |
560 | x | |
a881baa2 | 561 | xRCS file: $WORKDIR/gitcvs.git/main/merge,v |
ef6fd72b MO |
562 | xWorking file: merge |
563 | xhead: 1.4 | |
564 | xbranch: | |
565 | xlocks: strict | |
566 | xaccess list: | |
567 | xsymbolic names: | |
568 | xkeyword substitution: kv | |
569 | xtotal revisions: 4; selected revisions: 4 | |
570 | xdescription: | |
571 | x---------------------------- | |
572 | xrevision 1.4 | |
573 | xdate: __DATE__; author: author; state: Exp; lines: +2 -3 | |
574 | x | |
575 | xMerge test (no-op) | |
576 | xSP | |
577 | x---------------------------- | |
578 | xrevision 1.3 | |
579 | xdate: __DATE__; author: author; state: Exp; lines: +2 -3 | |
580 | x | |
581 | xMerge test (conflict) | |
582 | xSP | |
583 | x---------------------------- | |
584 | xrevision 1.2 | |
585 | xdate: __DATE__; author: author; state: Exp; lines: +2 -3 | |
586 | x | |
587 | xMerge test (merge) | |
588 | xSP | |
589 | x---------------------------- | |
590 | xrevision 1.1 | |
591 | xdate: __DATE__; author: author; state: Exp; lines: +2 -3 | |
592 | x | |
593 | xMerge test (pre-merge) | |
594 | xSP | |
595 | x============================================================================= | |
596 | EOF | |
597 | expectStat="$?" | |
598 | ||
599 | cd "$WORKDIR" | |
600 | test_expect_success 'cvs log' ' | |
447a3b73 JC |
601 | cd cvswork && |
602 | test x"$expectStat" = x"0" && | |
603 | GIT_CONFIG="$git_config" cvs log merge >../out && | |
604 | 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 && | |
605 | test_cmp ../expect ../actual | |
ef6fd72b MO |
606 | ' |
607 | ||
7ceacdff JH |
608 | #------------ |
609 | # CVS ANNOTATE | |
610 | #------------ | |
611 | ||
612 | cd "$WORKDIR" | |
613 | test_expect_success 'cvs annotate' ' | |
447a3b73 JC |
614 | cd cvswork && |
615 | GIT_CONFIG="$git_config" cvs annotate merge >../out && | |
616 | sed -e "s/ .*//" ../out >../actual && | |
617 | printf "1.%d\n" 3 1 1 1 1 1 1 1 2 4 >../expect && | |
618 | test_cmp ../expect ../actual | |
7ceacdff JH |
619 | ' |
620 | ||
9a42c03c JK |
621 | #------------ |
622 | # running via git-shell | |
623 | #------------ | |
624 | ||
625 | cd "$WORKDIR" | |
626 | ||
627 | test_expect_success 'create remote-cvs helper' ' | |
628 | write_script remote-cvs <<-\EOF | |
629 | exec git shell -c "cvs server" | |
630 | EOF | |
631 | ' | |
632 | ||
633 | test_expect_success 'cvs server does not run with vanilla git-shell' ' | |
634 | ( | |
635 | cd cvswork && | |
636 | CVS_SERVER=$WORKDIR/remote-cvs && | |
637 | export CVS_SERVER && | |
41feac6f | 638 | ! cvs log merge |
9a42c03c JK |
639 | ) |
640 | ' | |
641 | ||
642 | test_expect_success 'configure git shell to run cvs server' ' | |
643 | mkdir "$HOME"/git-shell-commands && | |
644 | ||
645 | write_script "$HOME"/git-shell-commands/cvs <<-\EOF && | |
646 | if ! test $# = 1 && test "$1" = "server" | |
647 | then | |
648 | echo >&2 "git-cvsserver only handles \"server\"" | |
649 | exit 1 | |
650 | fi | |
651 | exec git cvsserver server | |
652 | EOF | |
653 | ||
654 | # Should not be used, but part of the recommended setup | |
655 | write_script "$HOME"/git-shell-commands/no-interactive-login <<-\EOF | |
656 | echo Interactive login forbidden | |
657 | EOF | |
658 | ' | |
659 | ||
660 | test_expect_success 'cvs server can run with recommended config' ' | |
661 | ( | |
662 | cd cvswork && | |
663 | CVS_SERVER=$WORKDIR/remote-cvs && | |
664 | export CVS_SERVER && | |
665 | cvs log merge | |
666 | ) | |
667 | ' | |
668 | ||
b3b53439 | 669 | test_done |