1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369
|
#!/bin/sh
#
# Copyright (c) 2008 Matthew Ogilvie
# Parts adapted from other tests.
#
test_description='git-cvsserver -kb modes
tests -kb mode for binary files when accessing a git
repository using cvs CLI client via git-cvsserver server'
. ./test-lib.sh
marked_as () {
foundEntry="$(grep "^/$2/" "$1/CVS/Entries")"
if [ x"$foundEntry" = x"" ] ; then
echo "NOT FOUND: $1 $2 1 $3" >> "${WORKDIR}/marked.log"
return 1
fi
test x"$(grep "^/$2/" "$1/CVS/Entries" | cut -d/ -f5)" = x"$3"
stat=$?
echo "$1 $2 $stat '$3'" >> "${WORKDIR}/marked.log"
return $stat
}
not_present() {
foundEntry="$(grep "^/$2/" "$1/CVS/Entries")"
if [ -r "$1/$2" ] ; then
echo "Error: File still exists: $1 $2" >> "${WORKDIR}/marked.log"
return 1;
fi
if [ x"$foundEntry" != x"" ] ; then
echo "Error: should not have found: $1 $2" >> "${WORKDIR}/marked.log"
return 1;
else
echo "Correctly not found: $1 $2" >> "${WORKDIR}/marked.log"
return 0;
fi
}
check_status_options() {
(cd "$1" &&
GIT_CONFIG="$git_config" cvs -Q status "$2" > "${WORKDIR}/status.out" 2>&1
)
if [ x"$?" != x"0" ] ; then
echo "Error from cvs status: $1 $2" >> "${WORKDIR}/marked.log"
return 1;
fi
got="$(sed -n -e 's/^[ ]*Sticky Options:[ ]*//p' "${WORKDIR}/status.out")"
expect="$3"
if [ x"$expect" = x"" ] ; then
expect="(none)"
fi
test x"$got" = x"$expect"
stat=$?
echo "cvs status: $1 $2 $stat '$3' '$got'" >> "${WORKDIR}/marked.log"
return $stat
}
cvs >/dev/null 2>&1
if test $? -ne 1
then
skip_all='skipping git-cvsserver tests, cvs not found'
test_done
fi
if ! test_have_prereq PERL
then
skip_all='skipping git-cvsserver tests, perl not available'
test_done
fi
perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
skip_all='skipping git-cvsserver tests, Perl SQLite interface unavailable'
test_done
}
unset GIT_DIR GIT_CONFIG
WORKDIR=$(pwd)
SERVERDIR=$(pwd)/gitcvs.git
git_config="$SERVERDIR/config"
CVSROOT=":fork:$SERVERDIR"
CVSWORK="$(pwd)/cvswork"
CVS_SERVER=git-cvsserver
export CVSROOT CVS_SERVER
rm -rf "$CVSWORK" "$SERVERDIR"
test_expect_success 'setup' '
git config push.default matching &&
echo "Simple text file" >textfile.c &&
echo "File with embedded NUL: Q <- there" | q_to_nul > binfile.bin &&
mkdir subdir &&
echo "Another text file" > subdir/file.h &&
echo "Another binary: Q (this time CR)" | q_to_cr > subdir/withCr.bin &&
echo "Mixed up NUL, but marked text: Q <- there" | q_to_nul > mixedUp.c &&
echo "Unspecified" > subdir/unspecified.other &&
echo "/*.bin -crlf" > .gitattributes &&
echo "/*.c crlf" >> .gitattributes &&
echo "subdir/*.bin -crlf" >> .gitattributes &&
echo "subdir/*.c crlf" >> .gitattributes &&
echo "subdir/file.h crlf" >> .gitattributes &&
git add .gitattributes textfile.c binfile.bin mixedUp.c subdir/* &&
git commit -q -m "First Commit" &&
git clone -q --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 &&
GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true &&
GIT_DIR="$SERVERDIR" git config gitcvs.logfile "$SERVERDIR/gitcvs.log"
'
test_expect_success 'cvs co (default crlf)' '
GIT_CONFIG="$git_config" cvs -Q co -d cvswork master >cvs.log 2>&1 &&
test x"$(grep '/-k' cvswork/CVS/Entries cvswork/subdir/CVS/Entries)" = x""
'
rm -rf cvswork
test_expect_success 'cvs co (allbinary)' '
GIT_DIR="$SERVERDIR" git config --bool gitcvs.allbinary true &&
GIT_CONFIG="$git_config" cvs -Q co -d cvswork master >cvs.log 2>&1 &&
marked_as cvswork textfile.c -kb &&
marked_as cvswork binfile.bin -kb &&
marked_as cvswork .gitattributes -kb &&
marked_as cvswork mixedUp.c -kb &&
marked_as cvswork/subdir withCr.bin -kb &&
marked_as cvswork/subdir file.h -kb &&
marked_as cvswork/subdir unspecified.other -kb
'
rm -rf cvswork cvs.log
test_expect_success 'cvs co (use attributes/allbinary)' '
GIT_DIR="$SERVERDIR" git config --bool gitcvs.usecrlfattr true &&
GIT_CONFIG="$git_config" cvs -Q co -d cvswork master >cvs.log 2>&1 &&
marked_as cvswork textfile.c "" &&
marked_as cvswork binfile.bin -kb &&
marked_as cvswork .gitattributes -kb &&
marked_as cvswork mixedUp.c "" &&
marked_as cvswork/subdir withCr.bin -kb &&
marked_as cvswork/subdir file.h "" &&
marked_as cvswork/subdir unspecified.other -kb
'
rm -rf cvswork
test_expect_success 'cvs co (use attributes)' '
GIT_DIR="$SERVERDIR" git config --bool gitcvs.allbinary false &&
GIT_CONFIG="$git_config" cvs -Q co -d cvswork master >cvs.log 2>&1 &&
marked_as cvswork textfile.c "" &&
marked_as cvswork binfile.bin -kb &&
marked_as cvswork .gitattributes "" &&
marked_as cvswork mixedUp.c "" &&
marked_as cvswork/subdir withCr.bin -kb &&
marked_as cvswork/subdir file.h "" &&
marked_as cvswork/subdir unspecified.other ""
'
test_expect_success 'adding files' '
(cd cvswork &&
(cd subdir &&
echo "more text" > src.c &&
GIT_CONFIG="$git_config" cvs -Q add src.c >cvs.log 2>&1 &&
marked_as . src.c "" &&
echo "psuedo-binary" > temp.bin
) &&
GIT_CONFIG="$git_config" cvs -Q add subdir/temp.bin >cvs.log 2>&1 &&
marked_as subdir temp.bin "-kb" &&
cd subdir &&
GIT_CONFIG="$git_config" cvs -Q ci -m "adding files" >cvs.log 2>&1 &&
marked_as . temp.bin "-kb" &&
marked_as . src.c ""
)
'
test_expect_success 'updating' '
git pull gitcvs.git &&
echo 'hi' > subdir/newfile.bin &&
echo 'junk' > subdir/file.h &&
echo 'hi' > subdir/newfile.c &&
echo 'hello' >> binfile.bin &&
git add subdir/newfile.bin subdir/file.h subdir/newfile.c binfile.bin &&
git commit -q -m "Add and change some files" &&
git push gitcvs.git >/dev/null &&
(cd cvswork &&
GIT_CONFIG="$git_config" cvs -Q update
) &&
marked_as cvswork textfile.c "" &&
marked_as cvswork binfile.bin -kb &&
marked_as cvswork .gitattributes "" &&
marked_as cvswork mixedUp.c "" &&
marked_as cvswork/subdir withCr.bin -kb &&
marked_as cvswork/subdir file.h "" &&
marked_as cvswork/subdir unspecified.other "" &&
marked_as cvswork/subdir newfile.bin -kb &&
marked_as cvswork/subdir newfile.c "" &&
echo "File with embedded NUL: Q <- there" | q_to_nul > tmpExpect1 &&
echo "hello" >> tmpExpect1 &&
cmp cvswork/binfile.bin tmpExpect1
'
rm -rf cvswork
test_expect_success 'cvs co (use attributes/guess)' '
GIT_DIR="$SERVERDIR" git config gitcvs.allbinary guess &&
GIT_CONFIG="$git_config" cvs -Q co -d cvswork master >cvs.log 2>&1 &&
marked_as cvswork textfile.c "" &&
marked_as cvswork binfile.bin -kb &&
marked_as cvswork .gitattributes "" &&
marked_as cvswork mixedUp.c "" &&
marked_as cvswork/subdir withCr.bin -kb &&
marked_as cvswork/subdir file.h "" &&
marked_as cvswork/subdir unspecified.other "" &&
marked_as cvswork/subdir newfile.bin -kb &&
marked_as cvswork/subdir newfile.c ""
'
test_expect_success 'setup multi-line files' '
( echo "line 1" &&
echo "line 2" &&
echo "line 3" &&
echo "line 4 with NUL: Q <-" ) | q_to_nul > multiline.c &&
git add multiline.c &&
( echo "line 1" &&
echo "line 2" &&
echo "line 3" &&
echo "line 4" ) | q_to_nul > multilineTxt.c &&
git add multilineTxt.c &&
git commit -q -m "multiline files" &&
git push gitcvs.git >/dev/null
'
rm -rf cvswork
test_expect_success 'cvs co (guess)' '
GIT_DIR="$SERVERDIR" git config --bool gitcvs.usecrlfattr false &&
GIT_CONFIG="$git_config" cvs -Q co -d cvswork master >cvs.log 2>&1 &&
marked_as cvswork textfile.c "" &&
marked_as cvswork binfile.bin -kb &&
marked_as cvswork .gitattributes "" &&
marked_as cvswork mixedUp.c -kb &&
marked_as cvswork multiline.c -kb &&
marked_as cvswork multilineTxt.c "" &&
marked_as cvswork/subdir withCr.bin -kb &&
marked_as cvswork/subdir file.h "" &&
marked_as cvswork/subdir unspecified.other "" &&
marked_as cvswork/subdir newfile.bin "" &&
marked_as cvswork/subdir newfile.c ""
'
test_expect_success 'cvs co another copy (guess)' '
GIT_CONFIG="$git_config" cvs -Q co -d cvswork2 master >cvs.log 2>&1 &&
marked_as cvswork2 textfile.c "" &&
marked_as cvswork2 binfile.bin -kb &&
marked_as cvswork2 .gitattributes "" &&
marked_as cvswork2 mixedUp.c -kb &&
marked_as cvswork2 multiline.c -kb &&
marked_as cvswork2 multilineTxt.c "" &&
marked_as cvswork2/subdir withCr.bin -kb &&
marked_as cvswork2/subdir file.h "" &&
marked_as cvswork2/subdir unspecified.other "" &&
marked_as cvswork2/subdir newfile.bin "" &&
marked_as cvswork2/subdir newfile.c ""
'
test_expect_success 'cvs status - sticky options' '
check_status_options cvswork2 textfile.c "" &&
check_status_options cvswork2 binfile.bin -kb &&
check_status_options cvswork2 .gitattributes "" &&
check_status_options cvswork2 mixedUp.c -kb &&
check_status_options cvswork2 multiline.c -kb &&
check_status_options cvswork2 multilineTxt.c "" &&
check_status_options cvswork2/subdir withCr.bin -kb &&
check_status_options cvswork2 subdir/withCr.bin -kb &&
check_status_options cvswork2/subdir file.h "" &&
check_status_options cvswork2 subdir/file.h "" &&
check_status_options cvswork2/subdir unspecified.other "" &&
check_status_options cvswork2/subdir newfile.bin "" &&
check_status_options cvswork2/subdir newfile.c ""
'
test_expect_success 'add text (guess)' '
(cd cvswork &&
echo "simpleText" > simpleText.c &&
GIT_CONFIG="$git_config" cvs -Q add simpleText.c
) &&
marked_as cvswork simpleText.c ""
'
test_expect_success 'add bin (guess)' '
(cd cvswork &&
echo "simpleBin: NUL: Q <- there" | q_to_nul > simpleBin.bin &&
GIT_CONFIG="$git_config" cvs -Q add simpleBin.bin
) &&
marked_as cvswork simpleBin.bin -kb
'
test_expect_success 'remove files (guess)' '
(cd cvswork &&
GIT_CONFIG="$git_config" cvs -Q rm -f subdir/file.h &&
(cd subdir &&
GIT_CONFIG="$git_config" cvs -Q rm -f withCr.bin
)) &&
marked_as cvswork/subdir withCr.bin -kb &&
marked_as cvswork/subdir file.h ""
'
test_expect_success 'cvs ci (guess)' '
(cd cvswork &&
GIT_CONFIG="$git_config" cvs -Q ci -m "add/rm files" >cvs.log 2>&1
) &&
marked_as cvswork textfile.c "" &&
marked_as cvswork binfile.bin -kb &&
marked_as cvswork .gitattributes "" &&
marked_as cvswork mixedUp.c -kb &&
marked_as cvswork multiline.c -kb &&
marked_as cvswork multilineTxt.c "" &&
not_present cvswork/subdir withCr.bin &&
not_present cvswork/subdir file.h &&
marked_as cvswork/subdir unspecified.other "" &&
marked_as cvswork/subdir newfile.bin "" &&
marked_as cvswork/subdir newfile.c "" &&
marked_as cvswork simpleBin.bin -kb &&
marked_as cvswork simpleText.c ""
'
test_expect_success 'update subdir of other copy (guess)' '
(cd cvswork2/subdir &&
GIT_CONFIG="$git_config" cvs -Q update
) &&
marked_as cvswork2 textfile.c "" &&
marked_as cvswork2 binfile.bin -kb &&
marked_as cvswork2 .gitattributes "" &&
marked_as cvswork2 mixedUp.c -kb &&
marked_as cvswork2 multiline.c -kb &&
marked_as cvswork2 multilineTxt.c "" &&
not_present cvswork2/subdir withCr.bin &&
not_present cvswork2/subdir file.h &&
marked_as cvswork2/subdir unspecified.other "" &&
marked_as cvswork2/subdir newfile.bin "" &&
marked_as cvswork2/subdir newfile.c "" &&
not_present cvswork2 simpleBin.bin &&
not_present cvswork2 simpleText.c
'
echo "starting update/merge" >> "${WORKDIR}/marked.log"
test_expect_success 'update/merge full other copy (guess)' '
git pull gitcvs.git master &&
sed "s/3/replaced_3/" < multilineTxt.c > ml.temp &&
mv ml.temp multilineTxt.c &&
git add multilineTxt.c &&
git commit -q -m "modify multiline file" >> "${WORKDIR}/marked.log" &&
git push gitcvs.git >/dev/null &&
(cd cvswork2 &&
sed "s/1/replaced_1/" < multilineTxt.c > ml.temp &&
mv ml.temp multilineTxt.c &&
GIT_CONFIG="$git_config" cvs update > cvs.log 2>&1
) &&
marked_as cvswork2 textfile.c "" &&
marked_as cvswork2 binfile.bin -kb &&
marked_as cvswork2 .gitattributes "" &&
marked_as cvswork2 mixedUp.c -kb &&
marked_as cvswork2 multiline.c -kb &&
marked_as cvswork2 multilineTxt.c "" &&
not_present cvswork2/subdir withCr.bin &&
not_present cvswork2/subdir file.h &&
marked_as cvswork2/subdir unspecified.other "" &&
marked_as cvswork2/subdir newfile.bin "" &&
marked_as cvswork2/subdir newfile.c "" &&
marked_as cvswork2 simpleBin.bin -kb &&
marked_as cvswork2 simpleText.c "" &&
echo "line replaced_1" > tmpExpect2 &&
echo "line 2" >> tmpExpect2 &&
echo "line replaced_3" >> tmpExpect2 &&
echo "line 4" | q_to_nul >> tmpExpect2 &&
cmp cvswork2/multilineTxt.c tmpExpect2
'
test_done
|