github.com/catandhorse/git-lfs@v2.5.2+incompatible/t/t-env.sh (about) 1 #!/usr/bin/env bash 2 3 . "$(dirname "$0")/testlib.sh" 4 5 envInitConfig='git config filter.lfs.process = "git-lfs filter-process" 6 git config filter.lfs.smudge = "git-lfs smudge -- %f" 7 git config filter.lfs.clean = "git-lfs clean -- %f"' 8 9 begin_test "env with no remote" 10 ( 11 set -e 12 reponame="env-no-remote" 13 mkdir $reponame 14 cd $reponame 15 git init 16 17 localwd=$(native_path "$TRASHDIR/$reponame") 18 localgit=$(native_path "$TRASHDIR/$reponame/.git") 19 localgitstore=$(native_path "$TRASHDIR/$reponame/.git") 20 lfsstorage=$(native_path "$TRASHDIR/$reponame/.git/lfs") 21 localmedia=$(native_path "$TRASHDIR/$reponame/.git/lfs/objects") 22 tempdir=$(native_path "$TRASHDIR/$reponame/.git/lfs/tmp") 23 envVars=$(printf "%s" "$(env | grep "^GIT")") 24 25 expected=$(printf '%s 26 %s 27 28 LocalWorkingDir=%s 29 LocalGitDir=%s 30 LocalGitStorageDir=%s 31 LocalMediaDir=%s 32 LocalReferenceDirs= 33 TempDir=%s 34 ConcurrentTransfers=3 35 TusTransfers=false 36 BasicTransfersOnly=false 37 SkipDownloadErrors=false 38 FetchRecentAlways=false 39 FetchRecentRefsDays=7 40 FetchRecentCommitsDays=0 41 FetchRecentRefsIncludeRemotes=true 42 PruneOffsetDays=3 43 PruneVerifyRemoteAlways=false 44 PruneRemoteName=origin 45 LfsStorageDir=%s 46 AccessDownload=none 47 AccessUpload=none 48 DownloadTransfers=basic 49 UploadTransfers=basic 50 %s 51 %s 52 ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$lfsstorage" "$envVars" "$envInitConfig") 53 actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=") 54 55 contains_same_elements "$expected" "$actual" 56 ) 57 end_test 58 59 begin_test "env with origin remote" 60 ( 61 set -e 62 reponame="env-origin-remote" 63 mkdir $reponame 64 cd $reponame 65 git init 66 git remote add origin "$GITSERVER/env-origin-remote" 67 68 endpoint="$GITSERVER/$reponame.git/info/lfs (auth=none)" 69 localwd=$(native_path "$TRASHDIR/$reponame") 70 localgit=$(native_path "$TRASHDIR/$reponame/.git") 71 localgitstore=$(native_path "$TRASHDIR/$reponame/.git") 72 lfsstorage=$(native_path "$TRASHDIR/$reponame/.git/lfs") 73 localmedia=$(native_path "$TRASHDIR/$reponame/.git/lfs/objects") 74 tempdir=$(native_path "$TRASHDIR/$reponame/.git/lfs/tmp") 75 envVars=$(printf "%s" "$(env | grep "^GIT")") 76 expected=$(printf '%s 77 %s 78 79 Endpoint=%s 80 LocalWorkingDir=%s 81 LocalGitDir=%s 82 LocalGitStorageDir=%s 83 LocalMediaDir=%s 84 LocalReferenceDirs= 85 TempDir=%s 86 ConcurrentTransfers=3 87 TusTransfers=false 88 BasicTransfersOnly=false 89 SkipDownloadErrors=false 90 FetchRecentAlways=false 91 FetchRecentRefsDays=7 92 FetchRecentCommitsDays=0 93 FetchRecentRefsIncludeRemotes=true 94 PruneOffsetDays=3 95 PruneVerifyRemoteAlways=false 96 PruneRemoteName=origin 97 LfsStorageDir=%s 98 AccessDownload=none 99 AccessUpload=none 100 DownloadTransfers=basic 101 UploadTransfers=basic 102 %s 103 %s 104 ' "$(git lfs version)" "$(git version)" "$endpoint" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$lfsstorage" "$envVars" "$envInitConfig") 105 actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=") 106 contains_same_elements "$expected" "$actual" 107 108 cd .git 109 expected2=$(echo "$expected" | sed -e 's/LocalWorkingDir=.*/LocalWorkingDir=/') 110 actual2=$(git lfs env | grep -v "^GIT_EXEC_PATH=") 111 contains_same_elements "$expected2" "$actual2" 112 ) 113 end_test 114 115 begin_test "env with multiple remotes" 116 ( 117 set -e 118 reponame="env-multiple-remotes" 119 mkdir $reponame 120 cd $reponame 121 git init 122 git remote add origin "$GITSERVER/env-origin-remote" 123 git remote add other "$GITSERVER/env-other-remote" 124 125 endpoint="$GITSERVER/env-origin-remote.git/info/lfs (auth=none)" 126 endpoint2="$GITSERVER/env-other-remote.git/info/lfs (auth=none)" 127 localwd=$(native_path "$TRASHDIR/$reponame") 128 localgit=$(native_path "$TRASHDIR/$reponame/.git") 129 localgitstore=$(native_path "$TRASHDIR/$reponame/.git") 130 lfsstorage=$(native_path "$TRASHDIR/$reponame/.git/lfs") 131 localmedia=$(native_path "$TRASHDIR/$reponame/.git/lfs/objects") 132 tempdir=$(native_path "$TRASHDIR/$reponame/.git/lfs/tmp") 133 envVars=$(printf "%s" "$(env | grep "^GIT")") 134 expected=$(printf '%s 135 %s 136 137 Endpoint=%s 138 Endpoint (other)=%s 139 LocalWorkingDir=%s 140 LocalGitDir=%s 141 LocalGitStorageDir=%s 142 LocalMediaDir=%s 143 LocalReferenceDirs= 144 TempDir=%s 145 ConcurrentTransfers=3 146 TusTransfers=false 147 BasicTransfersOnly=false 148 SkipDownloadErrors=false 149 FetchRecentAlways=false 150 FetchRecentRefsDays=7 151 FetchRecentCommitsDays=0 152 FetchRecentRefsIncludeRemotes=true 153 PruneOffsetDays=3 154 PruneVerifyRemoteAlways=false 155 PruneRemoteName=origin 156 LfsStorageDir=%s 157 AccessDownload=none 158 AccessUpload=none 159 DownloadTransfers=basic 160 UploadTransfers=basic 161 %s 162 %s 163 ' "$(git lfs version)" "$(git version)" "$endpoint" "$endpoint2" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$lfsstorage" "$envVars" "$envInitConfig") 164 actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=") 165 contains_same_elements "$expected" "$actual" 166 167 cd .git 168 expected2=$(echo "$expected" | sed -e 's/LocalWorkingDir=.*/LocalWorkingDir=/') 169 actual2=$(git lfs env | grep -v "^GIT_EXEC_PATH=") 170 contains_same_elements "$expected2" "$actual2" 171 ) 172 end_test 173 174 begin_test "env with other remote" 175 ( 176 set -e 177 reponame="env-other-remote" 178 mkdir $reponame 179 cd $reponame 180 git init 181 git remote add other "$GITSERVER/env-other-remote" 182 183 endpoint="$GITSERVER/env-other-remote.git/info/lfs (auth=none)" 184 localwd=$(native_path "$TRASHDIR/$reponame") 185 localgit=$(native_path "$TRASHDIR/$reponame/.git") 186 localgitstore=$(native_path "$TRASHDIR/$reponame/.git") 187 lfsstorage=$(native_path "$TRASHDIR/$reponame/.git/lfs") 188 localmedia=$(native_path "$TRASHDIR/$reponame/.git/lfs/objects") 189 tempdir=$(native_path "$TRASHDIR/$reponame/.git/lfs/tmp") 190 envVars=$(printf "%s" "$(env | grep "^GIT")") 191 192 expected=$(printf '%s 193 %s 194 195 Endpoint (other)=%s 196 LocalWorkingDir=%s 197 LocalGitDir=%s 198 LocalGitStorageDir=%s 199 LocalMediaDir=%s 200 LocalReferenceDirs= 201 TempDir=%s 202 ConcurrentTransfers=3 203 TusTransfers=false 204 BasicTransfersOnly=false 205 SkipDownloadErrors=false 206 FetchRecentAlways=false 207 FetchRecentRefsDays=7 208 FetchRecentCommitsDays=0 209 FetchRecentRefsIncludeRemotes=true 210 PruneOffsetDays=3 211 PruneVerifyRemoteAlways=false 212 PruneRemoteName=origin 213 LfsStorageDir=%s 214 AccessDownload=none 215 AccessUpload=none 216 DownloadTransfers=basic 217 UploadTransfers=basic 218 %s 219 %s 220 ' "$(git lfs version)" "$(git version)" "$endpoint" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$lfsstorage" "$envVars" "$envInitConfig") 221 actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=") 222 contains_same_elements "$expected" "$actual" 223 224 cd .git 225 expected2=$(echo "$expected" | sed -e 's/LocalWorkingDir=.*/LocalWorkingDir=/') 226 actual2=$(git lfs env | grep -v "^GIT_EXEC_PATH=") 227 contains_same_elements "$expected2" "$actual2" 228 ) 229 end_test 230 231 begin_test "env with multiple remotes and lfs.url config" 232 ( 233 set -e 234 reponame="env-multiple-remotes-with-lfs-url" 235 mkdir $reponame 236 cd $reponame 237 git init 238 git remote add origin "$GITSERVER/env-origin-remote" 239 git remote add other "$GITSERVER/env-other-remote" 240 git config lfs.url "http://foo/bar" 241 242 endpoint="$GITSERVER/env-other-remote.git/info/lfs (auth=none)" 243 localwd=$(native_path "$TRASHDIR/$reponame") 244 localgit=$(native_path "$TRASHDIR/$reponame/.git") 245 localgitstore=$(native_path "$TRASHDIR/$reponame/.git") 246 lfsstorage=$(native_path "$TRASHDIR/$reponame/.git/lfs") 247 localmedia=$(native_path "$TRASHDIR/$reponame/.git/lfs/objects") 248 tempdir=$(native_path "$TRASHDIR/$reponame/.git/lfs/tmp") 249 envVars=$(printf "%s" "$(env | grep "^GIT")") 250 expected=$(printf '%s 251 %s 252 253 Endpoint=http://foo/bar (auth=none) 254 Endpoint (other)=%s 255 LocalWorkingDir=%s 256 LocalGitDir=%s 257 LocalGitStorageDir=%s 258 LocalMediaDir=%s 259 LocalReferenceDirs= 260 TempDir=%s 261 ConcurrentTransfers=3 262 TusTransfers=false 263 BasicTransfersOnly=false 264 SkipDownloadErrors=false 265 FetchRecentAlways=false 266 FetchRecentRefsDays=7 267 FetchRecentCommitsDays=0 268 FetchRecentRefsIncludeRemotes=true 269 PruneOffsetDays=3 270 PruneVerifyRemoteAlways=false 271 PruneRemoteName=origin 272 LfsStorageDir=%s 273 AccessDownload=none 274 AccessUpload=none 275 DownloadTransfers=basic 276 UploadTransfers=basic 277 %s 278 %s 279 ' "$(git lfs version)" "$(git version)" "$endpoint" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$lfsstorage" "$envVars" "$envInitConfig") 280 actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=") 281 contains_same_elements "$expected" "$actual" 282 283 cd .git 284 expected2=$(echo "$expected" | sed -e 's/LocalWorkingDir=.*/LocalWorkingDir=/') 285 actual2=$(git lfs env | grep -v "^GIT_EXEC_PATH=") 286 contains_same_elements "$expected2" "$actual2" 287 ) 288 end_test 289 290 begin_test "env with multiple remotes and lfs configs" 291 ( 292 set -e 293 reponame="env-multiple-remotes-lfs-configs" 294 mkdir $reponame 295 cd $reponame 296 git init 297 git remote add origin "$GITSERVER/env-origin-remote" 298 git remote add other "$GITSERVER/env-other-remote" 299 git config lfs.url "http://foo/bar" 300 git config remote.origin.lfsurl "http://custom/origin" 301 git config remote.other.lfsurl "http://custom/other" 302 303 localwd=$(native_path "$TRASHDIR/$reponame") 304 localgit=$(native_path "$TRASHDIR/$reponame/.git") 305 localgitstore=$(native_path "$TRASHDIR/$reponame/.git") 306 lfsstorage=$(native_path "$TRASHDIR/$reponame/.git/lfs") 307 localmedia=$(native_path "$TRASHDIR/$reponame/.git/lfs/objects") 308 tempdir=$(native_path "$TRASHDIR/$reponame/.git/lfs/tmp") 309 envVars=$(printf "%s" "$(env | grep "^GIT")") 310 expected=$(printf '%s 311 %s 312 313 Endpoint=http://foo/bar (auth=none) 314 Endpoint (other)=http://custom/other (auth=none) 315 LocalWorkingDir=%s 316 LocalGitDir=%s 317 LocalGitStorageDir=%s 318 LocalMediaDir=%s 319 LocalReferenceDirs= 320 TempDir=%s 321 ConcurrentTransfers=3 322 TusTransfers=false 323 BasicTransfersOnly=false 324 SkipDownloadErrors=false 325 FetchRecentAlways=false 326 FetchRecentRefsDays=7 327 FetchRecentCommitsDays=0 328 FetchRecentRefsIncludeRemotes=true 329 PruneOffsetDays=3 330 PruneVerifyRemoteAlways=false 331 PruneRemoteName=origin 332 LfsStorageDir=%s 333 AccessDownload=none 334 AccessUpload=none 335 DownloadTransfers=basic 336 UploadTransfers=basic 337 %s 338 %s 339 ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$lfsstorage" "$envVars" "$envInitConfig") 340 actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=") 341 contains_same_elements "$expected" "$actual" 342 343 cd .git 344 expected2=$(echo "$expected" | sed -e 's/LocalWorkingDir=.*/LocalWorkingDir=/') 345 actual2=$(git lfs env | grep -v "^GIT_EXEC_PATH=") 346 contains_same_elements "$expected2" "$actual2" 347 ) 348 end_test 349 350 begin_test "env with multiple remotes and lfs url and batch configs" 351 ( 352 set -e 353 reponame="env-multiple-remotes-lfs-batch-configs" 354 mkdir $reponame 355 cd $reponame 356 git init 357 git remote add origin "$GITSERVER/env-origin-remote" 358 git remote add other "$GITSERVER/env-other-remote" 359 git config lfs.url "http://foo/bar" 360 git config lfs.concurrenttransfers 5 361 git config remote.origin.lfsurl "http://custom/origin" 362 git config remote.other.lfsurl "http://custom/other" 363 364 localwd=$(native_path "$TRASHDIR/$reponame") 365 localgit=$(native_path "$TRASHDIR/$reponame/.git") 366 localgitstore=$(native_path "$TRASHDIR/$reponame/.git") 367 lfsstorage=$(native_path "$TRASHDIR/$reponame/.git/lfs") 368 localmedia=$(native_path "$TRASHDIR/$reponame/.git/lfs/objects") 369 tempdir=$(native_path "$TRASHDIR/$reponame/.git/lfs/tmp") 370 envVars=$(printf "%s" "$(env | grep "^GIT")") 371 expected=$(printf '%s 372 %s 373 374 Endpoint=http://foo/bar (auth=none) 375 Endpoint (other)=http://custom/other (auth=none) 376 LocalWorkingDir=%s 377 LocalGitDir=%s 378 LocalGitStorageDir=%s 379 LocalMediaDir=%s 380 LocalReferenceDirs= 381 TempDir=%s 382 ConcurrentTransfers=5 383 TusTransfers=false 384 BasicTransfersOnly=false 385 SkipDownloadErrors=false 386 FetchRecentAlways=false 387 FetchRecentRefsDays=7 388 FetchRecentCommitsDays=0 389 FetchRecentRefsIncludeRemotes=true 390 PruneOffsetDays=3 391 PruneVerifyRemoteAlways=false 392 PruneRemoteName=origin 393 LfsStorageDir=%s 394 AccessDownload=none 395 AccessUpload=none 396 DownloadTransfers=basic 397 UploadTransfers=basic 398 %s 399 %s 400 ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$lfsstorage" "$envVars" "$envInitConfig") 401 actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=") 402 contains_same_elements "$expected" "$actual" 403 404 cd .git 405 expected2=$(echo "$expected" | sed -e 's/LocalWorkingDir=.*/LocalWorkingDir=/') 406 actual2=$(git lfs env | grep -v "^GIT_EXEC_PATH=") 407 contains_same_elements "$expected2" "$actual2" 408 ) 409 end_test 410 411 begin_test "env with .lfsconfig" 412 ( 413 set -e 414 reponame="env-with-lfsconfig" 415 416 git init $reponame 417 cd $reponame 418 419 git remote add origin "$GITSERVER/env-origin-remote" 420 echo '[remote "origin"] 421 lfsurl = http://foobar:8080/ 422 [lfs] 423 batch = false 424 concurrenttransfers = 5 425 ' > .lfsconfig 426 echo '[remote "origin"] 427 lfsurl = http://foobar:5050/ 428 [lfs] 429 batch = true 430 concurrenttransfers = 50 431 ' > .gitconfig 432 433 localwd=$(native_path "$TRASHDIR/$reponame") 434 localgit=$(native_path "$TRASHDIR/$reponame/.git") 435 localgitstore=$(native_path "$TRASHDIR/$reponame/.git") 436 lfsstorage=$(native_path "$TRASHDIR/$reponame/.git/lfs") 437 localmedia=$(native_path "$TRASHDIR/$reponame/.git/lfs/objects") 438 tempdir=$(native_path "$TRASHDIR/$reponame/.git/lfs/tmp") 439 envVars=$(printf "%s" "$(env | grep "^GIT")") 440 expected=$(printf '%s 441 %s 442 443 Endpoint=http://foobar:8080/ (auth=none) 444 LocalWorkingDir=%s 445 LocalGitDir=%s 446 LocalGitStorageDir=%s 447 LocalMediaDir=%s 448 LocalReferenceDirs= 449 TempDir=%s 450 ConcurrentTransfers=3 451 TusTransfers=false 452 BasicTransfersOnly=false 453 SkipDownloadErrors=false 454 FetchRecentAlways=false 455 FetchRecentRefsDays=7 456 FetchRecentCommitsDays=0 457 FetchRecentRefsIncludeRemotes=true 458 PruneOffsetDays=3 459 PruneVerifyRemoteAlways=false 460 PruneRemoteName=origin 461 LfsStorageDir=%s 462 AccessDownload=none 463 AccessUpload=none 464 DownloadTransfers=basic 465 UploadTransfers=basic 466 %s 467 %s 468 ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$lfsstorage" "$envVars" "$envInitConfig") 469 actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=") 470 contains_same_elements "$expected" "$actual" 471 472 mkdir a 473 cd a 474 actual2=$(git lfs env | grep -v "^GIT_EXEC_PATH=") 475 contains_same_elements "$expected" "$actual2" 476 ) 477 end_test 478 479 begin_test "env with environment variables" 480 ( 481 set -e 482 reponame="env-with-envvars" 483 git init $reponame 484 mkdir -p $reponame/a/b/c 485 486 gitDir=$(native_path "$TRASHDIR/$reponame/.git") 487 workTree=$(native_path "$TRASHDIR/$reponame/a/b") 488 489 localwd=$(native_path "$TRASHDIR/$reponame/a/b") 490 localgit=$(native_path "$TRASHDIR/$reponame/.git") 491 localgitstore=$(native_path "$TRASHDIR/$reponame/.git") 492 lfsstorage=$(native_path "$TRASHDIR/$reponame/.git/lfs") 493 localmedia=$(native_path "$TRASHDIR/$reponame/.git/lfs/objects") 494 tempdir=$(native_path "$TRASHDIR/$reponame/.git/lfs/tmp") 495 envVars="$(GIT_DIR=$gitDir GIT_WORK_TREE=$workTree env | grep "^GIT" | sort)" 496 expected=$(printf '%s 497 %s 498 499 LocalWorkingDir=%s 500 LocalGitDir=%s 501 LocalGitStorageDir=%s 502 LocalMediaDir=%s 503 LocalReferenceDirs= 504 TempDir=%s 505 ConcurrentTransfers=3 506 TusTransfers=false 507 BasicTransfersOnly=false 508 SkipDownloadErrors=false 509 FetchRecentAlways=false 510 FetchRecentRefsDays=7 511 FetchRecentCommitsDays=0 512 FetchRecentRefsIncludeRemotes=true 513 PruneOffsetDays=3 514 PruneVerifyRemoteAlways=false 515 PruneRemoteName=origin 516 LfsStorageDir=%s 517 AccessDownload=none 518 AccessUpload=none 519 DownloadTransfers=basic 520 UploadTransfers=basic 521 %s 522 %s 523 ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$lfsstorage" "$envVars" "$envInitConfig") 524 525 actual=$(GIT_DIR=$gitDir GIT_WORK_TREE=$workTree git lfs env \ 526 | grep -v "^GIT_EXEC_PATH=") 527 contains_same_elements "$expected" "$actual" 528 529 cd $TRASHDIR/$reponame 530 actual2=$(GIT_DIR=$gitDir GIT_WORK_TREE=$workTree git lfs env \ 531 | grep -v "^GIT_EXEC_PATH=") 532 contains_same_elements "$expected" "$actual2" 533 534 cd $TRASHDIR/$reponame/.git 535 actual3=$(GIT_DIR=$gitDir GIT_WORK_TREE=$workTree git lfs env \ 536 | grep -v "^GIT_EXEC_PATH=") 537 contains_same_elements "$expected" "$actual3" 538 539 cd $TRASHDIR/$reponame/a/b/c 540 actual4=$(GIT_DIR=$gitDir GIT_WORK_TREE=$workTree git lfs env \ 541 | grep -v "^GIT_EXEC_PATH=") 542 contains_same_elements "$expected" "$actual4" 543 544 envVars="$(GIT_DIR=$gitDir GIT_WORK_TREE=a/b env | grep "^GIT" | sort)" 545 546 # `a/b` is an invalid relative path from where we are now and results in an 547 # error, so resulting output will have many fields blank or invalid 548 mediaDir5=$(native_path "lfs/objects") 549 tempDir5=$(native_path "lfs/tmp") 550 expected5=$(printf '%s 551 %s 552 553 LocalWorkingDir= 554 LocalGitDir= 555 LocalGitStorageDir= 556 LocalMediaDir=%s 557 LocalReferenceDirs= 558 TempDir=%s 559 ConcurrentTransfers=3 560 TusTransfers=false 561 BasicTransfersOnly=false 562 SkipDownloadErrors=false 563 FetchRecentAlways=false 564 FetchRecentRefsDays=7 565 FetchRecentCommitsDays=0 566 FetchRecentRefsIncludeRemotes=true 567 PruneOffsetDays=3 568 PruneVerifyRemoteAlways=false 569 PruneRemoteName=origin 570 LfsStorageDir=lfs 571 AccessDownload=none 572 AccessUpload=none 573 DownloadTransfers=basic 574 UploadTransfers=basic 575 %s 576 git config filter.lfs.process = "" 577 git config filter.lfs.smudge = "" 578 git config filter.lfs.clean = "" 579 ' "$(git lfs version)" "$(git version)" "$mediaDir5" "$tempDir5" "$envVars") 580 actual5=$(GIT_DIR=$gitDir GIT_WORK_TREE=a/b git lfs env \ 581 | grep -v "^GIT_EXEC_PATH=") 582 contains_same_elements "$expected5" "$actual5" 583 584 cd $TRASHDIR/$reponame/a/b 585 envVars="$(GIT_DIR=$gitDir env | grep "^GIT" | sort)" 586 expected7=$(printf '%s 587 %s 588 589 LocalWorkingDir=%s 590 LocalGitDir=%s 591 LocalGitStorageDir=%s 592 LocalMediaDir=%s 593 LocalReferenceDirs= 594 TempDir=%s 595 ConcurrentTransfers=3 596 TusTransfers=false 597 BasicTransfersOnly=false 598 SkipDownloadErrors=false 599 FetchRecentAlways=false 600 FetchRecentRefsDays=7 601 FetchRecentCommitsDays=0 602 FetchRecentRefsIncludeRemotes=true 603 PruneOffsetDays=3 604 PruneVerifyRemoteAlways=false 605 PruneRemoteName=origin 606 LfsStorageDir=%s 607 AccessDownload=none 608 AccessUpload=none 609 DownloadTransfers=basic 610 UploadTransfers=basic 611 %s 612 %s 613 ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$lfsstorage" "$envVars" "$envInitConfig") 614 actual7=$(GIT_DIR=$gitDir git lfs env | grep -v "^GIT_EXEC_PATH=") 615 contains_same_elements "$expected7" "$actual7" 616 617 cd $TRASHDIR/$reponame/a 618 envVars="$(GIT_WORK_TREE=$workTree env | grep "^GIT" | sort)" 619 expected8=$(printf '%s 620 %s 621 622 LocalWorkingDir=%s 623 LocalGitDir=%s 624 LocalGitStorageDir=%s 625 LocalMediaDir=%s 626 LocalReferenceDirs= 627 TempDir=%s 628 ConcurrentTransfers=3 629 TusTransfers=false 630 BasicTransfersOnly=false 631 SkipDownloadErrors=false 632 FetchRecentAlways=false 633 FetchRecentRefsDays=7 634 FetchRecentCommitsDays=0 635 FetchRecentRefsIncludeRemotes=true 636 PruneOffsetDays=3 637 PruneVerifyRemoteAlways=false 638 PruneRemoteName=origin 639 LfsStorageDir=%s 640 AccessDownload=none 641 AccessUpload=none 642 DownloadTransfers=basic 643 UploadTransfers=basic 644 %s 645 %s 646 ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$lfsstorage" "$envVars" "$envInitConfig") 647 actual8=$(GIT_WORK_TREE=$workTree git lfs env | grep -v "^GIT_EXEC_PATH=") 648 contains_same_elements "$expected8" "$actual8" 649 ) 650 end_test 651 652 begin_test "env with bare repo" 653 ( 654 set -e 655 reponame="env-with-bare-repo" 656 git init --bare $reponame 657 cd $reponame 658 659 localgit=$(native_path "$TRASHDIR/$reponame") 660 localgitstore=$(native_path "$TRASHDIR/$reponame") 661 lfsstorage=$(native_path "$TRASHDIR/$reponame/lfs") 662 localmedia=$(native_path "$TRASHDIR/$reponame/lfs/objects") 663 tempdir=$(native_path "$TRASHDIR/$reponame/lfs/tmp") 664 envVars=$(printf "%s" "$(env | grep "^GIT")") 665 666 expected=$(printf "%s\n%s\n 667 LocalWorkingDir= 668 LocalGitDir=%s 669 LocalGitStorageDir=%s 670 LocalMediaDir=%s 671 LocalReferenceDirs= 672 TempDir=%s 673 ConcurrentTransfers=3 674 TusTransfers=false 675 BasicTransfersOnly=false 676 SkipDownloadErrors=false 677 FetchRecentAlways=false 678 FetchRecentRefsDays=7 679 FetchRecentCommitsDays=0 680 FetchRecentRefsIncludeRemotes=true 681 PruneOffsetDays=3 682 PruneVerifyRemoteAlways=false 683 PruneRemoteName=origin 684 LfsStorageDir=%s 685 AccessDownload=none 686 AccessUpload=none 687 DownloadTransfers=basic 688 UploadTransfers=basic 689 %s 690 %s 691 " "$(git lfs version)" "$(git version)" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$lfsstorage" "$envVars" "$envInitConfig") 692 actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=") 693 contains_same_elements "$expected" "$actual" 694 695 ) 696 end_test 697 698 begin_test "env with multiple ssh remotes" 699 ( 700 set -e 701 reponame="env-with-ssh" 702 mkdir $reponame 703 cd $reponame 704 git init 705 git remote add origin git@git-server.com:user/repo.git 706 git remote add other git@other-git-server.com:user/repo.git 707 708 expected='Endpoint=https://git-server.com/user/repo.git/info/lfs (auth=none) 709 SSH=git@git-server.com:user/repo.git 710 Endpoint (other)=https://other-git-server.com/user/repo.git/info/lfs (auth=none) 711 SSH=git@other-git-server.com:user/repo.git 712 GIT_SSH=lfs-ssh-echo' 713 714 contains_same_elements "$expected" "$(git lfs env \ 715 | grep -v "^GIT_EXEC_PATH=" | grep -e "Endpoint" -e "SSH=")" 716 ) 717 end_test 718 719 begin_test "env with skip download errors" 720 ( 721 set -e 722 reponame="env-with-skip-dl" 723 git init $reponame 724 cd $reponame 725 726 git config lfs.skipdownloaderrors 1 727 728 localgit=$(native_path "$TRASHDIR/$reponame") 729 localgitstore=$(native_path "$TRASHDIR/$reponame") 730 lfsstorage=$(native_path "$TRASHDIR/$reponame/lfs") 731 localmedia=$(native_path "$TRASHDIR/$reponame/lfs/objects") 732 tempdir=$(native_path "$TRASHDIR/$reponame/lfs/tmp") 733 envVars=$(printf "%s" "$(env | grep "^GIT")") 734 735 localwd=$(native_path "$TRASHDIR/$reponame") 736 localgit=$(native_path "$TRASHDIR/$reponame/.git") 737 localgitstore=$(native_path "$TRASHDIR/$reponame/.git") 738 lfsstorage=$(native_path "$TRASHDIR/$reponame/.git/lfs") 739 localmedia=$(native_path "$TRASHDIR/$reponame/.git/lfs/objects") 740 tempdir=$(native_path "$TRASHDIR/$reponame/.git/lfs/tmp") 741 envVars=$(printf "%s" "$(env | grep "^GIT")") 742 743 expectedenabled=$(printf '%s 744 %s 745 746 LocalWorkingDir=%s 747 LocalGitDir=%s 748 LocalGitStorageDir=%s 749 LocalMediaDir=%s 750 LocalReferenceDirs= 751 TempDir=%s 752 ConcurrentTransfers=3 753 TusTransfers=false 754 BasicTransfersOnly=false 755 SkipDownloadErrors=true 756 FetchRecentAlways=false 757 FetchRecentRefsDays=7 758 FetchRecentCommitsDays=0 759 FetchRecentRefsIncludeRemotes=true 760 PruneOffsetDays=3 761 PruneVerifyRemoteAlways=false 762 PruneRemoteName=origin 763 LfsStorageDir=%s 764 AccessDownload=none 765 AccessUpload=none 766 DownloadTransfers=basic 767 UploadTransfers=basic 768 %s 769 %s 770 ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$lfsstorage" "$envVars" "$envInitConfig") 771 actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=") 772 contains_same_elements "$expectedenabled" "$actual" 773 774 git config --unset lfs.skipdownloaderrors 775 # prove it's usually off 776 expecteddisabled=$(printf '%s 777 %s 778 779 LocalWorkingDir=%s 780 LocalGitDir=%s 781 LocalGitStorageDir=%s 782 LocalMediaDir=%s 783 LocalReferenceDirs= 784 TempDir=%s 785 ConcurrentTransfers=3 786 TusTransfers=false 787 BasicTransfersOnly=false 788 SkipDownloadErrors=false 789 FetchRecentAlways=false 790 FetchRecentRefsDays=7 791 FetchRecentCommitsDays=0 792 FetchRecentRefsIncludeRemotes=true 793 PruneOffsetDays=3 794 PruneVerifyRemoteAlways=false 795 PruneRemoteName=origin 796 LfsStorageDir=%s 797 AccessDownload=none 798 AccessUpload=none 799 DownloadTransfers=basic 800 UploadTransfers=basic 801 %s 802 %s 803 ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$lfsstorage" "$envVars" "$envInitConfig") 804 actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=") 805 contains_same_elements "$expecteddisabled" "$actual" 806 807 # now enable via env var 808 envVarsEnabled=$(printf "%s" "$(GIT_LFS_SKIP_DOWNLOAD_ERRORS=1 env | grep "^GIT")") 809 expectedenabled2=$(printf '%s 810 %s 811 812 LocalWorkingDir=%s 813 LocalGitDir=%s 814 LocalGitStorageDir=%s 815 LocalMediaDir=%s 816 LocalReferenceDirs= 817 TempDir=%s 818 ConcurrentTransfers=3 819 TusTransfers=false 820 BasicTransfersOnly=false 821 SkipDownloadErrors=true 822 FetchRecentAlways=false 823 FetchRecentRefsDays=7 824 FetchRecentCommitsDays=0 825 FetchRecentRefsIncludeRemotes=true 826 PruneOffsetDays=3 827 PruneVerifyRemoteAlways=false 828 PruneRemoteName=origin 829 LfsStorageDir=%s 830 AccessDownload=none 831 AccessUpload=none 832 DownloadTransfers=basic 833 UploadTransfers=basic 834 %s 835 %s 836 ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$lfsstorage" "$envVarsEnabled" "$envInitConfig") 837 actual=$(GIT_LFS_SKIP_DOWNLOAD_ERRORS=1 git lfs env | grep -v "^GIT_EXEC_PATH=") 838 contains_same_elements "$expectedenabled2" "$actual" 839 840 841 842 843 ) 844 end_test 845 846 begin_test "env with extra transfer methods" 847 ( 848 set -e 849 reponame="env-with-transfers" 850 git init $reponame 851 cd $reponame 852 853 git config lfs.tustransfers true 854 git config lfs.customtransfer.supertransfer.path /path/to/something 855 856 localgit=$(native_path "$TRASHDIR/$reponame") 857 localgitstore=$(native_path "$TRASHDIR/$reponame") 858 lfsstorage=$(native_path "$TRASHDIR/$reponame/lfs") 859 localmedia=$(native_path "$TRASHDIR/$reponame/lfs/objects") 860 tempdir=$(native_path "$TRASHDIR/$reponame/lfs/tmp") 861 envVars=$(printf "%s" "$(env | grep "^GIT")") 862 863 localwd=$(native_path "$TRASHDIR/$reponame") 864 localgit=$(native_path "$TRASHDIR/$reponame/.git") 865 localgitstore=$(native_path "$TRASHDIR/$reponame/.git") 866 lfsstorage=$(native_path "$TRASHDIR/$reponame/.git/lfs") 867 localmedia=$(native_path "$TRASHDIR/$reponame/.git/lfs/objects") 868 tempdir=$(native_path "$TRASHDIR/$reponame/.git/lfs/tmp") 869 envVars=$(printf "%s" "$(env | grep "^GIT")") 870 871 expectedenabled=$(printf '%s 872 %s 873 874 LocalWorkingDir=%s 875 LocalGitDir=%s 876 LocalGitStorageDir=%s 877 LocalMediaDir=%s 878 LocalReferenceDirs= 879 TempDir=%s 880 ConcurrentTransfers=3 881 TusTransfers=true 882 BasicTransfersOnly=false 883 SkipDownloadErrors=false 884 FetchRecentAlways=false 885 FetchRecentRefsDays=7 886 FetchRecentCommitsDays=0 887 FetchRecentRefsIncludeRemotes=true 888 PruneOffsetDays=3 889 PruneVerifyRemoteAlways=false 890 PruneRemoteName=origin 891 LfsStorageDir=%s 892 AccessDownload=none 893 AccessUpload=none 894 DownloadTransfers=basic,supertransfer 895 UploadTransfers=basic,supertransfer,tus 896 %s 897 %s 898 ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$lfsstorage" "$envVars" "$envInitConfig") 899 actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=") 900 contains_same_elements "$expectedenabled" "$actual" 901 902 ) 903 end_test 904 905 begin_test "env with multiple remotes and ref" 906 ( 907 set -e 908 reponame="env-multiple-remotes-ref" 909 mkdir $reponame 910 cd $reponame 911 git init 912 git remote add origin "$GITSERVER/env-origin-remote" 913 git remote add other "$GITSERVER/env-other-remote" 914 915 touch a.txt 916 git add a.txt 917 git commit -m "initial commit" 918 919 endpoint="$GITSERVER/env-origin-remote.git/info/lfs (auth=none)" 920 endpoint2="$GITSERVER/env-other-remote.git/info/lfs (auth=none)" 921 localwd=$(native_path "$TRASHDIR/$reponame") 922 localgit=$(native_path "$TRASHDIR/$reponame/.git") 923 localgitstore=$(native_path "$TRASHDIR/$reponame/.git") 924 lfsstorage=$(native_path "$TRASHDIR/$reponame/.git/lfs") 925 localmedia=$(native_path "$TRASHDIR/$reponame/.git/lfs/objects") 926 tempdir=$(native_path "$TRASHDIR/$reponame/.git/lfs/tmp") 927 envVars=$(printf "%s" "$(env | grep "^GIT")") 928 expected=$(printf '%s 929 %s 930 931 Endpoint=%s 932 Endpoint (other)=%s 933 LocalWorkingDir=%s 934 LocalGitDir=%s 935 LocalGitStorageDir=%s 936 LocalMediaDir=%s 937 LocalReferenceDirs= 938 TempDir=%s 939 ConcurrentTransfers=3 940 TusTransfers=false 941 BasicTransfersOnly=false 942 SkipDownloadErrors=false 943 FetchRecentAlways=false 944 FetchRecentRefsDays=7 945 FetchRecentCommitsDays=0 946 FetchRecentRefsIncludeRemotes=true 947 PruneOffsetDays=3 948 PruneVerifyRemoteAlways=false 949 PruneRemoteName=origin 950 LfsStorageDir=%s 951 AccessDownload=none 952 AccessUpload=none 953 DownloadTransfers=basic 954 UploadTransfers=basic 955 %s 956 %s 957 ' "$(git lfs version)" "$(git version)" "$endpoint" "$endpoint2" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$lfsstorage" "$envVars" "$envInitConfig") 958 actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=") 959 contains_same_elements "$expected" "$actual" 960 ) 961 end_test