| 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='git-cvsserver and git refspecs |
| 4 | |
| 5 | tests ability for git-cvsserver to switch between and compare |
| 6 | tags, branches and other git refspecs' |
| 7 | |
| 8 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
| 9 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
| 10 | |
| 11 | . ./test-lib.sh |
| 12 | |
| 13 | ######### |
| 14 | |
| 15 | check_start_tree() { |
| 16 | rm -f "$WORKDIR/list.expected" |
| 17 | echo "start $1" >>"${WORKDIR}/check.log" |
| 18 | } |
| 19 | |
| 20 | check_file() { |
| 21 | sandbox="$1" |
| 22 | file="$2" |
| 23 | ver="$3" |
| 24 | GIT_DIR=$SERVERDIR git show "${ver}:${file}" \ |
| 25 | >"$WORKDIR/check.got" 2>"$WORKDIR/check.stderr" |
| 26 | test_cmp "$WORKDIR/check.got" "$sandbox/$file" |
| 27 | stat=$? |
| 28 | echo "check_file $sandbox $file $ver : $stat" >>"$WORKDIR/check.log" |
| 29 | echo "$file" >>"$WORKDIR/list.expected" |
| 30 | return $stat |
| 31 | } |
| 32 | |
| 33 | check_end_tree() { |
| 34 | sandbox="$1" && |
| 35 | find "$sandbox" -name CVS -prune -o -type f -print >"$WORKDIR/list.actual" && |
| 36 | sort <"$WORKDIR/list.expected" >expected && |
| 37 | sort <"$WORKDIR/list.actual" | sed -e "s%cvswork/%%" >actual && |
| 38 | test_cmp expected actual && |
| 39 | rm expected actual |
| 40 | } |
| 41 | |
| 42 | check_end_full_tree() { |
| 43 | sandbox="$1" && |
| 44 | sort <"$WORKDIR/list.expected" >expected && |
| 45 | find "$sandbox" -name CVS -prune -o -type f -print | |
| 46 | sed -e "s%$sandbox/%%" | sort >act1 && |
| 47 | test_cmp expected act1 && |
| 48 | git ls-tree --name-only -r "$2" | sort >act2 && |
| 49 | test_cmp expected act2 && |
| 50 | rm expected act1 act2 |
| 51 | } |
| 52 | |
| 53 | ######### |
| 54 | |
| 55 | check_diff() { |
| 56 | diffFile="$1" |
| 57 | vOld="$2" |
| 58 | vNew="$3" |
| 59 | rm -rf diffSandbox |
| 60 | git clone -q -n . diffSandbox && |
| 61 | ( |
| 62 | cd diffSandbox && |
| 63 | git checkout "$vOld" && |
| 64 | git apply -p0 --index <"../$diffFile" && |
| 65 | git diff --exit-code "$vNew" |
| 66 | ) >check_diff_apply.out 2>&1 |
| 67 | } |
| 68 | |
| 69 | ######### |
| 70 | |
| 71 | if ! cvs version >/dev/null 2>&1 |
| 72 | then |
| 73 | skip_all='skipping git-cvsserver tests, cvs not found' |
| 74 | test_done |
| 75 | fi |
| 76 | |
| 77 | if ! test_have_prereq PERL |
| 78 | then |
| 79 | skip_all='skipping git-cvsserver tests, perl not available' |
| 80 | test_done |
| 81 | fi |
| 82 | perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || { |
| 83 | skip_all='skipping git-cvsserver tests, Perl SQLite interface unavailable' |
| 84 | test_done |
| 85 | } |
| 86 | |
| 87 | unset GIT_DIR GIT_CONFIG |
| 88 | WORKDIR=$PWD |
| 89 | SERVERDIR=$PWD/gitcvs.git |
| 90 | git_config="$SERVERDIR/config" |
| 91 | CVSROOT=":fork:$SERVERDIR" |
| 92 | CVSWORK="$PWD/cvswork" |
| 93 | CVS_SERVER=git-cvsserver |
| 94 | export CVSROOT CVS_SERVER |
| 95 | |
| 96 | rm -rf "$CVSWORK" "$SERVERDIR" |
| 97 | test_expect_success 'setup v1, b1' ' |
| 98 | echo "Simple text file" >textfile.c && |
| 99 | echo "t2" >t2 && |
| 100 | mkdir adir && |
| 101 | echo "adir/afile line1" >adir/afile && |
| 102 | echo "adir/afile line2" >>adir/afile && |
| 103 | echo "adir/afile line3" >>adir/afile && |
| 104 | echo "adir/afile line4" >>adir/afile && |
| 105 | echo "adir/a2file" >>adir/a2file && |
| 106 | mkdir adir/bdir && |
| 107 | echo "adir/bdir/bfile line 1" >adir/bdir/bfile && |
| 108 | echo "adir/bdir/bfile line 2" >>adir/bdir/bfile && |
| 109 | echo "adir/bdir/b2file" >adir/bdir/b2file && |
| 110 | git add textfile.c t2 adir && |
| 111 | git commit -q -m "First Commit (v1)" && |
| 112 | git tag v1 && |
| 113 | git branch b1 && |
| 114 | git clone -q --bare "$WORKDIR/.git" "$SERVERDIR" >/dev/null 2>&1 && |
| 115 | GIT_DIR="$SERVERDIR" git config --bool gitcvs.enabled true && |
| 116 | GIT_DIR="$SERVERDIR" git config gitcvs.logfile "$SERVERDIR/gitcvs.log" |
| 117 | ' |
| 118 | |
| 119 | rm -rf cvswork |
| 120 | test_expect_success 'cvs co v1' ' |
| 121 | cvs -f -Q co -r v1 -d cvswork main >cvs.log 2>&1 && |
| 122 | check_start_tree cvswork && |
| 123 | check_file cvswork textfile.c v1 && |
| 124 | check_file cvswork t2 v1 && |
| 125 | check_file cvswork adir/afile v1 && |
| 126 | check_file cvswork adir/a2file v1 && |
| 127 | check_file cvswork adir/bdir/bfile v1 && |
| 128 | check_file cvswork adir/bdir/b2file v1 && |
| 129 | check_end_tree cvswork |
| 130 | ' |
| 131 | |
| 132 | rm -rf cvswork |
| 133 | test_expect_success 'cvs co b1' ' |
| 134 | cvs -f co -r b1 -d cvswork main >cvs.log 2>&1 && |
| 135 | check_start_tree cvswork && |
| 136 | check_file cvswork textfile.c v1 && |
| 137 | check_file cvswork t2 v1 && |
| 138 | check_file cvswork adir/afile v1 && |
| 139 | check_file cvswork adir/a2file v1 && |
| 140 | check_file cvswork adir/bdir/bfile v1 && |
| 141 | check_file cvswork adir/bdir/b2file v1 && |
| 142 | check_end_tree cvswork |
| 143 | ' |
| 144 | |
| 145 | test_expect_success 'cvs co b1 [cvswork3]' ' |
| 146 | cvs -f co -r b1 -d cvswork3 main >cvs.log 2>&1 && |
| 147 | check_start_tree cvswork3 && |
| 148 | check_file cvswork3 textfile.c v1 && |
| 149 | check_file cvswork3 t2 v1 && |
| 150 | check_file cvswork3 adir/afile v1 && |
| 151 | check_file cvswork3 adir/a2file v1 && |
| 152 | check_file cvswork3 adir/bdir/bfile v1 && |
| 153 | check_file cvswork3 adir/bdir/b2file v1 && |
| 154 | check_end_full_tree cvswork3 v1 |
| 155 | ' |
| 156 | |
| 157 | test_expect_success 'edit cvswork3 and save diff' ' |
| 158 | ( |
| 159 | cd cvswork3 && |
| 160 | sed -e "s/line1/line1 - data/" adir/afile >adir/afileNEW && |
| 161 | mv -f adir/afileNEW adir/afile && |
| 162 | echo "afile5" >adir/afile5 && |
| 163 | rm t2 && |
| 164 | cvs -f add adir/afile5 && |
| 165 | cvs -f rm t2 && |
| 166 | ! cvs -f diff -N -u >"$WORKDIR/cvswork3edit.diff" |
| 167 | ) |
| 168 | ' |
| 169 | |
| 170 | test_expect_success 'setup v1.2 on b1' ' |
| 171 | git checkout b1 && |
| 172 | echo "new v1.2" >t3 && |
| 173 | rm t2 && |
| 174 | sed -e "s/line3/line3 - more data/" adir/afile >adir/afileNEW && |
| 175 | mv -f adir/afileNEW adir/afile && |
| 176 | rm adir/a2file && |
| 177 | echo "a3file" >>adir/a3file && |
| 178 | echo "bfile line 3" >>adir/bdir/bfile && |
| 179 | rm adir/bdir/b2file && |
| 180 | echo "b3file" >adir/bdir/b3file && |
| 181 | mkdir cdir && |
| 182 | echo "cdir/cfile" >cdir/cfile && |
| 183 | git add -A cdir adir t3 t2 && |
| 184 | git commit -q -m "v1.2" && |
| 185 | git tag v1.2 && |
| 186 | git push --tags gitcvs.git b1:b1 |
| 187 | ' |
| 188 | |
| 189 | test_expect_success 'cvs -f up (on b1 adir)' ' |
| 190 | ( cd cvswork/adir && cvs -f up -d ) >cvs.log 2>&1 && |
| 191 | check_start_tree cvswork && |
| 192 | check_file cvswork textfile.c v1 && |
| 193 | check_file cvswork t2 v1 && |
| 194 | check_file cvswork adir/afile v1.2 && |
| 195 | check_file cvswork adir/a3file v1.2 && |
| 196 | check_file cvswork adir/bdir/bfile v1.2 && |
| 197 | check_file cvswork adir/bdir/b3file v1.2 && |
| 198 | check_end_tree cvswork |
| 199 | ' |
| 200 | |
| 201 | test_expect_success 'cvs up (on b1 /)' ' |
| 202 | ( cd cvswork && cvs -f up -d ) >cvs.log 2>&1 && |
| 203 | check_start_tree cvswork && |
| 204 | check_file cvswork textfile.c v1.2 && |
| 205 | check_file cvswork t3 v1.2 && |
| 206 | check_file cvswork adir/afile v1.2 && |
| 207 | check_file cvswork adir/a3file v1.2 && |
| 208 | check_file cvswork adir/bdir/bfile v1.2 && |
| 209 | check_file cvswork adir/bdir/b3file v1.2 && |
| 210 | check_file cvswork cdir/cfile v1.2 && |
| 211 | check_end_tree cvswork |
| 212 | ' |
| 213 | |
| 214 | # Make sure "CVS/Tag" files didn't get messed up: |
| 215 | test_expect_success 'cvs up (on b1 /) (again; check CVS/Tag files)' ' |
| 216 | ( cd cvswork && cvs -f up -d ) >cvs.log 2>&1 && |
| 217 | check_start_tree cvswork && |
| 218 | check_file cvswork textfile.c v1.2 && |
| 219 | check_file cvswork t3 v1.2 && |
| 220 | check_file cvswork adir/afile v1.2 && |
| 221 | check_file cvswork adir/a3file v1.2 && |
| 222 | check_file cvswork adir/bdir/bfile v1.2 && |
| 223 | check_file cvswork adir/bdir/b3file v1.2 && |
| 224 | check_file cvswork cdir/cfile v1.2 && |
| 225 | check_end_tree cvswork |
| 226 | ' |
| 227 | |
| 228 | # update to another version: |
| 229 | test_expect_success 'cvs up -r v1' ' |
| 230 | ( cd cvswork && cvs -f up -r v1 ) >cvs.log 2>&1 && |
| 231 | check_start_tree cvswork && |
| 232 | check_file cvswork textfile.c v1 && |
| 233 | check_file cvswork t2 v1 && |
| 234 | check_file cvswork adir/afile v1 && |
| 235 | check_file cvswork adir/a2file v1 && |
| 236 | check_file cvswork adir/bdir/bfile v1 && |
| 237 | check_file cvswork adir/bdir/b2file v1 && |
| 238 | check_end_tree cvswork |
| 239 | ' |
| 240 | |
| 241 | test_expect_success 'cvs up' ' |
| 242 | ( cd cvswork && cvs -f up ) >cvs.log 2>&1 && |
| 243 | check_start_tree cvswork && |
| 244 | check_file cvswork textfile.c v1 && |
| 245 | check_file cvswork t2 v1 && |
| 246 | check_file cvswork adir/afile v1 && |
| 247 | check_file cvswork adir/a2file v1 && |
| 248 | check_file cvswork adir/bdir/bfile v1 && |
| 249 | check_file cvswork adir/bdir/b2file v1 && |
| 250 | check_end_tree cvswork |
| 251 | ' |
| 252 | |
| 253 | test_expect_success 'cvs up (again; check CVS/Tag files)' ' |
| 254 | ( cd cvswork && cvs -f up -d ) >cvs.log 2>&1 && |
| 255 | check_start_tree cvswork && |
| 256 | check_file cvswork textfile.c v1 && |
| 257 | check_file cvswork t2 v1 && |
| 258 | check_file cvswork adir/afile v1 && |
| 259 | check_file cvswork adir/a2file v1 && |
| 260 | check_file cvswork adir/bdir/bfile v1 && |
| 261 | check_file cvswork adir/bdir/b2file v1 && |
| 262 | check_end_tree cvswork |
| 263 | ' |
| 264 | |
| 265 | test_expect_success 'setup simple b2' ' |
| 266 | git branch b2 v1 && |
| 267 | git push --tags gitcvs.git b2:b2 |
| 268 | ' |
| 269 | |
| 270 | test_expect_success 'cvs co b2 [into cvswork2]' ' |
| 271 | cvs -f co -r b2 -d cvswork2 main >cvs.log 2>&1 && |
| 272 | check_start_tree cvswork && |
| 273 | check_file cvswork textfile.c v1 && |
| 274 | check_file cvswork t2 v1 && |
| 275 | check_file cvswork adir/afile v1 && |
| 276 | check_file cvswork adir/a2file v1 && |
| 277 | check_file cvswork adir/bdir/bfile v1 && |
| 278 | check_file cvswork adir/bdir/b2file v1 && |
| 279 | check_end_tree cvswork |
| 280 | ' |
| 281 | |
| 282 | test_expect_success 'root dir edit [cvswork2]' ' |
| 283 | ( |
| 284 | cd cvswork2 && echo "Line 2" >>textfile.c && |
| 285 | ! cvs -f diff -u >"$WORKDIR/cvsEdit1.diff" && |
| 286 | cvs -f commit -m "edit textfile.c" textfile.c |
| 287 | ) >cvsEdit1.log 2>&1 |
| 288 | ' |
| 289 | |
| 290 | test_expect_success 'root dir rm file [cvswork2]' ' |
| 291 | ( |
| 292 | cd cvswork2 && |
| 293 | cvs -f rm -f t2 && |
| 294 | cvs -f diff -u >../cvsEdit2-empty.diff && |
| 295 | ! cvs -f diff -N -u >"$WORKDIR/cvsEdit2-N.diff" && |
| 296 | cvs -f commit -m "rm t2" |
| 297 | ) >cvsEdit2.log 2>&1 |
| 298 | ' |
| 299 | |
| 300 | test_expect_success 'subdir edit/add/rm files [cvswork2]' ' |
| 301 | ( |
| 302 | cd cvswork2 && |
| 303 | sed -e "s/line 1/line 1 (v2)/" adir/bdir/bfile >adir/bdir/bfileNEW && |
| 304 | mv -f adir/bdir/bfileNEW adir/bdir/bfile && |
| 305 | rm adir/bdir/b2file && |
| 306 | cd adir && |
| 307 | cvs -f rm bdir/b2file && |
| 308 | echo "4th file" >bdir/b4file && |
| 309 | cvs -f add bdir/b4file && |
| 310 | ! cvs -f diff -N -u >"$WORKDIR/cvsEdit3.diff" && |
| 311 | git fetch gitcvs.git b2:b2 && |
| 312 | ( |
| 313 | cd .. && |
| 314 | ! cvs -f diff -u -N -r v1.2 >"$WORKDIR/cvsEdit3-v1.2.diff" && |
| 315 | ! cvs -f diff -u -N -r v1.2 -r v1 >"$WORKDIR/cvsEdit3-v1.2-v1.diff" |
| 316 | ) && |
| 317 | cvs -f commit -m "various add/rm/edit" |
| 318 | ) >cvs.log 2>&1 |
| 319 | ' |
| 320 | |
| 321 | test_expect_success 'validate result of edits [cvswork2]' ' |
| 322 | git fetch gitcvs.git b2:b2 && |
| 323 | git tag v2 b2 && |
| 324 | git push --tags gitcvs.git b2:b2 && |
| 325 | check_start_tree cvswork2 && |
| 326 | check_file cvswork2 textfile.c v2 && |
| 327 | check_file cvswork2 adir/afile v2 && |
| 328 | check_file cvswork2 adir/a2file v2 && |
| 329 | check_file cvswork2 adir/bdir/bfile v2 && |
| 330 | check_file cvswork2 adir/bdir/b4file v2 && |
| 331 | check_end_full_tree cvswork2 v2 |
| 332 | ' |
| 333 | |
| 334 | test_expect_success 'validate basic diffs saved during above cvswork2 edits' ' |
| 335 | test $(grep Index: cvsEdit1.diff | wc -l) = 1 && |
| 336 | test_must_be_empty cvsEdit2-empty.diff && |
| 337 | test $(grep Index: cvsEdit2-N.diff | wc -l) = 1 && |
| 338 | test $(grep Index: cvsEdit3.diff | wc -l) = 3 && |
| 339 | rm -rf diffSandbox && |
| 340 | git clone -q -n . diffSandbox && |
| 341 | ( |
| 342 | cd diffSandbox && |
| 343 | git checkout v1 && |
| 344 | git apply -p0 --index <"$WORKDIR/cvsEdit1.diff" && |
| 345 | git apply -p0 --index <"$WORKDIR/cvsEdit2-N.diff" && |
| 346 | git apply -p0 --directory=adir --index <"$WORKDIR/cvsEdit3.diff" && |
| 347 | git diff --exit-code v2 |
| 348 | ) >"check_diff_apply.out" 2>&1 |
| 349 | ' |
| 350 | |
| 351 | test_expect_success 'validate v1.2 diff saved during last cvswork2 edit' ' |
| 352 | test $(grep Index: cvsEdit3-v1.2.diff | wc -l) = 9 && |
| 353 | check_diff cvsEdit3-v1.2.diff v1.2 v2 |
| 354 | ' |
| 355 | |
| 356 | test_expect_success 'validate v1.2 v1 diff saved during last cvswork2 edit' ' |
| 357 | test $(grep Index: cvsEdit3-v1.2-v1.diff | wc -l) = 9 && |
| 358 | check_diff cvsEdit3-v1.2-v1.diff v1.2 v1 |
| 359 | ' |
| 360 | |
| 361 | test_expect_success 'cvs up [cvswork2]' ' |
| 362 | ( cd cvswork2 && cvs -f up ) >cvs.log 2>&1 && |
| 363 | check_start_tree cvswork2 && |
| 364 | check_file cvswork2 textfile.c v2 && |
| 365 | check_file cvswork2 adir/afile v2 && |
| 366 | check_file cvswork2 adir/a2file v2 && |
| 367 | check_file cvswork2 adir/bdir/bfile v2 && |
| 368 | check_file cvswork2 adir/bdir/b4file v2 && |
| 369 | check_end_full_tree cvswork2 v2 |
| 370 | ' |
| 371 | |
| 372 | test_expect_success 'cvs up -r b2 [back to cvswork]' ' |
| 373 | ( cd cvswork && cvs -f up -r b2 ) >cvs.log 2>&1 && |
| 374 | check_start_tree cvswork && |
| 375 | check_file cvswork textfile.c v2 && |
| 376 | check_file cvswork adir/afile v2 && |
| 377 | check_file cvswork adir/a2file v2 && |
| 378 | check_file cvswork adir/bdir/bfile v2 && |
| 379 | check_file cvswork adir/bdir/b4file v2 && |
| 380 | check_end_full_tree cvswork v2 |
| 381 | ' |
| 382 | |
| 383 | test_expect_success 'cvs up -r b1' ' |
| 384 | ( cd cvswork && cvs -f up -r b1 ) >cvs.log 2>&1 && |
| 385 | check_start_tree cvswork && |
| 386 | check_file cvswork textfile.c v1.2 && |
| 387 | check_file cvswork t3 v1.2 && |
| 388 | check_file cvswork adir/afile v1.2 && |
| 389 | check_file cvswork adir/a3file v1.2 && |
| 390 | check_file cvswork adir/bdir/bfile v1.2 && |
| 391 | check_file cvswork adir/bdir/b3file v1.2 && |
| 392 | check_file cvswork cdir/cfile v1.2 && |
| 393 | check_end_full_tree cvswork v1.2 |
| 394 | ' |
| 395 | |
| 396 | test_expect_success 'cvs up -A' ' |
| 397 | ( cd cvswork && cvs -f up -A ) >cvs.log 2>&1 && |
| 398 | check_start_tree cvswork && |
| 399 | check_file cvswork textfile.c v1 && |
| 400 | check_file cvswork t2 v1 && |
| 401 | check_file cvswork adir/afile v1 && |
| 402 | check_file cvswork adir/a2file v1 && |
| 403 | check_file cvswork adir/bdir/bfile v1 && |
| 404 | check_file cvswork adir/bdir/b2file v1 && |
| 405 | check_end_full_tree cvswork v1 |
| 406 | ' |
| 407 | |
| 408 | test_expect_success 'cvs up (check CVS/Tag files)' ' |
| 409 | ( cd cvswork && cvs -f up ) >cvs.log 2>&1 && |
| 410 | check_start_tree cvswork && |
| 411 | check_file cvswork textfile.c v1 && |
| 412 | check_file cvswork t2 v1 && |
| 413 | check_file cvswork adir/afile v1 && |
| 414 | check_file cvswork adir/a2file v1 && |
| 415 | check_file cvswork adir/bdir/bfile v1 && |
| 416 | check_file cvswork adir/bdir/b2file v1 && |
| 417 | check_end_full_tree cvswork v1 |
| 418 | ' |
| 419 | |
| 420 | # This is not really legal CVS, but it seems to work anyway: |
| 421 | test_expect_success 'cvs up -r heads/b1' ' |
| 422 | ( cd cvswork && cvs -f up -r heads/b1 ) >cvs.log 2>&1 && |
| 423 | check_start_tree cvswork && |
| 424 | check_file cvswork textfile.c v1.2 && |
| 425 | check_file cvswork t3 v1.2 && |
| 426 | check_file cvswork adir/afile v1.2 && |
| 427 | check_file cvswork adir/a3file v1.2 && |
| 428 | check_file cvswork adir/bdir/bfile v1.2 && |
| 429 | check_file cvswork adir/bdir/b3file v1.2 && |
| 430 | check_file cvswork cdir/cfile v1.2 && |
| 431 | check_end_full_tree cvswork v1.2 |
| 432 | ' |
| 433 | |
| 434 | # But this should work even if CVS client checks -r more carefully: |
| 435 | test_expect_success 'cvs up -r heads_-s-b2 (cvsserver escape mechanism)' ' |
| 436 | ( cd cvswork && cvs -f up -r heads_-s-b2 ) >cvs.log 2>&1 && |
| 437 | check_start_tree cvswork && |
| 438 | check_file cvswork textfile.c v2 && |
| 439 | check_file cvswork adir/afile v2 && |
| 440 | check_file cvswork adir/a2file v2 && |
| 441 | check_file cvswork adir/bdir/bfile v2 && |
| 442 | check_file cvswork adir/bdir/b4file v2 && |
| 443 | check_end_full_tree cvswork v2 |
| 444 | ' |
| 445 | |
| 446 | v1hash=$(git rev-parse v1) |
| 447 | test_expect_success 'cvs up -r $(git rev-parse v1)' ' |
| 448 | test -n "$v1hash" && |
| 449 | ( cd cvswork && cvs -f up -r "$v1hash" ) >cvs.log 2>&1 && |
| 450 | check_start_tree cvswork && |
| 451 | check_file cvswork textfile.c v1 && |
| 452 | check_file cvswork t2 v1 && |
| 453 | check_file cvswork adir/afile v1 && |
| 454 | check_file cvswork adir/a2file v1 && |
| 455 | check_file cvswork adir/bdir/bfile v1 && |
| 456 | check_file cvswork adir/bdir/b2file v1 && |
| 457 | check_end_full_tree cvswork v1 |
| 458 | ' |
| 459 | |
| 460 | test_expect_success 'cvs diff -r v1 -u' ' |
| 461 | ( cd cvswork && cvs -f diff -r v1 -u >../cvsDiff.out 2>../cvs.log ) && |
| 462 | test_must_be_empty cvsDiff.out && |
| 463 | test_must_be_empty cvs.log |
| 464 | ' |
| 465 | |
| 466 | test_expect_success 'cvs diff -N -r v2 -u' ' |
| 467 | ( cd cvswork && ! cvs -f diff -N -r v2 -u >../cvsDiff.out 2>../cvs.log ) && |
| 468 | test_must_be_empty cvs.log && |
| 469 | test -s cvsDiff.out && |
| 470 | check_diff cvsDiff.out v2 v1 >check_diff.out 2>&1 |
| 471 | ' |
| 472 | |
| 473 | test_expect_success 'cvs diff -N -r v2 -r v1.2' ' |
| 474 | ( cd cvswork && ! cvs -f diff -N -r v2 -r v1.2 -u >../cvsDiff.out 2>../cvs.log ) && |
| 475 | test_must_be_empty cvs.log && |
| 476 | test -s cvsDiff.out && |
| 477 | check_diff cvsDiff.out v2 v1.2 >check_diff.out 2>&1 |
| 478 | ' |
| 479 | |
| 480 | test_expect_success 'apply early [cvswork3] diff to b3' ' |
| 481 | git clone -q . gitwork3 && |
| 482 | ( |
| 483 | cd gitwork3 && |
| 484 | git checkout -b b3 v1 && |
| 485 | git apply -p0 --index <"$WORKDIR/cvswork3edit.diff" && |
| 486 | git commit -m "cvswork3 edits applied" |
| 487 | ) && |
| 488 | git fetch gitwork3 b3:b3 && |
| 489 | git tag v3 b3 |
| 490 | ' |
| 491 | |
| 492 | test_expect_success 'check [cvswork3] diff' ' |
| 493 | ( cd cvswork3 && ! cvs -f diff -N -u >"$WORKDIR/cvsDiff.out" 2>../cvs.log ) && |
| 494 | test_must_be_empty cvs.log && |
| 495 | test -s cvsDiff.out && |
| 496 | test $(grep Index: cvsDiff.out | wc -l) = 3 && |
| 497 | test_cmp cvsDiff.out cvswork3edit.diff && |
| 498 | check_diff cvsDiff.out v1 v3 >check_diff.out 2>&1 |
| 499 | ' |
| 500 | |
| 501 | test_expect_success 'merge early [cvswork3] b3 with b1' ' |
| 502 | ( cd gitwork3 && git merge -m "message" b1 ) && |
| 503 | git fetch gitwork3 b3:b3 && |
| 504 | git tag v3merged b3 && |
| 505 | git push --tags gitcvs.git b3:b3 |
| 506 | ' |
| 507 | |
| 508 | # This test would fail if cvsserver properly created a ".#afile"* file |
| 509 | # for the merge. |
| 510 | # TODO: Validate that the .# file was saved properly, and then |
| 511 | # delete/ignore it when checking the tree. |
| 512 | test_expect_success 'cvs up dirty [cvswork3]' ' |
| 513 | ( |
| 514 | cd cvswork3 && |
| 515 | cvs -f up && |
| 516 | ! cvs -f diff -N -u >"$WORKDIR/cvsDiff.out" |
| 517 | ) >cvs.log 2>&1 && |
| 518 | test -s cvsDiff.out && |
| 519 | test $(grep Index: cvsDiff.out | wc -l) = 2 && |
| 520 | check_start_tree cvswork3 && |
| 521 | check_file cvswork3 textfile.c v3merged && |
| 522 | check_file cvswork3 t3 v3merged && |
| 523 | check_file cvswork3 adir/afile v3merged && |
| 524 | check_file cvswork3 adir/a3file v3merged && |
| 525 | check_file cvswork3 adir/afile5 v3merged && |
| 526 | check_file cvswork3 adir/bdir/bfile v3merged && |
| 527 | check_file cvswork3 adir/bdir/b3file v3merged && |
| 528 | check_file cvswork3 cdir/cfile v3merged && |
| 529 | check_end_full_tree cvswork3 v3merged |
| 530 | ' |
| 531 | |
| 532 | # TODO: test cvs status |
| 533 | |
| 534 | test_expect_success 'cvs commit [cvswork3]' ' |
| 535 | ( |
| 536 | cd cvswork3 && |
| 537 | cvs -f commit -m "dirty sandbox after auto-merge" |
| 538 | ) >cvs.log 2>&1 && |
| 539 | check_start_tree cvswork3 && |
| 540 | check_file cvswork3 textfile.c v3merged && |
| 541 | check_file cvswork3 t3 v3merged && |
| 542 | check_file cvswork3 adir/afile v3merged && |
| 543 | check_file cvswork3 adir/a3file v3merged && |
| 544 | check_file cvswork3 adir/afile5 v3merged && |
| 545 | check_file cvswork3 adir/bdir/bfile v3merged && |
| 546 | check_file cvswork3 adir/bdir/b3file v3merged && |
| 547 | check_file cvswork3 cdir/cfile v3merged && |
| 548 | check_end_full_tree cvswork3 v3merged && |
| 549 | git fetch gitcvs.git b3:b4 && |
| 550 | git tag v4.1 b4 && |
| 551 | git diff --exit-code v4.1 v3merged >check_diff_apply.out 2>&1 |
| 552 | ' |
| 553 | |
| 554 | test_done |