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 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558
|
#!/usr/bin/env bash
. "$(dirname "$0")/testlib.sh"
do_upload_download_test () {
git lfs track "*.dat" 2>&1 | tee track.log
grep "Tracking \"\*.dat\"" track.log
git add .gitattributes
git commit -m "Tracking"
git checkout -b test
# set up a decent amount of data so that there's work for multiple concurrent adapters
echo "[
{
\"CommitDate\":\"$(get_date -10d)\",
\"Files\":[
{\"Filename\":\"verify.dat\",\"Size\":18,\"Data\":\"send-verify-action\"},
{\"Filename\":\"file1.dat\",\"Size\":1024},
{\"Filename\":\"file2.dat\",\"Size\":750}]
},
{
\"CommitDate\":\"$(get_date -7d)\",
\"Files\":[
{\"Filename\":\"file1.dat\",\"Size\":1050},
{\"Filename\":\"file3.dat\",\"Size\":660},
{\"Filename\":\"file4.dat\",\"Size\":230}]
},
{
\"CommitDate\":\"$(get_date -5d)\",
\"Files\":[
{\"Filename\":\"file5.dat\",\"Size\":1200},
{\"Filename\":\"file6.dat\",\"Size\":300}]
},
{
\"CommitDate\":\"$(get_date -2d)\",
\"Files\":[
{\"Filename\":\"file3.dat\",\"Size\":120},
{\"Filename\":\"file5.dat\",\"Size\":450},
{\"Filename\":\"file7.dat\",\"Size\":520},
{\"Filename\":\"file8.dat\",\"Size\":2048}]
}
]" | lfstest-testutils addcommits
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git push origin test 2>&1 | tee pushcustom.log
# use PIPESTATUS otherwise we get exit code from tee
[ ${PIPESTATUS[0]} = "0" ]
ourobjects=$(cd .git && find lfs/objects -type f | sort)
theirobjects=$(cd $gitdir && find lfs/objects -type f | sort)
# Make sure the lock verification is not attempted.
grep "locks/verify$" pushcustom.log && false
grep "xfer: started custom adapter process" pushcustom.log
grep "Uploading LFS objects: 100% (12/12)" pushcustom.log
[ "$ourobjects" = "$theirobjects" ]
rm -rf .git/lfs/objects
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git lfs fetch --all 2>&1 | tee fetchcustom.log
[ ${PIPESTATUS[0]} = "0" ]
objectlist=$(find .git/lfs/objects -type f)
[ "$(echo "$objectlist" | wc -l)" -eq 12 ]
}
do_local_path_test () {
local reponame="$1"
local suffix="$2"
git lfs track "*.dat" 2>&1 | tee track.log
grep "Tracking \"\*.dat\"" track.log
git add .gitattributes
git commit -m "Tracking"
git checkout -b test
# set up a decent amount of data so that there's work for multiple concurrent adapters
echo "[
{
\"CommitDate\":\"$(get_date -10d)\",
\"Files\":[
{\"Filename\":\"verify.dat\",\"Size\":18,\"Data\":\"send-verify-action\"},
{\"Filename\":\"file1.dat\",\"Size\":1024},
{\"Filename\":\"file2.dat\",\"Size\":750}]
},
{
\"CommitDate\":\"$(get_date -7d)\",
\"Files\":[
{\"Filename\":\"file1.dat\",\"Size\":1050},
{\"Filename\":\"file3.dat\",\"Size\":660},
{\"Filename\":\"file4.dat\",\"Size\":230}]
},
{
\"CommitDate\":\"$(get_date -5d)\",
\"Files\":[
{\"Filename\":\"file5.dat\",\"Size\":1200},
{\"Filename\":\"file6.dat\",\"Size\":300}]
},
{
\"CommitDate\":\"$(get_date -2d)\",
\"Files\":[
{\"Filename\":\"file3.dat\",\"Size\":120},
{\"Filename\":\"file5.dat\",\"Size\":450},
{\"Filename\":\"file7.dat\",\"Size\":520},
{\"Filename\":\"file8.dat\",\"Size\":2048}]
}
]" | lfstest-testutils addcommits
testdir="$(pwd)"
cd "$TRASHDIR"
# Check a clone using an absolute Unix-style path.
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git clone "$testdir$suffix" "$reponame-repo1" 2>&1 | tee clonecustom.log
(cd "$reponame-repo1" && git lfs fsck)
grep "xfer: started custom adapter process" clonecustom.log
# Check a clone using a relative path.
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git clone "$reponame-repo1$suffix" "$reponame-repo2" 2>&1 | tee clonecustom.log
(cd "$reponame-repo2" && git lfs fsck)
grep "xfer: started custom adapter process" clonecustom.log
# Check a clone using an absolute native-style path.
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git clone "$(native_path "$testdir")$suffix" "$reponame-repo3" 2>&1 | tee clonecustom.log
(cd "$reponame-repo3" && git lfs fsck)
grep "xfer: started custom adapter process" clonecustom.log
}
begin_test "standalone-file-upload-download-bare"
(
set -e
# setup a git repo to be used as a local repo, not remote
reponame="standalone-file-upload-download-bare"
setup_remote_repo "$reponame"
git init --bare "$reponame-2.git"
gitdir="$(pwd)/$reponame-2.git"
# clone directly, not through lfstest-gitserver
clone_repo_url "$REMOTEDIR/$reponame.git" $reponame
git remote set-url origin "file://$(urlify "$gitdir")"
do_upload_download_test
)
end_test
begin_test "standalone-file-upload-download-non-bare"
(
set -e
# setup a git repo to be used as a local repo, not remote
reponame="standalone-file-upload-download-non-bare"
setup_remote_repo "$reponame"
git init "$reponame-2.git"
repo2="$(pwd)/$reponame-2.git"
gitdir="$(pwd)/$reponame-2.git/.git"
# clone directly, not through lfstest-gitserver
clone_repo_url "$REMOTEDIR/$reponame.git" $reponame
git remote set-url origin "file://$(urlify "$repo2")"
do_upload_download_test
)
end_test
begin_test "standalone-file-download-missing-file"
(
set -e
# setup a git repo to be used as a local repo, not remote
reponame="standalone-file-download-missing-file"
setup_remote_repo "$reponame"
otherrepo="$(pwd)/$reponame-2.git"
git init --bare "$otherrepo"
# clone directly, not through lfstest-gitserver
clone_repo_url "$REMOTEDIR/$reponame.git" $reponame
git remote set-url origin "file://$(urlify "$otherrepo")"
git lfs track "*.dat" 2>&1 | tee track.log
grep "Tracking \"\*.dat\"" track.log
git add .gitattributes
git commit -m "Tracking"
git checkout -b test
# set up a decent amount of data so that there's work for multiple concurrent adapters
echo "[
{
\"CommitDate\":\"$(get_date -10d)\",
\"Files\":[
{\"Filename\":\"verify.dat\",\"Size\":18,\"Data\":\"send-verify-action\"},
{\"Filename\":\"file1.dat\",\"Size\":1024},
{\"Filename\":\"file2.dat\",\"Size\":750}]
},
{
\"CommitDate\":\"$(get_date -7d)\",
\"Files\":[
{\"Filename\":\"file1.dat\",\"Size\":1050},
{\"Filename\":\"file3.dat\",\"Size\":660},
{\"Filename\":\"file4.dat\",\"Size\":230}]
},
{
\"CommitDate\":\"$(get_date -5d)\",
\"Files\":[
{\"Filename\":\"file5.dat\",\"Size\":1200},
{\"Filename\":\"file6.dat\",\"Size\":300}]
},
{
\"CommitDate\":\"$(get_date -2d)\",
\"Files\":[
{\"Filename\":\"file3.dat\",\"Size\":120},
{\"Filename\":\"file5.dat\",\"Size\":450},
{\"Filename\":\"file7.dat\",\"Size\":520},
{\"Filename\":\"file8.dat\",\"Size\":2048}]
}
]" | lfstest-testutils addcommits
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git push origin test 2>&1 | tee pushcustom.log
# use PIPESTATUS otherwise we get exit code from tee
[ ${PIPESTATUS[0]} = "0" ]
# Make sure the lock verification is not attempted.
grep "locks/verify$" pushcustom.log && false
grep "xfer: started custom adapter process" pushcustom.log
grep "Uploading LFS objects: 100% (12/12)" pushcustom.log
# Delete an object from the remote side. Any object will do.
rm -f $(find "$otherrepo/lfs/objects" -type f | head -n1)
rm -rf .git/lfs/objects
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git lfs fetch --all 2>&1 | tee fetchcustom.log
# Make sure we failed.
[ ${PIPESTATUS[0]} != "0" ]
# Make sure we downloaded the rest of the objects.
objectlist=$(find .git/lfs/objects -type f)
[ "$(echo "$objectlist" | wc -l)" -eq 11 ]
)
end_test
begin_test "standalone-file-clone"
(
set -e
# setup a git repo to be used as a local repo, not remote
reponame="standalone-file-clone"
setup_remote_repo "$reponame"
# clone directly, not through lfstest-gitserver
clone_repo_url "$REMOTEDIR/$reponame.git" $reponame
git lfs track "*.dat" 2>&1 | tee track.log
grep "Tracking \"\*.dat\"" track.log
git add .gitattributes
git commit -m "Tracking"
git checkout -b test
# set up a decent amount of data so that there's work for multiple concurrent adapters
echo "[
{
\"CommitDate\":\"$(get_date -10d)\",
\"Files\":[
{\"Filename\":\"verify.dat\",\"Size\":18,\"Data\":\"send-verify-action\"},
{\"Filename\":\"file1.dat\",\"Size\":1024},
{\"Filename\":\"file2.dat\",\"Size\":750}]
},
{
\"CommitDate\":\"$(get_date -7d)\",
\"Files\":[
{\"Filename\":\"file1.dat\",\"Size\":1050},
{\"Filename\":\"file3.dat\",\"Size\":660},
{\"Filename\":\"file4.dat\",\"Size\":230}]
},
{
\"CommitDate\":\"$(get_date -5d)\",
\"Files\":[
{\"Filename\":\"file5.dat\",\"Size\":1200},
{\"Filename\":\"file6.dat\",\"Size\":300}]
},
{
\"CommitDate\":\"$(get_date -2d)\",
\"Files\":[
{\"Filename\":\"file3.dat\",\"Size\":120},
{\"Filename\":\"file5.dat\",\"Size\":450},
{\"Filename\":\"file7.dat\",\"Size\":520},
{\"Filename\":\"file8.dat\",\"Size\":2048}]
}
]" | lfstest-testutils addcommits
testdir="$(pwd)"
cd "$TRASHDIR"
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git clone "file://$(urlify "$testdir")" repo3 2>&1 | tee clonecustom.log
grep "xfer: started custom adapter process" clonecustom.log
)
end_test
begin_test "standalone-file-local-path"
(
set -e
# setup a git repo to be used as a local repo, not remote
reponame="standalone-file-local-path"
setup_remote_repo "$reponame"
# clone directly, not through lfstest-gitserver
clone_repo_url "$REMOTEDIR/$reponame.git" $reponame
do_local_path_test "$reponame" ""
)
end_test
begin_test "standalone-file-local-path-trailing-slash"
(
set -e
# setup a git repo to be used as a local repo, not remote
reponame="standalone-file-local-path-trailing-slash"
setup_remote_repo "$reponame"
# clone directly, not through lfstest-gitserver
clone_repo_url "$REMOTEDIR/$reponame.git/" $reponame
do_local_path_test "$reponame" "$suffix"
)
end_test
begin_test "standalone-file-lfs.url file URL"
(
set -e
# setup a git repo to be used as a local repo, not remote
reponame="standalone-file-lfsurl"
setup_remote_repo "$reponame"
# clone directly, not through lfstest-gitserver
clone_repo_url "$REMOTEDIR/$reponame.git" $reponame
otherrepo="$(pwd)/$reponame-2.git"
git init --bare "$otherrepo"
wrongrepo="$(pwd)/$reponame-3.git"
git init --bare "$wrongrepo"
git remote set-url origin "file://$(urlify "$wrongrepo")"
git config lfs.url "file://$(urlify "$otherrepo")"
git lfs track "*.dat" 2>&1 | tee track.log
grep "Tracking \"\*.dat\"" track.log
git add .gitattributes
git commit -m "Tracking"
git checkout -b test
# set up a decent amount of data so that there's work for multiple concurrent adapters
echo "[
{
\"CommitDate\":\"$(get_date -10d)\",
\"Files\":[
{\"Filename\":\"verify.dat\",\"Size\":18,\"Data\":\"send-verify-action\"},
{\"Filename\":\"file1.dat\",\"Size\":1024},
{\"Filename\":\"file2.dat\",\"Size\":750}]
},
{
\"CommitDate\":\"$(get_date -7d)\",
\"Files\":[
{\"Filename\":\"file1.dat\",\"Size\":1050},
{\"Filename\":\"file3.dat\",\"Size\":660},
{\"Filename\":\"file4.dat\",\"Size\":230}]
},
{
\"CommitDate\":\"$(get_date -5d)\",
\"Files\":[
{\"Filename\":\"file5.dat\",\"Size\":1200},
{\"Filename\":\"file6.dat\",\"Size\":300}]
},
{
\"CommitDate\":\"$(get_date -2d)\",
\"Files\":[
{\"Filename\":\"file3.dat\",\"Size\":120},
{\"Filename\":\"file5.dat\",\"Size\":450},
{\"Filename\":\"file7.dat\",\"Size\":520},
{\"Filename\":\"file8.dat\",\"Size\":2048}]
}
]" | lfstest-testutils addcommits
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git push origin test 2>&1 | tee pushcustom.log
# use PIPESTATUS otherwise we get exit code from tee
[ ${PIPESTATUS[0]} = "0" ]
# Make sure the lock verification is not attempted.
grep "locks/verify$" pushcustom.log && false
grep "xfer: started custom adapter process" pushcustom.log
grep "Uploading LFS objects: 100% (12/12)" pushcustom.log
# Make sure we didn't write to the wrong repo.
objectlist=$(find "$wrongrepo/lfs/objects" -type f || true)
[ -z "$objectlist" ]
# Make sure we uploaded the expected number of objects.
objectlist=$(find "$otherrepo/lfs/objects" -type f || true)
[ "$(echo "$objectlist" | wc -l)" -eq 12 ]
)
end_test
begin_test "standalone-file-lfs.url http URL"
(
set -e
reponame="standalone-file-lfsurl-http"
setup_remote_repo "$reponame"
# clone directly, not through lfstest-gitserver
clone_repo "$reponame" "$reponame"
wrongrepo="$(pwd)/$reponame-2.git"
git init --bare "$wrongrepo"
git remote set-url origin "file://$(urlify "$wrongrepo")"
git config lfs.url "$(repo_endpoint "$GITSERVER" "$reponame")"
git lfs track "*.dat" 2>&1 | tee track.log
grep "Tracking \"\*.dat\"" track.log
git add .gitattributes
git commit -m "Tracking"
git checkout -b test
# set up a decent amount of data so that there's work for multiple concurrent adapters
echo "[
{
\"CommitDate\":\"$(get_date -10d)\",
\"Files\":[
{\"Filename\":\"verify.dat\",\"Size\":18,\"Data\":\"send-verify-action\"},
{\"Filename\":\"file1.dat\",\"Size\":1024},
{\"Filename\":\"file2.dat\",\"Size\":750}]
},
{
\"CommitDate\":\"$(get_date -7d)\",
\"Files\":[
{\"Filename\":\"file1.dat\",\"Size\":1050},
{\"Filename\":\"file3.dat\",\"Size\":660},
{\"Filename\":\"file4.dat\",\"Size\":230}]
},
{
\"CommitDate\":\"$(get_date -5d)\",
\"Files\":[
{\"Filename\":\"file5.dat\",\"Size\":1200},
{\"Filename\":\"file6.dat\",\"Size\":300}]
},
{
\"CommitDate\":\"$(get_date -2d)\",
\"Files\":[
{\"Filename\":\"file3.dat\",\"Size\":120},
{\"Filename\":\"file5.dat\",\"Size\":450},
{\"Filename\":\"file7.dat\",\"Size\":520},
{\"Filename\":\"file8.dat\",\"Size\":2048}]
}
]" | lfstest-testutils addcommits
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git push origin test 2>&1 | tee push.log
# use PIPESTATUS otherwise we get exit code from tee
[ ${PIPESTATUS[0]} = "0" ]
# We should not use the custom adapter process here.
grep "xfer: started custom adapter process" push.log && exit 1
grep -F "$GITSERVER/$reponame" push.log
# Make sure we didn't write to the wrong repo.
objectlist=$(find "$wrongrepo/lfs/objects" -type f || true)
[ -z "$objectlist" ]
rm -fr .git/lfs/objects
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git lfs fetch --all 2>&1 | tee fetch.log
grep "xfer: started custom adapter process" fetch.log && exit 1
grep -F "$GITSERVER/$reponame" fetch.log
git lfs fsck
)
end_test
begin_test "standalone-file error"
(
set -e
reponame="standalone-file-error"
setup_remote_repo "$reponame"
# clone directly, not through lfstest-gitserver
clone_repo "$reponame" "$reponame"
otherrepo="$(pwd)/$reponame-2.git"
mkdir "$otherrepo"
git remote set-url origin "file://$(urlify "$otherrepo")"
git lfs track "*.dat" 2>&1 | tee track.log
grep "Tracking \"\*.dat\"" track.log
git add .gitattributes
git commit -m "Tracking"
git checkout -b test
# set up a decent amount of data so that there's work for multiple concurrent adapters
echo "[
{
\"CommitDate\":\"$(get_date -10d)\",
\"Files\":[
{\"Filename\":\"verify.dat\",\"Size\":18,\"Data\":\"send-verify-action\"},
{\"Filename\":\"file1.dat\",\"Size\":1024},
{\"Filename\":\"file2.dat\",\"Size\":750}]
},
{
\"CommitDate\":\"$(get_date -7d)\",
\"Files\":[
{\"Filename\":\"file1.dat\",\"Size\":1050},
{\"Filename\":\"file3.dat\",\"Size\":660},
{\"Filename\":\"file4.dat\",\"Size\":230}]
},
{
\"CommitDate\":\"$(get_date -5d)\",
\"Files\":[
{\"Filename\":\"file5.dat\",\"Size\":1200},
{\"Filename\":\"file6.dat\",\"Size\":300}]
},
{
\"CommitDate\":\"$(get_date -2d)\",
\"Files\":[
{\"Filename\":\"file3.dat\",\"Size\":120},
{\"Filename\":\"file5.dat\",\"Size\":450},
{\"Filename\":\"file7.dat\",\"Size\":520},
{\"Filename\":\"file8.dat\",\"Size\":2048}]
}
]" | lfstest-testutils addcommits
if git push origin test 2>pusherror.log
then
exit 1
fi
cat pusherror.log
grep 'not.*a git repository' pusherror.log
)
end_test
|