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