Frank Lichtenheld | b3b5343 | 2007-05-02 02:45:22 +0200 | [diff] [blame] | 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 | |
| 11 | . ./test-lib.sh |
| 12 | |
Jeff King | 1b19ccd | 2009-04-03 15:33:59 -0400 | [diff] [blame] | 13 | if ! test_have_prereq PERL; then |
Ævar Arnfjörð Bjarmason | fadb515 | 2010-06-24 17:44:48 +0000 | [diff] [blame] | 14 | skip_all='skipping git cvsserver tests, perl not available' |
Jeff King | 1b19ccd | 2009-04-03 15:33:59 -0400 | [diff] [blame] | 15 | test_done |
| 16 | fi |
Frank Lichtenheld | b3b5343 | 2007-05-02 02:45:22 +0200 | [diff] [blame] | 17 | cvs >/dev/null 2>&1 |
| 18 | if test $? -ne 1 |
| 19 | then |
Ævar Arnfjörð Bjarmason | fadb515 | 2010-06-24 17:44:48 +0000 | [diff] [blame] | 20 | skip_all='skipping git-cvsserver tests, cvs not found' |
Frank Lichtenheld | b3b5343 | 2007-05-02 02:45:22 +0200 | [diff] [blame] | 21 | test_done |
Frank Lichtenheld | b3b5343 | 2007-05-02 02:45:22 +0200 | [diff] [blame] | 22 | fi |
Philippe Bruhat (BooK) | be38ca3 | 2009-11-17 09:42:39 +0100 | [diff] [blame] | 23 | "$PERL_PATH" -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || { |
Ævar Arnfjörð Bjarmason | fadb515 | 2010-06-24 17:44:48 +0000 | [diff] [blame] | 24 | skip_all='skipping git-cvsserver tests, Perl SQLite interface unavailable' |
Junio C Hamano | 469be5b | 2007-05-09 09:19:42 -0700 | [diff] [blame] | 25 | test_done |
Junio C Hamano | 469be5b | 2007-05-09 09:19:42 -0700 | [diff] [blame] | 26 | } |
Frank Lichtenheld | b3b5343 | 2007-05-02 02:45:22 +0200 | [diff] [blame] | 27 | |
| 28 | unset GIT_DIR GIT_CONFIG |
| 29 | WORKDIR=$(pwd) |
| 30 | SERVERDIR=$(pwd)/gitcvs.git |
Junio Hamano | a25907d | 2007-05-11 16:35:18 -0700 | [diff] [blame] | 31 | git_config="$SERVERDIR/config" |
Frank Lichtenheld | b3b5343 | 2007-05-02 02:45:22 +0200 | [diff] [blame] | 32 | CVSROOT=":fork:$SERVERDIR" |
Junio Hamano | a25907d | 2007-05-11 16:35:18 -0700 | [diff] [blame] | 33 | CVSWORK="$(pwd)/cvswork" |
Frank Lichtenheld | b3b5343 | 2007-05-02 02:45:22 +0200 | [diff] [blame] | 34 | CVS_SERVER=git-cvsserver |
| 35 | export CVSROOT CVS_SERVER |
| 36 | |
| 37 | rm -rf "$CVSWORK" "$SERVERDIR" |
Steffen Prohaska | 7549376 | 2008-01-26 10:54:05 +0100 | [diff] [blame] | 38 | test_expect_success 'setup' ' |
| 39 | echo >empty && |
Frank Lichtenheld | b3b5343 | 2007-05-02 02:45:22 +0200 | [diff] [blame] | 40 | git add empty && |
| 41 | git commit -q -m "First Commit" && |
Steffen Prohaska | e509db9 | 2008-01-26 10:54:06 +0100 | [diff] [blame] | 42 | mkdir secondroot && |
| 43 | ( cd secondroot && |
| 44 | git init && |
| 45 | touch secondrootfile && |
| 46 | git add secondrootfile && |
| 47 | git commit -m "second root") && |
| 48 | git pull secondroot master && |
Johannes Sixt | 7fd3ef1 | 2009-03-07 00:04:09 +0100 | [diff] [blame] | 49 | git clone -q --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 && |
Frank Lichtenheld | b3b5343 | 2007-05-02 02:45:22 +0200 | [diff] [blame] | 50 | GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true && |
Ævar Arnfjörð Bjarmason | 1dd3f29 | 2010-05-15 02:46:04 +0000 | [diff] [blame] | 51 | GIT_DIR="$SERVERDIR" git config gitcvs.logfile "$SERVERDIR/gitcvs.log" && |
| 52 | GIT_DIR="$SERVERDIR" git config gitcvs.authdb "$SERVERDIR/auth.db" && |
| 53 | echo cvsuser:cvGVEarMLnhlA > "$SERVERDIR/auth.db" |
Steffen Prohaska | 7549376 | 2008-01-26 10:54:05 +0100 | [diff] [blame] | 54 | ' |
Frank Lichtenheld | b3b5343 | 2007-05-02 02:45:22 +0200 | [diff] [blame] | 55 | |
| 56 | # note that cvs doesn't accept absolute pathnames |
| 57 | # as argument to co -d |
| 58 | test_expect_success 'basic checkout' \ |
Junio Hamano | a25907d | 2007-05-11 16:35:18 -0700 | [diff] [blame] | 59 | 'GIT_CONFIG="$git_config" cvs -Q co -d cvswork master && |
Jonathan Nieder | a48fcd8 | 2010-10-30 20:46:54 -0500 | [diff] [blame] | 60 | test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | head -n 1))" = "empty/1.1/" && |
Jeff King | b4ce54f | 2008-03-12 17:34:34 -0400 | [diff] [blame] | 61 | test "$(echo $(grep -v ^D cvswork/CVS/Entries|cut -d/ -f2,3,5 | sed -ne \$p))" = "secondrootfile/1.1/"' |
Frank Lichtenheld | b3b5343 | 2007-05-02 02:45:22 +0200 | [diff] [blame] | 62 | |
Frank Lichtenheld | 240ba7f | 2007-05-21 00:31:58 +0200 | [diff] [blame] | 63 | #------------------------ |
| 64 | # PSERVER AUTHENTICATION |
| 65 | #------------------------ |
| 66 | |
| 67 | cat >request-anonymous <<EOF |
| 68 | BEGIN AUTH REQUEST |
| 69 | $SERVERDIR |
| 70 | anonymous |
| 71 | |
| 72 | END AUTH REQUEST |
| 73 | EOF |
| 74 | |
| 75 | cat >request-git <<EOF |
| 76 | BEGIN AUTH REQUEST |
| 77 | $SERVERDIR |
| 78 | git |
| 79 | |
| 80 | END AUTH REQUEST |
| 81 | EOF |
| 82 | |
Frank Lichtenheld | 24a97d8 | 2007-05-27 14:33:10 +0200 | [diff] [blame] | 83 | cat >login-anonymous <<EOF |
| 84 | BEGIN VERIFICATION REQUEST |
| 85 | $SERVERDIR |
| 86 | anonymous |
| 87 | |
| 88 | END VERIFICATION REQUEST |
| 89 | EOF |
| 90 | |
| 91 | cat >login-git <<EOF |
| 92 | BEGIN VERIFICATION REQUEST |
| 93 | $SERVERDIR |
| 94 | git |
| 95 | |
| 96 | END VERIFICATION REQUEST |
| 97 | EOF |
| 98 | |
Ævar Arnfjörð Bjarmason | 1dd3f29 | 2010-05-15 02:46:04 +0000 | [diff] [blame] | 99 | cat >login-git-ok <<EOF |
| 100 | BEGIN VERIFICATION REQUEST |
| 101 | $SERVERDIR |
| 102 | cvsuser |
| 103 | Ah<Z:yZZ30 e |
| 104 | END VERIFICATION REQUEST |
| 105 | EOF |
| 106 | |
Frank Lichtenheld | 240ba7f | 2007-05-21 00:31:58 +0200 | [diff] [blame] | 107 | test_expect_success 'pserver authentication' \ |
| 108 | 'cat request-anonymous | git-cvsserver pserver >log 2>&1 && |
Stephen Boyd | 9524cf2 | 2010-01-26 15:08:31 -0800 | [diff] [blame] | 109 | sed -ne \$p log | grep "^I LOVE YOU\$"' |
Frank Lichtenheld | 240ba7f | 2007-05-21 00:31:58 +0200 | [diff] [blame] | 110 | |
| 111 | test_expect_success 'pserver authentication failure (non-anonymous user)' \ |
| 112 | 'if cat request-git | git-cvsserver pserver >log 2>&1 |
| 113 | then |
| 114 | false |
| 115 | else |
| 116 | true |
| 117 | fi && |
Stephen Boyd | 9524cf2 | 2010-01-26 15:08:31 -0800 | [diff] [blame] | 118 | sed -ne \$p log | grep "^I HATE YOU\$"' |
Frank Lichtenheld | 240ba7f | 2007-05-21 00:31:58 +0200 | [diff] [blame] | 119 | |
Ævar Arnfjörð Bjarmason | 1dd3f29 | 2010-05-15 02:46:04 +0000 | [diff] [blame] | 120 | test_expect_success 'pserver authentication success (non-anonymous user with password)' \ |
| 121 | 'cat login-git-ok | git-cvsserver pserver >log 2>&1 && |
| 122 | sed -ne \$p log | grep "^I LOVE YOU\$"' |
| 123 | |
Frank Lichtenheld | 24a97d8 | 2007-05-27 14:33:10 +0200 | [diff] [blame] | 124 | test_expect_success 'pserver authentication (login)' \ |
| 125 | 'cat login-anonymous | git-cvsserver pserver >log 2>&1 && |
Stephen Boyd | 9524cf2 | 2010-01-26 15:08:31 -0800 | [diff] [blame] | 126 | sed -ne \$p log | grep "^I LOVE YOU\$"' |
Frank Lichtenheld | 24a97d8 | 2007-05-27 14:33:10 +0200 | [diff] [blame] | 127 | |
| 128 | test_expect_success 'pserver authentication failure (login/non-anonymous user)' \ |
| 129 | 'if cat login-git | git-cvsserver pserver >log 2>&1 |
| 130 | then |
| 131 | false |
| 132 | else |
| 133 | true |
| 134 | fi && |
Stephen Boyd | 9524cf2 | 2010-01-26 15:08:31 -0800 | [diff] [blame] | 135 | sed -ne \$p log | grep "^I HATE YOU\$"' |
Frank Lichtenheld | 24a97d8 | 2007-05-27 14:33:10 +0200 | [diff] [blame] | 136 | |
Frank Lichtenheld | 240ba7f | 2007-05-21 00:31:58 +0200 | [diff] [blame] | 137 | |
Frank Lichtenheld | 4890888 | 2007-06-07 16:57:00 +0200 | [diff] [blame] | 138 | # misuse pserver authentication for testing of req_Root |
| 139 | |
| 140 | cat >request-relative <<EOF |
| 141 | BEGIN AUTH REQUEST |
| 142 | gitcvs.git |
| 143 | anonymous |
| 144 | |
| 145 | END AUTH REQUEST |
| 146 | EOF |
| 147 | |
| 148 | cat >request-conflict <<EOF |
| 149 | BEGIN AUTH REQUEST |
| 150 | $SERVERDIR |
| 151 | anonymous |
| 152 | |
| 153 | END AUTH REQUEST |
| 154 | Root $WORKDIR |
| 155 | EOF |
| 156 | |
| 157 | test_expect_success 'req_Root failure (relative pathname)' \ |
| 158 | 'if cat request-relative | git-cvsserver pserver >log 2>&1 |
| 159 | then |
| 160 | echo unexpected success |
| 161 | false |
| 162 | else |
| 163 | true |
| 164 | fi && |
Jeff King | aadbe44 | 2008-03-12 17:32:17 -0400 | [diff] [blame] | 165 | tail log | grep "^error 1 Root must be an absolute pathname$"' |
Frank Lichtenheld | 4890888 | 2007-06-07 16:57:00 +0200 | [diff] [blame] | 166 | |
| 167 | test_expect_success 'req_Root failure (conflicting roots)' \ |
| 168 | 'cat request-conflict | git-cvsserver pserver >log 2>&1 && |
Jeff King | aadbe44 | 2008-03-12 17:32:17 -0400 | [diff] [blame] | 169 | tail log | grep "^error 1 Conflicting roots specified$"' |
Frank Lichtenheld | 4890888 | 2007-06-07 16:57:00 +0200 | [diff] [blame] | 170 | |
Frank Lichtenheld | 693b632 | 2007-06-07 16:57:01 +0200 | [diff] [blame] | 171 | test_expect_success 'req_Root (strict paths)' \ |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 172 | 'cat request-anonymous | git-cvsserver --strict-paths pserver "$SERVERDIR" >log 2>&1 && |
Stephen Boyd | 9524cf2 | 2010-01-26 15:08:31 -0800 | [diff] [blame] | 173 | sed -ne \$p log | grep "^I LOVE YOU\$"' |
Frank Lichtenheld | 693b632 | 2007-06-07 16:57:01 +0200 | [diff] [blame] | 174 | |
Junio C Hamano | 41ac414 | 2008-02-01 01:50:53 -0800 | [diff] [blame] | 175 | test_expect_success 'req_Root failure (strict-paths)' ' |
| 176 | ! cat request-anonymous | |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 177 | git-cvsserver --strict-paths pserver "$WORKDIR" >log 2>&1 |
Junio C Hamano | 41ac414 | 2008-02-01 01:50:53 -0800 | [diff] [blame] | 178 | ' |
Frank Lichtenheld | 693b632 | 2007-06-07 16:57:01 +0200 | [diff] [blame] | 179 | |
| 180 | test_expect_success 'req_Root (w/o strict-paths)' \ |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 181 | 'cat request-anonymous | git-cvsserver pserver "$WORKDIR/" >log 2>&1 && |
Stephen Boyd | 9524cf2 | 2010-01-26 15:08:31 -0800 | [diff] [blame] | 182 | sed -ne \$p log | grep "^I LOVE YOU\$"' |
Frank Lichtenheld | 693b632 | 2007-06-07 16:57:01 +0200 | [diff] [blame] | 183 | |
Junio C Hamano | 41ac414 | 2008-02-01 01:50:53 -0800 | [diff] [blame] | 184 | test_expect_success 'req_Root failure (w/o strict-paths)' ' |
| 185 | ! cat request-anonymous | |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 186 | git-cvsserver pserver "$WORKDIR/gitcvs" >log 2>&1 |
Junio C Hamano | 41ac414 | 2008-02-01 01:50:53 -0800 | [diff] [blame] | 187 | ' |
Frank Lichtenheld | 693b632 | 2007-06-07 16:57:01 +0200 | [diff] [blame] | 188 | |
| 189 | cat >request-base <<EOF |
| 190 | BEGIN AUTH REQUEST |
| 191 | /gitcvs.git |
| 192 | anonymous |
| 193 | |
| 194 | END AUTH REQUEST |
Frank Lichtenheld | fd1cd91 | 2007-06-15 03:01:52 +0200 | [diff] [blame] | 195 | Root /gitcvs.git |
Frank Lichtenheld | 693b632 | 2007-06-07 16:57:01 +0200 | [diff] [blame] | 196 | EOF |
| 197 | |
| 198 | test_expect_success 'req_Root (base-path)' \ |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 199 | 'cat request-base | git-cvsserver --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" >log 2>&1 && |
Stephen Boyd | 9524cf2 | 2010-01-26 15:08:31 -0800 | [diff] [blame] | 200 | sed -ne \$p log | grep "^I LOVE YOU\$"' |
Frank Lichtenheld | 693b632 | 2007-06-07 16:57:01 +0200 | [diff] [blame] | 201 | |
Junio C Hamano | 41ac414 | 2008-02-01 01:50:53 -0800 | [diff] [blame] | 202 | test_expect_success 'req_Root failure (base-path)' ' |
| 203 | ! cat request-anonymous | |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 204 | git-cvsserver --strict-paths --base-path "$WORKDIR" pserver "$SERVERDIR" >log 2>&1 |
Junio C Hamano | 41ac414 | 2008-02-01 01:50:53 -0800 | [diff] [blame] | 205 | ' |
Frank Lichtenheld | 4890888 | 2007-06-07 16:57:00 +0200 | [diff] [blame] | 206 | |
Frank Lichtenheld | 226bccb | 2007-06-15 03:01:53 +0200 | [diff] [blame] | 207 | GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false || exit 1 |
| 208 | |
| 209 | test_expect_success 'req_Root (export-all)' \ |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 210 | 'cat request-anonymous | git-cvsserver --export-all pserver "$WORKDIR" >log 2>&1 && |
Stephen Boyd | 9524cf2 | 2010-01-26 15:08:31 -0800 | [diff] [blame] | 211 | sed -ne \$p log | grep "^I LOVE YOU\$"' |
Frank Lichtenheld | 226bccb | 2007-06-15 03:01:53 +0200 | [diff] [blame] | 212 | |
Junio C Hamano | 41ac414 | 2008-02-01 01:50:53 -0800 | [diff] [blame] | 213 | test_expect_success 'req_Root failure (export-all w/o whitelist)' \ |
| 214 | '! (cat request-anonymous | git-cvsserver --export-all pserver >log 2>&1 || false)' |
Frank Lichtenheld | 226bccb | 2007-06-15 03:01:53 +0200 | [diff] [blame] | 215 | |
| 216 | test_expect_success 'req_Root (everything together)' \ |
Bryan Donlan | f69e836 | 2008-05-04 01:37:59 -0400 | [diff] [blame] | 217 | 'cat request-base | git-cvsserver --export-all --strict-paths --base-path "$WORKDIR/" pserver "$SERVERDIR" >log 2>&1 && |
Stephen Boyd | 9524cf2 | 2010-01-26 15:08:31 -0800 | [diff] [blame] | 218 | sed -ne \$p log | grep "^I LOVE YOU\$"' |
Frank Lichtenheld | 226bccb | 2007-06-15 03:01:53 +0200 | [diff] [blame] | 219 | |
| 220 | GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true || exit 1 |
| 221 | |
Frank Lichtenheld | 1d431b2 | 2007-05-21 00:31:56 +0200 | [diff] [blame] | 222 | #-------------- |
| 223 | # CONFIG TESTS |
| 224 | #-------------- |
| 225 | |
| 226 | test_expect_success 'gitcvs.enabled = false' \ |
| 227 | 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false && |
| 228 | if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 |
| 229 | then |
| 230 | echo unexpected cvs success |
| 231 | false |
| 232 | else |
| 233 | true |
| 234 | fi && |
Jeff King | aadbe44 | 2008-03-12 17:32:17 -0400 | [diff] [blame] | 235 | grep "GITCVS emulation disabled" cvs.log && |
Frank Lichtenheld | 1d431b2 | 2007-05-21 00:31:56 +0200 | [diff] [blame] | 236 | test ! -d cvswork2' |
| 237 | |
| 238 | rm -fr cvswork2 |
| 239 | test_expect_success 'gitcvs.ext.enabled = true' \ |
| 240 | 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true && |
| 241 | GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled false && |
| 242 | GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 && |
Junio C Hamano | 4a2284b | 2010-03-11 21:40:33 -0800 | [diff] [blame] | 243 | test_cmp cvswork cvswork2' |
Frank Lichtenheld | 1d431b2 | 2007-05-21 00:31:56 +0200 | [diff] [blame] | 244 | |
| 245 | rm -fr cvswork2 |
| 246 | test_expect_success 'gitcvs.ext.enabled = false' \ |
| 247 | 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled false && |
| 248 | GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true && |
| 249 | if GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 |
| 250 | then |
| 251 | echo unexpected cvs success |
| 252 | false |
| 253 | else |
| 254 | true |
| 255 | fi && |
Jeff King | aadbe44 | 2008-03-12 17:32:17 -0400 | [diff] [blame] | 256 | grep "GITCVS emulation disabled" cvs.log && |
Frank Lichtenheld | 1d431b2 | 2007-05-21 00:31:56 +0200 | [diff] [blame] | 257 | test ! -d cvswork2' |
| 258 | |
| 259 | rm -fr cvswork2 |
| 260 | test_expect_success 'gitcvs.dbname' \ |
| 261 | 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true && |
| 262 | GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs.%a.%m.sqlite && |
| 263 | GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 && |
Junio C Hamano | 4a2284b | 2010-03-11 21:40:33 -0800 | [diff] [blame] | 264 | test_cmp cvswork cvswork2 && |
Frank Lichtenheld | 1d431b2 | 2007-05-21 00:31:56 +0200 | [diff] [blame] | 265 | test -f "$SERVERDIR/gitcvs.ext.master.sqlite" && |
| 266 | cmp "$SERVERDIR/gitcvs.master.sqlite" "$SERVERDIR/gitcvs.ext.master.sqlite"' |
| 267 | |
| 268 | rm -fr cvswork2 |
| 269 | test_expect_success 'gitcvs.ext.dbname' \ |
| 270 | 'GIT_DIR="$SERVERDIR" git config --bool gitcvs.ext.enabled true && |
| 271 | GIT_DIR="$SERVERDIR" git config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite && |
| 272 | GIT_DIR="$SERVERDIR" git config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite && |
| 273 | GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 && |
Junio C Hamano | 4a2284b | 2010-03-11 21:40:33 -0800 | [diff] [blame] | 274 | test_cmp cvswork cvswork2 && |
Frank Lichtenheld | 1d431b2 | 2007-05-21 00:31:56 +0200 | [diff] [blame] | 275 | test -f "$SERVERDIR/gitcvs1.ext.master.sqlite" && |
| 276 | test ! -f "$SERVERDIR/gitcvs2.ext.master.sqlite" && |
| 277 | cmp "$SERVERDIR/gitcvs.master.sqlite" "$SERVERDIR/gitcvs1.ext.master.sqlite"' |
| 278 | |
| 279 | |
| 280 | #------------ |
| 281 | # CVS UPDATE |
| 282 | #------------ |
| 283 | |
| 284 | rm -fr "$SERVERDIR" |
| 285 | cd "$WORKDIR" && |
Johannes Sixt | 7fd3ef1 | 2009-03-07 00:04:09 +0100 | [diff] [blame] | 286 | git clone -q --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 && |
Frank Lichtenheld | 1d431b2 | 2007-05-21 00:31:56 +0200 | [diff] [blame] | 287 | GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true && |
Frank Lichtenheld | db1696b | 2007-06-25 16:00:24 +0200 | [diff] [blame] | 288 | GIT_DIR="$SERVERDIR" git config gitcvs.logfile "$SERVERDIR/gitcvs.log" || |
Frank Lichtenheld | 1d431b2 | 2007-05-21 00:31:56 +0200 | [diff] [blame] | 289 | exit 1 |
| 290 | |
Frank Lichtenheld | b3b5343 | 2007-05-02 02:45:22 +0200 | [diff] [blame] | 291 | test_expect_success 'cvs update (create new file)' \ |
| 292 | 'echo testfile1 >testfile1 && |
| 293 | git add testfile1 && |
| 294 | git commit -q -m "Add testfile1" && |
| 295 | git push gitcvs.git >/dev/null && |
| 296 | cd cvswork && |
Junio Hamano | a25907d | 2007-05-11 16:35:18 -0700 | [diff] [blame] | 297 | GIT_CONFIG="$git_config" cvs -Q update && |
Frank Lichtenheld | b3b5343 | 2007-05-02 02:45:22 +0200 | [diff] [blame] | 298 | test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.1/" && |
Junio C Hamano | 4a2284b | 2010-03-11 21:40:33 -0800 | [diff] [blame] | 299 | test_cmp testfile1 ../testfile1' |
Frank Lichtenheld | b3b5343 | 2007-05-02 02:45:22 +0200 | [diff] [blame] | 300 | |
| 301 | cd "$WORKDIR" |
| 302 | test_expect_success 'cvs update (update existing file)' \ |
| 303 | 'echo line 2 >>testfile1 && |
| 304 | git add testfile1 && |
| 305 | git commit -q -m "Append to testfile1" && |
| 306 | git push gitcvs.git >/dev/null && |
| 307 | cd cvswork && |
Junio Hamano | a25907d | 2007-05-11 16:35:18 -0700 | [diff] [blame] | 308 | GIT_CONFIG="$git_config" cvs -Q update && |
Frank Lichtenheld | b3b5343 | 2007-05-02 02:45:22 +0200 | [diff] [blame] | 309 | test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.2/" && |
Junio C Hamano | 4a2284b | 2010-03-11 21:40:33 -0800 | [diff] [blame] | 310 | test_cmp testfile1 ../testfile1' |
Frank Lichtenheld | b3b5343 | 2007-05-02 02:45:22 +0200 | [diff] [blame] | 311 | |
| 312 | cd "$WORKDIR" |
| 313 | #TODO: cvsserver doesn't support update w/o -d |
Junio C Hamano | 41ac414 | 2008-02-01 01:50:53 -0800 | [diff] [blame] | 314 | test_expect_failure "cvs update w/o -d doesn't create subdir (TODO)" ' |
| 315 | mkdir test && |
Frank Lichtenheld | b3b5343 | 2007-05-02 02:45:22 +0200 | [diff] [blame] | 316 | echo >test/empty && |
| 317 | git add test && |
| 318 | git commit -q -m "Single Subdirectory" && |
| 319 | git push gitcvs.git >/dev/null && |
| 320 | cd cvswork && |
Junio Hamano | a25907d | 2007-05-11 16:35:18 -0700 | [diff] [blame] | 321 | GIT_CONFIG="$git_config" cvs -Q update && |
Junio C Hamano | 41ac414 | 2008-02-01 01:50:53 -0800 | [diff] [blame] | 322 | test ! -d test |
| 323 | ' |
Frank Lichtenheld | b3b5343 | 2007-05-02 02:45:22 +0200 | [diff] [blame] | 324 | |
| 325 | cd "$WORKDIR" |
| 326 | test_expect_success 'cvs update (subdirectories)' \ |
| 327 | '(for dir in A A/B A/B/C A/D E; do |
| 328 | mkdir $dir && |
| 329 | echo "test file in $dir" >"$dir/file_in_$(echo $dir|sed -e "s#/# #g")" && |
| 330 | git add $dir; |
| 331 | done) && |
| 332 | git commit -q -m "deep sub directory structure" && |
| 333 | git push gitcvs.git >/dev/null && |
| 334 | cd cvswork && |
Junio Hamano | a25907d | 2007-05-11 16:35:18 -0700 | [diff] [blame] | 335 | GIT_CONFIG="$git_config" cvs -Q update -d && |
Frank Lichtenheld | b3b5343 | 2007-05-02 02:45:22 +0200 | [diff] [blame] | 336 | (for dir in A A/B A/B/C A/D E; do |
| 337 | filename="file_in_$(echo $dir|sed -e "s#/# #g")" && |
| 338 | if test "$(echo $(grep -v ^D $dir/CVS/Entries|cut -d/ -f2,3,5))" = "$filename/1.1/" && |
Junio C Hamano | 4a2284b | 2010-03-11 21:40:33 -0800 | [diff] [blame] | 339 | test_cmp "$dir/$filename" "../$dir/$filename"; then |
Frank Lichtenheld | b3b5343 | 2007-05-02 02:45:22 +0200 | [diff] [blame] | 340 | : |
| 341 | else |
| 342 | echo >failure |
| 343 | fi |
| 344 | done) && |
| 345 | test ! -f failure' |
| 346 | |
| 347 | cd "$WORKDIR" |
| 348 | test_expect_success 'cvs update (delete file)' \ |
| 349 | 'git rm testfile1 && |
| 350 | git commit -q -m "Remove testfile1" && |
| 351 | git push gitcvs.git >/dev/null && |
| 352 | cd cvswork && |
Junio Hamano | a25907d | 2007-05-11 16:35:18 -0700 | [diff] [blame] | 353 | GIT_CONFIG="$git_config" cvs -Q update && |
Frank Lichtenheld | b3b5343 | 2007-05-02 02:45:22 +0200 | [diff] [blame] | 354 | test -z "$(grep testfile1 CVS/Entries)" && |
| 355 | test ! -f testfile1' |
| 356 | |
| 357 | cd "$WORKDIR" |
| 358 | test_expect_success 'cvs update (re-add deleted file)' \ |
| 359 | 'echo readded testfile >testfile1 && |
| 360 | git add testfile1 && |
| 361 | git commit -q -m "Re-Add testfile1" && |
| 362 | git push gitcvs.git >/dev/null && |
| 363 | cd cvswork && |
Junio Hamano | a25907d | 2007-05-11 16:35:18 -0700 | [diff] [blame] | 364 | GIT_CONFIG="$git_config" cvs -Q update && |
Frank Lichtenheld | b3b5343 | 2007-05-02 02:45:22 +0200 | [diff] [blame] | 365 | test "$(echo $(grep testfile1 CVS/Entries|cut -d/ -f2,3,5))" = "testfile1/1.4/" && |
Junio C Hamano | 4a2284b | 2010-03-11 21:40:33 -0800 | [diff] [blame] | 366 | test_cmp testfile1 ../testfile1' |
Frank Lichtenheld | b3b5343 | 2007-05-02 02:45:22 +0200 | [diff] [blame] | 367 | |
Frank Lichtenheld | 1978659 | 2007-05-21 00:31:57 +0200 | [diff] [blame] | 368 | cd "$WORKDIR" |
| 369 | test_expect_success 'cvs update (merge)' \ |
| 370 | 'echo Line 0 >expected && |
| 371 | for i in 1 2 3 4 5 6 7 |
| 372 | do |
| 373 | echo Line $i >>merge |
| 374 | echo Line $i >>expected |
| 375 | done && |
| 376 | echo Line 8 >>expected && |
| 377 | git add merge && |
| 378 | git commit -q -m "Merge test (pre-merge)" && |
| 379 | git push gitcvs.git >/dev/null && |
| 380 | cd cvswork && |
| 381 | GIT_CONFIG="$git_config" cvs -Q update && |
| 382 | test "$(echo $(grep merge CVS/Entries|cut -d/ -f2,3,5))" = "merge/1.1/" && |
Junio C Hamano | 4a2284b | 2010-03-11 21:40:33 -0800 | [diff] [blame] | 383 | test_cmp merge ../merge && |
Frank Lichtenheld | 1978659 | 2007-05-21 00:31:57 +0200 | [diff] [blame] | 384 | ( echo Line 0; cat merge ) >merge.tmp && |
| 385 | mv merge.tmp merge && |
| 386 | cd "$WORKDIR" && |
| 387 | echo Line 8 >>merge && |
| 388 | git add merge && |
| 389 | git commit -q -m "Merge test (merge)" && |
| 390 | git push gitcvs.git >/dev/null && |
| 391 | cd cvswork && |
Frank Lichtenheld | b3c81cf | 2007-05-27 14:33:09 +0200 | [diff] [blame] | 392 | sleep 1 && touch merge && |
Frank Lichtenheld | 1978659 | 2007-05-21 00:31:57 +0200 | [diff] [blame] | 393 | GIT_CONFIG="$git_config" cvs -Q update && |
Junio C Hamano | 4a2284b | 2010-03-11 21:40:33 -0800 | [diff] [blame] | 394 | test_cmp merge ../expected' |
Frank Lichtenheld | 1978659 | 2007-05-21 00:31:57 +0200 | [diff] [blame] | 395 | |
| 396 | cd "$WORKDIR" |
| 397 | |
| 398 | cat >expected.C <<EOF |
| 399 | <<<<<<< merge.mine |
| 400 | Line 0 |
| 401 | ======= |
| 402 | LINE 0 |
Matthew Ogilvie | ab07681 | 2012-10-13 23:42:21 -0600 | [diff] [blame] | 403 | >>>>>>> merge.1.3 |
Frank Lichtenheld | 1978659 | 2007-05-21 00:31:57 +0200 | [diff] [blame] | 404 | EOF |
| 405 | |
| 406 | for i in 1 2 3 4 5 6 7 8 |
| 407 | do |
| 408 | echo Line $i >>expected.C |
| 409 | done |
| 410 | |
| 411 | test_expect_success 'cvs update (conflict merge)' \ |
| 412 | '( echo LINE 0; cat merge ) >merge.tmp && |
| 413 | mv merge.tmp merge && |
| 414 | git add merge && |
| 415 | git commit -q -m "Merge test (conflict)" && |
| 416 | git push gitcvs.git >/dev/null && |
| 417 | cd cvswork && |
| 418 | GIT_CONFIG="$git_config" cvs -Q update && |
Junio C Hamano | 4a2284b | 2010-03-11 21:40:33 -0800 | [diff] [blame] | 419 | test_cmp merge ../expected.C' |
Frank Lichtenheld | 1978659 | 2007-05-21 00:31:57 +0200 | [diff] [blame] | 420 | |
| 421 | cd "$WORKDIR" |
| 422 | test_expect_success 'cvs update (-C)' \ |
| 423 | 'cd cvswork && |
| 424 | GIT_CONFIG="$git_config" cvs -Q update -C && |
Junio C Hamano | 4a2284b | 2010-03-11 21:40:33 -0800 | [diff] [blame] | 425 | test_cmp merge ../merge' |
Frank Lichtenheld | 1978659 | 2007-05-21 00:31:57 +0200 | [diff] [blame] | 426 | |
| 427 | cd "$WORKDIR" |
| 428 | test_expect_success 'cvs update (merge no-op)' \ |
| 429 | 'echo Line 9 >>merge && |
| 430 | cp merge cvswork/merge && |
| 431 | git add merge && |
| 432 | git commit -q -m "Merge test (no-op)" && |
| 433 | git push gitcvs.git >/dev/null && |
| 434 | cd cvswork && |
Frank Lichtenheld | b3c81cf | 2007-05-27 14:33:09 +0200 | [diff] [blame] | 435 | sleep 1 && touch merge && |
Frank Lichtenheld | 1978659 | 2007-05-21 00:31:57 +0200 | [diff] [blame] | 436 | GIT_CONFIG="$git_config" cvs -Q update && |
Junio C Hamano | 4a2284b | 2010-03-11 21:40:33 -0800 | [diff] [blame] | 437 | test_cmp merge ../merge' |
Frank Lichtenheld | 1978659 | 2007-05-21 00:31:57 +0200 | [diff] [blame] | 438 | |
Damien Diederen | 6e8937a | 2008-03-27 23:18:23 +0100 | [diff] [blame] | 439 | cd "$WORKDIR" |
| 440 | test_expect_success 'cvs update (-p)' ' |
| 441 | touch really-empty && |
| 442 | echo Line 1 > no-lf && |
Brian Gernhardt | 6ecfd91 | 2008-10-31 01:09:13 -0400 | [diff] [blame] | 443 | printf "Line 2" >> no-lf && |
Damien Diederen | 6e8937a | 2008-03-27 23:18:23 +0100 | [diff] [blame] | 444 | git add really-empty no-lf && |
| 445 | git commit -q -m "Update -p test" && |
| 446 | git push gitcvs.git >/dev/null && |
| 447 | cd cvswork && |
| 448 | GIT_CONFIG="$git_config" cvs update && |
| 449 | rm -f failures && |
| 450 | for i in merge no-lf empty really-empty; do |
| 451 | GIT_CONFIG="$git_config" cvs update -p "$i" >$i.out |
Gary V. Vaughan | 4fdf71b | 2010-05-14 09:31:37 +0000 | [diff] [blame] | 452 | test_cmp $i.out ../$i >>failures 2>&1 |
Damien Diederen | 6e8937a | 2008-03-27 23:18:23 +0100 | [diff] [blame] | 453 | done && |
| 454 | test -z "$(cat failures)" |
| 455 | ' |
| 456 | |
Lars Noschinski | b0f2ecf | 2008-07-17 19:00:28 +0200 | [diff] [blame] | 457 | cd "$WORKDIR" |
| 458 | test_expect_success 'cvs update (module list supports packed refs)' ' |
| 459 | GIT_DIR="$SERVERDIR" git pack-refs --all && |
| 460 | GIT_CONFIG="$git_config" cvs -n up -d 2> out && |
| 461 | grep "cvs update: New directory \`master'\''" < out |
| 462 | ' |
| 463 | |
Damien Diederen | dded801 | 2008-03-27 23:18:02 +0100 | [diff] [blame] | 464 | #------------ |
| 465 | # CVS STATUS |
| 466 | #------------ |
| 467 | |
| 468 | cd "$WORKDIR" |
| 469 | test_expect_success 'cvs status' ' |
| 470 | mkdir status.dir && |
| 471 | echo Line > status.dir/status.file && |
| 472 | echo Line > status.file && |
| 473 | git add status.dir status.file && |
| 474 | git commit -q -m "Status test" && |
| 475 | git push gitcvs.git >/dev/null && |
| 476 | cd cvswork && |
| 477 | GIT_CONFIG="$git_config" cvs update && |
| 478 | GIT_CONFIG="$git_config" cvs status | grep "^File: status.file" >../out && |
Stefano Lattarini | 3fb0459 | 2012-04-11 13:24:01 +0200 | [diff] [blame] | 479 | test_line_count = 2 ../out |
Damien Diederen | dded801 | 2008-03-27 23:18:02 +0100 | [diff] [blame] | 480 | ' |
| 481 | |
| 482 | cd "$WORKDIR" |
| 483 | test_expect_success 'cvs status (nonrecursive)' ' |
| 484 | cd cvswork && |
| 485 | GIT_CONFIG="$git_config" cvs status -l | grep "^File: status.file" >../out && |
Stefano Lattarini | 3fb0459 | 2012-04-11 13:24:01 +0200 | [diff] [blame] | 486 | test_line_count = 1 ../out |
Damien Diederen | dded801 | 2008-03-27 23:18:02 +0100 | [diff] [blame] | 487 | ' |
| 488 | |
| 489 | cd "$WORKDIR" |
| 490 | test_expect_success 'cvs status (no subdirs in header)' ' |
| 491 | cd cvswork && |
| 492 | GIT_CONFIG="$git_config" cvs status | grep ^File: >../out && |
| 493 | ! grep / <../out |
| 494 | ' |
| 495 | |
Fabian Emmes | 42f7a2d | 2008-07-17 19:00:30 +0200 | [diff] [blame] | 496 | #------------ |
| 497 | # CVS CHECKOUT |
| 498 | #------------ |
| 499 | |
| 500 | cd "$WORKDIR" |
| 501 | test_expect_success 'cvs co -c (shows module database)' ' |
| 502 | GIT_CONFIG="$git_config" cvs co -c > out && |
Junio C Hamano | 2718781 | 2012-04-19 13:05:26 -0700 | [diff] [blame] | 503 | grep "^master[ ][ ]*master$" <out && |
| 504 | ! grep -v "^master[ ][ ]*master$" <out |
Fabian Emmes | 42f7a2d | 2008-07-17 19:00:30 +0200 | [diff] [blame] | 505 | ' |
| 506 | |
Junio C Hamano | 7ceacdf | 2008-09-05 00:57:35 -0700 | [diff] [blame] | 507 | #------------ |
Matthew Ogilvie | ef6fd72 | 2012-10-13 23:42:14 -0600 | [diff] [blame] | 508 | # CVS LOG |
| 509 | #------------ |
| 510 | |
| 511 | # Known issues with git-cvsserver current log output: |
| 512 | # - Hard coded "lines: +2 -3" placeholder, instead of real numbers. |
| 513 | # - CVS normally does not internally add a blank first line |
| 514 | # nor a last line with nothing but a space to log messages. |
| 515 | # - The latest cvs 1.12.x server sends +0000 timezone (with some hidden "MT" |
| 516 | # tagging in the protocol), and if cvs 1.12.x client sees the MT tags, |
| 517 | # it converts to local time zone. git-cvsserver doesn't do the +0000 |
| 518 | # or the MT tags... |
| 519 | # - The latest 1.12.x releases add a "commitid:" field on to the end of the |
| 520 | # "date:" line (after "lines:"). Maybe we could stick git's commit id |
| 521 | # in it? Or does CVS expect a certain number of bits (too few for |
| 522 | # a full sha1)? |
| 523 | # |
| 524 | # Given the above, expect the following test to break if git-cvsserver's |
| 525 | # log output is improved. The test is just to ensure it doesn't |
| 526 | # accidentally get worse. |
| 527 | |
| 528 | sed -e 's/^x//' -e 's/SP$/ /' > "$WORKDIR/expect" <<EOF |
| 529 | x |
| 530 | xRCS file: $WORKDIR/gitcvs.git/master/merge,v |
| 531 | xWorking file: merge |
| 532 | xhead: 1.4 |
| 533 | xbranch: |
| 534 | xlocks: strict |
| 535 | xaccess list: |
| 536 | xsymbolic names: |
| 537 | xkeyword substitution: kv |
| 538 | xtotal revisions: 4; selected revisions: 4 |
| 539 | xdescription: |
| 540 | x---------------------------- |
| 541 | xrevision 1.4 |
| 542 | xdate: __DATE__; author: author; state: Exp; lines: +2 -3 |
| 543 | x |
| 544 | xMerge test (no-op) |
| 545 | xSP |
| 546 | x---------------------------- |
| 547 | xrevision 1.3 |
| 548 | xdate: __DATE__; author: author; state: Exp; lines: +2 -3 |
| 549 | x |
| 550 | xMerge test (conflict) |
| 551 | xSP |
| 552 | x---------------------------- |
| 553 | xrevision 1.2 |
| 554 | xdate: __DATE__; author: author; state: Exp; lines: +2 -3 |
| 555 | x |
| 556 | xMerge test (merge) |
| 557 | xSP |
| 558 | x---------------------------- |
| 559 | xrevision 1.1 |
| 560 | xdate: __DATE__; author: author; state: Exp; lines: +2 -3 |
| 561 | x |
| 562 | xMerge test (pre-merge) |
| 563 | xSP |
| 564 | x============================================================================= |
| 565 | EOF |
| 566 | expectStat="$?" |
| 567 | |
| 568 | cd "$WORKDIR" |
| 569 | test_expect_success 'cvs log' ' |
| 570 | cd cvswork && |
| 571 | test x"$expectStat" = x"0" && |
| 572 | GIT_CONFIG="$git_config" cvs log merge >../out && |
| 573 | 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 && |
| 574 | test_cmp ../expect ../actual |
| 575 | ' |
| 576 | |
| 577 | #------------ |
Junio C Hamano | 7ceacdf | 2008-09-05 00:57:35 -0700 | [diff] [blame] | 578 | # CVS ANNOTATE |
| 579 | #------------ |
| 580 | |
| 581 | cd "$WORKDIR" |
| 582 | test_expect_success 'cvs annotate' ' |
| 583 | cd cvswork && |
| 584 | GIT_CONFIG="$git_config" cvs annotate merge >../out && |
| 585 | sed -e "s/ .*//" ../out >../actual && |
| 586 | for i in 3 1 1 1 1 1 1 1 2 4; do echo 1.$i; done >../expect && |
| 587 | test_cmp ../expect ../actual |
| 588 | ' |
| 589 | |
Frank Lichtenheld | b3b5343 | 2007-05-02 02:45:22 +0200 | [diff] [blame] | 590 | test_done |