| 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 | if [ "$IS_WINDOWS" -eq 1 ]; then |
| 10 | export MSYS2_ENV_CONV_EXCL="GIT_LFS_TEST_DIR" |
| 11 | fi |
| 12 | |
| 13 | # The "git lfs env" command should ignore this environment variable |
| 14 | # despite the "GIT_" strings in its name and value. |
| 15 | export TEST_GIT_EXAMPLE="GIT_EXAMPLE" |
| 16 | |
| 17 | setup_expected_concurrent_transfers |
| 18 | |
| 19 | begin_test "env with no remote" |
| 20 | ( |
| 21 | set -e |
| 22 | reponame="env-no-remote" |
| 23 | mkdir $reponame |
| 24 | cd $reponame |
| 25 | git init |
| 26 | |
| 27 | localwd=$(canonical_path "$TRASHDIR/$reponame") |
| 28 | localgit=$(canonical_path "$TRASHDIR/$reponame/.git") |
| 29 | localgitstore=$(canonical_path "$TRASHDIR/$reponame/.git") |
| 30 | lfsstorage=$(canonical_path "$TRASHDIR/$reponame/.git/lfs") |
| 31 | localmedia=$(canonical_path "$TRASHDIR/$reponame/.git/lfs/objects") |
| 32 | tempdir=$(canonical_path "$TRASHDIR/$reponame/.git/lfs/tmp") |
| 33 | envVars=$(printf "%s" "$(env | grep "^GIT_")") |
| 34 | |
| 35 | expected=$(printf '%s |
| 36 | %s |
| 37 | |
| 38 | LocalWorkingDir=%s |
| 39 | LocalGitDir=%s |
| 40 | LocalGitStorageDir=%s |
| 41 | LocalMediaDir=%s |
| 42 | LocalReferenceDirs= |
| 43 | TempDir=%s |
| 44 | ConcurrentTransfers=%d |
| 45 | TusTransfers=false |
| 46 | BasicTransfersOnly=false |
| 47 | SkipDownloadErrors=false |
| 48 | FetchRecentAlways=false |
| 49 | FetchRecentRefsDays=7 |
| 50 | FetchRecentCommitsDays=0 |
| 51 | FetchRecentRefsIncludeRemotes=true |
| 52 | PruneOffsetDays=3 |
| 53 | PruneVerifyRemoteAlways=false |
| 54 | PruneVerifyUnreachableAlways=false |
| 55 | PruneRemoteName=origin |
| 56 | LfsStorageDir=%s |
| 57 | AccessDownload=none |
| 58 | AccessUpload=none |
| 59 | DownloadTransfers=basic,lfs-standalone-file,ssh |
| 60 | UploadTransfers=basic,lfs-standalone-file,ssh |
| 61 | %s |
| 62 | %s |
| 63 | ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$expectedConcurrentTransfers" "$lfsstorage" "$envVars" "$envInitConfig") |
| 64 | actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=") |
| 65 | |
| 66 | contains_same_elements "$expected" "$actual" |
| 67 | ) |
| 68 | end_test |
| 69 | |
| 70 | begin_test "env with origin remote" |
| 71 | ( |
| 72 | set -e |
| 73 | reponame="env-origin-remote" |
| 74 | mkdir $reponame |
| 75 | cd $reponame |
| 76 | git init |
| 77 | git remote add origin "$GITSERVER/env-origin-remote" |
| 78 | |
| 79 | endpoint="$GITSERVER/$reponame.git/info/lfs (auth=none)" |
| 80 | localwd=$(canonical_path "$TRASHDIR/$reponame") |
| 81 | localgit=$(canonical_path "$TRASHDIR/$reponame/.git") |
| 82 | localgitstore=$(canonical_path "$TRASHDIR/$reponame/.git") |
| 83 | lfsstorage=$(canonical_path "$TRASHDIR/$reponame/.git/lfs") |
| 84 | localmedia=$(canonical_path "$TRASHDIR/$reponame/.git/lfs/objects") |
| 85 | tempdir=$(canonical_path "$TRASHDIR/$reponame/.git/lfs/tmp") |
| 86 | envVars=$(printf "%s" "$(env | grep "^GIT_")") |
| 87 | expected=$(printf '%s |
| 88 | %s |
| 89 | |
| 90 | Endpoint=%s |
| 91 | LocalWorkingDir=%s |
| 92 | LocalGitDir=%s |
| 93 | LocalGitStorageDir=%s |
| 94 | LocalMediaDir=%s |
| 95 | LocalReferenceDirs= |
| 96 | TempDir=%s |
| 97 | ConcurrentTransfers=%d |
| 98 | TusTransfers=false |
| 99 | BasicTransfersOnly=false |
| 100 | SkipDownloadErrors=false |
| 101 | FetchRecentAlways=false |
| 102 | FetchRecentRefsDays=7 |
| 103 | FetchRecentCommitsDays=0 |
| 104 | FetchRecentRefsIncludeRemotes=true |
| 105 | PruneOffsetDays=3 |
| 106 | PruneVerifyRemoteAlways=false |
| 107 | PruneVerifyUnreachableAlways=false |
| 108 | PruneRemoteName=origin |
| 109 | LfsStorageDir=%s |
| 110 | AccessDownload=none |
| 111 | AccessUpload=none |
| 112 | DownloadTransfers=basic,lfs-standalone-file,ssh |
| 113 | UploadTransfers=basic,lfs-standalone-file,ssh |
| 114 | %s |
| 115 | %s |
| 116 | ' "$(git lfs version)" "$(git version)" "$endpoint" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$expectedConcurrentTransfers" "$lfsstorage" "$envVars" "$envInitConfig") |
| 117 | actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=") |
| 118 | contains_same_elements "$expected" "$actual" |
| 119 | |
| 120 | cd .git |
| 121 | expected2=$(echo "$expected" | sed -e 's/LocalWorkingDir=.*/LocalWorkingDir=/') |
| 122 | actual2=$(git lfs env | grep -v "^GIT_EXEC_PATH=") |
| 123 | contains_same_elements "$expected2" "$actual2" |
| 124 | ) |
| 125 | end_test |
| 126 | |
| 127 | begin_test "env with multiple remotes" |
| 128 | ( |
| 129 | set -e |
| 130 | reponame="env-multiple-remotes" |
| 131 | mkdir $reponame |
| 132 | cd $reponame |
| 133 | git init |
| 134 | git remote add origin "$GITSERVER/env-origin-remote" |
| 135 | git remote add other "$GITSERVER/env-other-remote" |
| 136 | |
| 137 | endpoint="$GITSERVER/env-origin-remote.git/info/lfs (auth=none)" |
| 138 | endpoint2="$GITSERVER/env-other-remote.git/info/lfs (auth=none)" |
| 139 | localwd=$(canonical_path "$TRASHDIR/$reponame") |
| 140 | localgit=$(canonical_path "$TRASHDIR/$reponame/.git") |
| 141 | localgitstore=$(canonical_path "$TRASHDIR/$reponame/.git") |
| 142 | lfsstorage=$(canonical_path "$TRASHDIR/$reponame/.git/lfs") |
| 143 | localmedia=$(canonical_path "$TRASHDIR/$reponame/.git/lfs/objects") |
| 144 | tempdir=$(canonical_path "$TRASHDIR/$reponame/.git/lfs/tmp") |
| 145 | envVars=$(printf "%s" "$(env | grep "^GIT_")") |
| 146 | expected=$(printf '%s |
| 147 | %s |
| 148 | |
| 149 | Endpoint=%s |
| 150 | Endpoint (other)=%s |
| 151 | LocalWorkingDir=%s |
| 152 | LocalGitDir=%s |
| 153 | LocalGitStorageDir=%s |
| 154 | LocalMediaDir=%s |
| 155 | LocalReferenceDirs= |
| 156 | TempDir=%s |
| 157 | ConcurrentTransfers=%d |
| 158 | TusTransfers=false |
| 159 | BasicTransfersOnly=false |
| 160 | SkipDownloadErrors=false |
| 161 | FetchRecentAlways=false |
| 162 | FetchRecentRefsDays=7 |
| 163 | FetchRecentCommitsDays=0 |
| 164 | FetchRecentRefsIncludeRemotes=true |
| 165 | PruneOffsetDays=3 |
| 166 | PruneVerifyRemoteAlways=false |
| 167 | PruneVerifyUnreachableAlways=false |
| 168 | PruneRemoteName=origin |
| 169 | LfsStorageDir=%s |
| 170 | AccessDownload=none |
| 171 | AccessUpload=none |
| 172 | DownloadTransfers=basic,lfs-standalone-file,ssh |
| 173 | UploadTransfers=basic,lfs-standalone-file,ssh |
| 174 | %s |
| 175 | %s |
| 176 | ' "$(git lfs version)" "$(git version)" "$endpoint" "$endpoint2" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$expectedConcurrentTransfers" "$lfsstorage" "$envVars" "$envInitConfig") |
| 177 | actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=") |
| 178 | contains_same_elements "$expected" "$actual" |
| 179 | |
| 180 | cd .git |
| 181 | expected2=$(echo "$expected" | sed -e 's/LocalWorkingDir=.*/LocalWorkingDir=/') |
| 182 | actual2=$(git lfs env | grep -v "^GIT_EXEC_PATH=") |
| 183 | contains_same_elements "$expected2" "$actual2" |
| 184 | ) |
| 185 | end_test |
| 186 | |
| 187 | begin_test "env with other remote" |
| 188 | ( |
| 189 | set -e |
| 190 | reponame="env-other-remote" |
| 191 | mkdir $reponame |
| 192 | cd $reponame |
| 193 | git init |
| 194 | git remote add other "$GITSERVER/env-other-remote" |
| 195 | |
| 196 | endpoint="$GITSERVER/env-other-remote.git/info/lfs (auth=none)" |
| 197 | localwd=$(canonical_path "$TRASHDIR/$reponame") |
| 198 | localgit=$(canonical_path "$TRASHDIR/$reponame/.git") |
| 199 | localgitstore=$(canonical_path "$TRASHDIR/$reponame/.git") |
| 200 | lfsstorage=$(canonical_path "$TRASHDIR/$reponame/.git/lfs") |
| 201 | localmedia=$(canonical_path "$TRASHDIR/$reponame/.git/lfs/objects") |
| 202 | tempdir=$(canonical_path "$TRASHDIR/$reponame/.git/lfs/tmp") |
| 203 | envVars=$(printf "%s" "$(env | grep "^GIT_")") |
| 204 | |
| 205 | expected=$(printf '%s |
| 206 | %s |
| 207 | |
| 208 | Endpoint (other)=%s |
| 209 | LocalWorkingDir=%s |
| 210 | LocalGitDir=%s |
| 211 | LocalGitStorageDir=%s |
| 212 | LocalMediaDir=%s |
| 213 | LocalReferenceDirs= |
| 214 | TempDir=%s |
| 215 | ConcurrentTransfers=%d |
| 216 | TusTransfers=false |
| 217 | BasicTransfersOnly=false |
| 218 | SkipDownloadErrors=false |
| 219 | FetchRecentAlways=false |
| 220 | FetchRecentRefsDays=7 |
| 221 | FetchRecentCommitsDays=0 |
| 222 | FetchRecentRefsIncludeRemotes=true |
| 223 | PruneOffsetDays=3 |
| 224 | PruneVerifyRemoteAlways=false |
| 225 | PruneVerifyUnreachableAlways=false |
| 226 | PruneRemoteName=origin |
| 227 | LfsStorageDir=%s |
| 228 | AccessDownload=none |
| 229 | AccessUpload=none |
| 230 | DownloadTransfers=basic,lfs-standalone-file,ssh |
| 231 | UploadTransfers=basic,lfs-standalone-file,ssh |
| 232 | %s |
| 233 | %s |
| 234 | ' "$(git lfs version)" "$(git version)" "$endpoint" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$expectedConcurrentTransfers" "$lfsstorage" "$envVars" "$envInitConfig") |
| 235 | actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=") |
| 236 | contains_same_elements "$expected" "$actual" |
| 237 | |
| 238 | cd .git |
| 239 | expected2=$(echo "$expected" | sed -e 's/LocalWorkingDir=.*/LocalWorkingDir=/') |
| 240 | actual2=$(git lfs env | grep -v "^GIT_EXEC_PATH=") |
| 241 | contains_same_elements "$expected2" "$actual2" |
| 242 | ) |
| 243 | end_test |
| 244 | |
| 245 | begin_test "env with multiple remotes and lfs.url config" |
| 246 | ( |
| 247 | set -e |
| 248 | reponame="env-multiple-remotes-with-lfs-url" |
| 249 | mkdir $reponame |
| 250 | cd $reponame |
| 251 | git init |
| 252 | git remote add origin "$GITSERVER/env-origin-remote" |
| 253 | git remote add other "$GITSERVER/env-other-remote" |
| 254 | git config lfs.url "http://foo/bar" |
| 255 | |
| 256 | localwd=$(canonical_path "$TRASHDIR/$reponame") |
| 257 | localgit=$(canonical_path "$TRASHDIR/$reponame/.git") |
| 258 | localgitstore=$(canonical_path "$TRASHDIR/$reponame/.git") |
| 259 | lfsstorage=$(canonical_path "$TRASHDIR/$reponame/.git/lfs") |
| 260 | localmedia=$(canonical_path "$TRASHDIR/$reponame/.git/lfs/objects") |
| 261 | tempdir=$(canonical_path "$TRASHDIR/$reponame/.git/lfs/tmp") |
| 262 | envVars=$(printf "%s" "$(env | grep "^GIT_")") |
| 263 | expected=$(printf '%s |
| 264 | %s |
| 265 | |
| 266 | Endpoint=http://foo/bar (auth=none) |
| 267 | Endpoint (other)=http://foo/bar (auth=none) |
| 268 | LocalWorkingDir=%s |
| 269 | LocalGitDir=%s |
| 270 | LocalGitStorageDir=%s |
| 271 | LocalMediaDir=%s |
| 272 | LocalReferenceDirs= |
| 273 | TempDir=%s |
| 274 | ConcurrentTransfers=%d |
| 275 | TusTransfers=false |
| 276 | BasicTransfersOnly=false |
| 277 | SkipDownloadErrors=false |
| 278 | FetchRecentAlways=false |
| 279 | FetchRecentRefsDays=7 |
| 280 | FetchRecentCommitsDays=0 |
| 281 | FetchRecentRefsIncludeRemotes=true |
| 282 | PruneOffsetDays=3 |
| 283 | PruneVerifyRemoteAlways=false |
| 284 | PruneVerifyUnreachableAlways=false |
| 285 | PruneRemoteName=origin |
| 286 | LfsStorageDir=%s |
| 287 | AccessDownload=none |
| 288 | AccessUpload=none |
| 289 | DownloadTransfers=basic,lfs-standalone-file,ssh |
| 290 | UploadTransfers=basic,lfs-standalone-file,ssh |
| 291 | %s |
| 292 | %s |
| 293 | ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$expectedConcurrentTransfers" "$lfsstorage" "$envVars" "$envInitConfig") |
| 294 | actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=") |
| 295 | contains_same_elements "$expected" "$actual" |
| 296 | |
| 297 | cd .git |
| 298 | expected2=$(echo "$expected" | sed -e 's/LocalWorkingDir=.*/LocalWorkingDir=/') |
| 299 | actual2=$(git lfs env | grep -v "^GIT_EXEC_PATH=") |
| 300 | contains_same_elements "$expected2" "$actual2" |
| 301 | ) |
| 302 | end_test |
| 303 | |
| 304 | begin_test "env with multiple remotes and lfs configs" |
| 305 | ( |
| 306 | set -e |
| 307 | reponame="env-multiple-remotes-lfs-configs" |
| 308 | mkdir $reponame |
| 309 | cd $reponame |
| 310 | git init |
| 311 | git remote add origin "$GITSERVER/env-origin-remote" |
| 312 | git remote add other "$GITSERVER/env-other-remote" |
| 313 | git config lfs.url "http://foo/bar" |
| 314 | git config remote.origin.lfsurl "http://custom/origin" |
| 315 | git config remote.other.lfsurl "http://custom/other" |
| 316 | |
| 317 | localwd=$(canonical_path "$TRASHDIR/$reponame") |
| 318 | localgit=$(canonical_path "$TRASHDIR/$reponame/.git") |
| 319 | localgitstore=$(canonical_path "$TRASHDIR/$reponame/.git") |
| 320 | lfsstorage=$(canonical_path "$TRASHDIR/$reponame/.git/lfs") |
| 321 | localmedia=$(canonical_path "$TRASHDIR/$reponame/.git/lfs/objects") |
| 322 | tempdir=$(canonical_path "$TRASHDIR/$reponame/.git/lfs/tmp") |
| 323 | envVars=$(printf "%s" "$(env | grep "^GIT_")") |
| 324 | expected=$(printf '%s |
| 325 | %s |
| 326 | |
| 327 | Endpoint=http://foo/bar (auth=none) |
| 328 | Endpoint (other)=http://foo/bar (auth=none) |
| 329 | LocalWorkingDir=%s |
| 330 | LocalGitDir=%s |
| 331 | LocalGitStorageDir=%s |
| 332 | LocalMediaDir=%s |
| 333 | LocalReferenceDirs= |
| 334 | TempDir=%s |
| 335 | ConcurrentTransfers=%d |
| 336 | TusTransfers=false |
| 337 | BasicTransfersOnly=false |
| 338 | SkipDownloadErrors=false |
| 339 | FetchRecentAlways=false |
| 340 | FetchRecentRefsDays=7 |
| 341 | FetchRecentCommitsDays=0 |
| 342 | FetchRecentRefsIncludeRemotes=true |
| 343 | PruneOffsetDays=3 |
| 344 | PruneVerifyRemoteAlways=false |
| 345 | PruneVerifyUnreachableAlways=false |
| 346 | PruneRemoteName=origin |
| 347 | LfsStorageDir=%s |
| 348 | AccessDownload=none |
| 349 | AccessUpload=none |
| 350 | DownloadTransfers=basic,lfs-standalone-file,ssh |
| 351 | UploadTransfers=basic,lfs-standalone-file,ssh |
| 352 | %s |
| 353 | %s |
| 354 | ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$expectedConcurrentTransfers" "$lfsstorage" "$envVars" "$envInitConfig") |
| 355 | actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=") |
| 356 | contains_same_elements "$expected" "$actual" |
| 357 | |
| 358 | cd .git |
| 359 | expected2=$(echo "$expected" | sed -e 's/LocalWorkingDir=.*/LocalWorkingDir=/') |
| 360 | actual2=$(git lfs env | grep -v "^GIT_EXEC_PATH=") |
| 361 | contains_same_elements "$expected2" "$actual2" |
| 362 | ) |
| 363 | end_test |
| 364 | |
| 365 | begin_test "env with multiple remotes and batch configs" |
| 366 | ( |
| 367 | set -e |
| 368 | reponame="env-multiple-remotes-lfs-batch-configs" |
| 369 | mkdir $reponame |
| 370 | cd $reponame |
| 371 | git init |
| 372 | git remote add origin "$GITSERVER/env-origin-remote" |
| 373 | git remote add other "$GITSERVER/env-other-remote" |
| 374 | git config lfs.concurrenttransfers 5 |
| 375 | git config remote.origin.lfsurl "http://foo/bar" |
| 376 | git config remote.other.lfsurl "http://custom/other" |
| 377 | |
| 378 | localwd=$(canonical_path "$TRASHDIR/$reponame") |
| 379 | localgit=$(canonical_path "$TRASHDIR/$reponame/.git") |
| 380 | localgitstore=$(canonical_path "$TRASHDIR/$reponame/.git") |
| 381 | lfsstorage=$(canonical_path "$TRASHDIR/$reponame/.git/lfs") |
| 382 | localmedia=$(canonical_path "$TRASHDIR/$reponame/.git/lfs/objects") |
| 383 | tempdir=$(canonical_path "$TRASHDIR/$reponame/.git/lfs/tmp") |
| 384 | envVars=$(printf "%s" "$(env | grep "^GIT_")") |
| 385 | expected=$(printf '%s |
| 386 | %s |
| 387 | |
| 388 | Endpoint=http://foo/bar (auth=none) |
| 389 | Endpoint (other)=http://custom/other (auth=none) |
| 390 | LocalWorkingDir=%s |
| 391 | LocalGitDir=%s |
| 392 | LocalGitStorageDir=%s |
| 393 | LocalMediaDir=%s |
| 394 | LocalReferenceDirs= |
| 395 | TempDir=%s |
| 396 | ConcurrentTransfers=5 |
| 397 | TusTransfers=false |
| 398 | BasicTransfersOnly=false |
| 399 | SkipDownloadErrors=false |
| 400 | FetchRecentAlways=false |
| 401 | FetchRecentRefsDays=7 |
| 402 | FetchRecentCommitsDays=0 |
| 403 | FetchRecentRefsIncludeRemotes=true |
| 404 | PruneOffsetDays=3 |
| 405 | PruneVerifyRemoteAlways=false |
| 406 | PruneVerifyUnreachableAlways=false |
| 407 | PruneRemoteName=origin |
| 408 | LfsStorageDir=%s |
| 409 | AccessDownload=none |
| 410 | AccessUpload=none |
| 411 | DownloadTransfers=basic,lfs-standalone-file,ssh |
| 412 | UploadTransfers=basic,lfs-standalone-file,ssh |
| 413 | %s |
| 414 | %s |
| 415 | ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$lfsstorage" "$envVars" "$envInitConfig") |
| 416 | actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=") |
| 417 | contains_same_elements "$expected" "$actual" |
| 418 | |
| 419 | cd .git |
| 420 | expected2=$(echo "$expected" | sed -e 's/LocalWorkingDir=.*/LocalWorkingDir=/') |
| 421 | actual2=$(git lfs env | grep -v "^GIT_EXEC_PATH=") |
| 422 | contains_same_elements "$expected2" "$actual2" |
| 423 | ) |
| 424 | end_test |
| 425 | |
| 426 | begin_test "env with .lfsconfig" |
| 427 | ( |
| 428 | set -e |
| 429 | reponame="env-with-lfsconfig" |
| 430 | git init $reponame |
| 431 | cd $reponame |
| 432 | |
| 433 | git remote add origin "$GITSERVER/env-origin-remote" |
| 434 | echo '[remote "origin"] |
| 435 | lfsurl = http://foobar:8080/ |
| 436 | [lfs] |
| 437 | batch = false |
| 438 | concurrenttransfers = 5 |
| 439 | ' > .lfsconfig |
| 440 | echo '[remote "origin"] |
| 441 | lfsurl = http://foobar:5050/ |
| 442 | [lfs] |
| 443 | batch = true |
| 444 | concurrenttransfers = 50 |
| 445 | ' > .gitconfig |
| 446 | |
| 447 | localwd=$(canonical_path "$TRASHDIR/$reponame") |
| 448 | localgit=$(canonical_path "$TRASHDIR/$reponame/.git") |
| 449 | localgitstore=$(canonical_path "$TRASHDIR/$reponame/.git") |
| 450 | lfsstorage=$(canonical_path "$TRASHDIR/$reponame/.git/lfs") |
| 451 | localmedia=$(canonical_path "$TRASHDIR/$reponame/.git/lfs/objects") |
| 452 | tempdir=$(canonical_path "$TRASHDIR/$reponame/.git/lfs/tmp") |
| 453 | envVars=$(printf "%s" "$(env | grep "^GIT_")") |
| 454 | expected=$(printf '%s |
| 455 | %s |
| 456 | |
| 457 | Endpoint=http://foobar:8080/ (auth=none) |
| 458 | LocalWorkingDir=%s |
| 459 | LocalGitDir=%s |
| 460 | LocalGitStorageDir=%s |
| 461 | LocalMediaDir=%s |
| 462 | LocalReferenceDirs= |
| 463 | TempDir=%s |
| 464 | ConcurrentTransfers=%d |
| 465 | TusTransfers=false |
| 466 | BasicTransfersOnly=false |
| 467 | SkipDownloadErrors=false |
| 468 | FetchRecentAlways=false |
| 469 | FetchRecentRefsDays=7 |
| 470 | FetchRecentCommitsDays=0 |
| 471 | FetchRecentRefsIncludeRemotes=true |
| 472 | PruneOffsetDays=3 |
| 473 | PruneVerifyRemoteAlways=false |
| 474 | PruneVerifyUnreachableAlways=false |
| 475 | PruneRemoteName=origin |
| 476 | LfsStorageDir=%s |
| 477 | AccessDownload=none |
| 478 | AccessUpload=none |
| 479 | DownloadTransfers=basic,lfs-standalone-file,ssh |
| 480 | UploadTransfers=basic,lfs-standalone-file,ssh |
| 481 | %s |
| 482 | %s |
| 483 | ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$expectedConcurrentTransfers" "$lfsstorage" "$envVars" "$envInitConfig") |
| 484 | actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=") |
| 485 | contains_same_elements "$expected" "$actual" |
| 486 | |
| 487 | mkdir a |
| 488 | cd a |
| 489 | actual2=$(git lfs env | grep -v "^GIT_EXEC_PATH=") |
| 490 | contains_same_elements "$expected" "$actual2" |
| 491 | ) |
| 492 | end_test |
| 493 | |
| 494 | begin_test "env with environment variables" |
| 495 | ( |
| 496 | set -e |
| 497 | reponame="env-with-envvars" |
| 498 | git init $reponame |
| 499 | mkdir -p $reponame/a/b/c |
| 500 | |
| 501 | gitDir=$(canonical_path "$TRASHDIR/$reponame/.git") |
| 502 | workTree=$(canonical_path "$TRASHDIR/$reponame/a/b") |
| 503 | |
| 504 | localwd=$(canonical_path "$TRASHDIR/$reponame/a/b") |
| 505 | localgit=$(canonical_path "$TRASHDIR/$reponame/.git") |
| 506 | localgitstore=$(canonical_path "$TRASHDIR/$reponame/.git") |
| 507 | lfsstorage=$(canonical_path "$TRASHDIR/$reponame/.git/lfs") |
| 508 | localmedia=$(canonical_path "$TRASHDIR/$reponame/.git/lfs/objects") |
| 509 | tempdir=$(canonical_path "$TRASHDIR/$reponame/.git/lfs/tmp") |
| 510 | envVars="$(GIT_DIR=$gitDir GIT_WORK_TREE=$workTree env | grep "^GIT_" | sort)" |
| 511 | expected=$(printf '%s |
| 512 | %s |
| 513 | |
| 514 | LocalWorkingDir=%s |
| 515 | LocalGitDir=%s |
| 516 | LocalGitStorageDir=%s |
| 517 | LocalMediaDir=%s |
| 518 | LocalReferenceDirs= |
| 519 | TempDir=%s |
| 520 | ConcurrentTransfers=%d |
| 521 | TusTransfers=false |
| 522 | BasicTransfersOnly=false |
| 523 | SkipDownloadErrors=false |
| 524 | FetchRecentAlways=false |
| 525 | FetchRecentRefsDays=7 |
| 526 | FetchRecentCommitsDays=0 |
| 527 | FetchRecentRefsIncludeRemotes=true |
| 528 | PruneOffsetDays=3 |
| 529 | PruneVerifyRemoteAlways=false |
| 530 | PruneVerifyUnreachableAlways=false |
| 531 | PruneRemoteName=origin |
| 532 | LfsStorageDir=%s |
| 533 | AccessDownload=none |
| 534 | AccessUpload=none |
| 535 | DownloadTransfers=basic,lfs-standalone-file,ssh |
| 536 | UploadTransfers=basic,lfs-standalone-file,ssh |
| 537 | %s |
| 538 | %s |
| 539 | ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$expectedConcurrentTransfers" "$lfsstorage" "$envVars" "$envInitConfig") |
| 540 | |
| 541 | actual=$(GIT_DIR=$gitDir GIT_WORK_TREE=$workTree git lfs env \ |
| 542 | | grep -v "^GIT_EXEC_PATH=") |
| 543 | contains_same_elements "$expected" "$actual" |
| 544 | |
| 545 | cd $TRASHDIR/$reponame |
| 546 | actual2=$(GIT_DIR=$gitDir GIT_WORK_TREE=$workTree git lfs env \ |
| 547 | | grep -v "^GIT_EXEC_PATH=") |
| 548 | contains_same_elements "$expected" "$actual2" |
| 549 | |
| 550 | cd $TRASHDIR/$reponame/.git |
| 551 | actual3=$(GIT_DIR=$gitDir GIT_WORK_TREE=$workTree git lfs env \ |
| 552 | | grep -v "^GIT_EXEC_PATH=") |
| 553 | contains_same_elements "$expected" "$actual3" |
| 554 | |
| 555 | cd $TRASHDIR/$reponame/a/b/c |
| 556 | actual4=$(GIT_DIR=$gitDir GIT_WORK_TREE=$workTree git lfs env \ |
| 557 | | grep -v "^GIT_EXEC_PATH=") |
| 558 | contains_same_elements "$expected" "$actual4" |
| 559 | |
| 560 | envVars="$(GIT_DIR=$gitDir GIT_WORK_TREE=a/b env | grep "^GIT_" | sort)" |
| 561 | |
| 562 | # `a/b` is an invalid relative path from where we are now and results in an |
| 563 | # error, so resulting output will have many fields blank or invalid |
| 564 | mediaDir5=$(native_path "lfs/objects") |
| 565 | tempDir5=$(native_path "lfs/tmp") |
| 566 | expected5=$(printf '%s |
| 567 | %s |
| 568 | |
| 569 | LocalWorkingDir= |
| 570 | LocalGitDir= |
| 571 | LocalGitStorageDir= |
| 572 | LocalMediaDir=%s |
| 573 | LocalReferenceDirs= |
| 574 | TempDir=%s |
| 575 | ConcurrentTransfers=%d |
| 576 | TusTransfers=false |
| 577 | BasicTransfersOnly=false |
| 578 | SkipDownloadErrors=false |
| 579 | FetchRecentAlways=false |
| 580 | FetchRecentRefsDays=7 |
| 581 | FetchRecentCommitsDays=0 |
| 582 | FetchRecentRefsIncludeRemotes=true |
| 583 | PruneOffsetDays=3 |
| 584 | PruneVerifyRemoteAlways=false |
| 585 | PruneVerifyUnreachableAlways=false |
| 586 | PruneRemoteName=origin |
| 587 | LfsStorageDir=lfs |
| 588 | AccessDownload=none |
| 589 | AccessUpload=none |
| 590 | DownloadTransfers=basic,lfs-standalone-file,ssh |
| 591 | UploadTransfers=basic,lfs-standalone-file,ssh |
| 592 | %s |
| 593 | git config filter.lfs.process = "" |
| 594 | git config filter.lfs.smudge = "" |
| 595 | git config filter.lfs.clean = "" |
| 596 | ' "$(git lfs version)" "$(git version)" "$mediaDir5" "$tempDir5" "$expectedConcurrentTransfers" "$envVars") |
| 597 | actual5=$(GIT_DIR=$gitDir GIT_WORK_TREE=a/b git lfs env \ |
| 598 | | grep -v "^GIT_EXEC_PATH=") |
| 599 | contains_same_elements "$expected5" "$actual5" |
| 600 | |
| 601 | cd $TRASHDIR/$reponame/a/b |
| 602 | envVars="$(GIT_DIR=$gitDir env | grep "^GIT_" | sort)" |
| 603 | expected7=$(printf '%s |
| 604 | %s |
| 605 | |
| 606 | LocalWorkingDir=%s |
| 607 | LocalGitDir=%s |
| 608 | LocalGitStorageDir=%s |
| 609 | LocalMediaDir=%s |
| 610 | LocalReferenceDirs= |
| 611 | TempDir=%s |
| 612 | ConcurrentTransfers=%d |
| 613 | TusTransfers=false |
| 614 | BasicTransfersOnly=false |
| 615 | SkipDownloadErrors=false |
| 616 | FetchRecentAlways=false |
| 617 | FetchRecentRefsDays=7 |
| 618 | FetchRecentCommitsDays=0 |
| 619 | FetchRecentRefsIncludeRemotes=true |
| 620 | PruneOffsetDays=3 |
| 621 | PruneVerifyRemoteAlways=false |
| 622 | PruneVerifyUnreachableAlways=false |
| 623 | PruneRemoteName=origin |
| 624 | LfsStorageDir=%s |
| 625 | AccessDownload=none |
| 626 | AccessUpload=none |
| 627 | DownloadTransfers=basic,lfs-standalone-file,ssh |
| 628 | UploadTransfers=basic,lfs-standalone-file,ssh |
| 629 | %s |
| 630 | %s |
| 631 | ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$expectedConcurrentTransfers" "$lfsstorage" "$envVars" "$envInitConfig") |
| 632 | actual7=$(GIT_DIR=$gitDir git lfs env | grep -v "^GIT_EXEC_PATH=") |
| 633 | contains_same_elements "$expected7" "$actual7" |
| 634 | |
| 635 | cd $TRASHDIR/$reponame/a |
| 636 | envVars="$(GIT_WORK_TREE=$workTree env | grep "^GIT_" | sort)" |
| 637 | expected8=$(printf '%s |
| 638 | %s |
| 639 | |
| 640 | LocalWorkingDir=%s |
| 641 | LocalGitDir=%s |
| 642 | LocalGitStorageDir=%s |
| 643 | LocalMediaDir=%s |
| 644 | LocalReferenceDirs= |
| 645 | TempDir=%s |
| 646 | ConcurrentTransfers=%d |
| 647 | TusTransfers=false |
| 648 | BasicTransfersOnly=false |
| 649 | SkipDownloadErrors=false |
| 650 | FetchRecentAlways=false |
| 651 | FetchRecentRefsDays=7 |
| 652 | FetchRecentCommitsDays=0 |
| 653 | FetchRecentRefsIncludeRemotes=true |
| 654 | PruneOffsetDays=3 |
| 655 | PruneVerifyRemoteAlways=false |
| 656 | PruneVerifyUnreachableAlways=false |
| 657 | PruneRemoteName=origin |
| 658 | LfsStorageDir=%s |
| 659 | AccessDownload=none |
| 660 | AccessUpload=none |
| 661 | DownloadTransfers=basic,lfs-standalone-file,ssh |
| 662 | UploadTransfers=basic,lfs-standalone-file,ssh |
| 663 | %s |
| 664 | %s |
| 665 | ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$expectedConcurrentTransfers" "$lfsstorage" "$envVars" "$envInitConfig") |
| 666 | actual8=$(GIT_WORK_TREE=$workTree git lfs env | grep -v "^GIT_EXEC_PATH=") |
| 667 | contains_same_elements "$expected8" "$actual8" |
| 668 | ) |
| 669 | end_test |
| 670 | |
| 671 | begin_test "env with bare repo" |
| 672 | ( |
| 673 | set -e |
| 674 | reponame="env-with-bare-repo" |
| 675 | git init --bare $reponame |
| 676 | cd $reponame |
| 677 | |
| 678 | localgit=$(canonical_path "$TRASHDIR/$reponame") |
| 679 | localgitstore=$(canonical_path "$TRASHDIR/$reponame") |
| 680 | lfsstorage=$(canonical_path "$TRASHDIR/$reponame/lfs") |
| 681 | localmedia=$(canonical_path "$TRASHDIR/$reponame/lfs/objects") |
| 682 | tempdir=$(canonical_path "$TRASHDIR/$reponame/lfs/tmp") |
| 683 | envVars=$(printf "%s" "$(env | grep "^GIT_")") |
| 684 | |
| 685 | expected=$(printf "%s\n%s\n |
| 686 | LocalWorkingDir= |
| 687 | LocalGitDir=%s |
| 688 | LocalGitStorageDir=%s |
| 689 | LocalMediaDir=%s |
| 690 | LocalReferenceDirs= |
| 691 | TempDir=%s |
| 692 | ConcurrentTransfers=%d |
| 693 | TusTransfers=false |
| 694 | BasicTransfersOnly=false |
| 695 | SkipDownloadErrors=false |
| 696 | FetchRecentAlways=false |
| 697 | FetchRecentRefsDays=7 |
| 698 | FetchRecentCommitsDays=0 |
| 699 | FetchRecentRefsIncludeRemotes=true |
| 700 | PruneOffsetDays=3 |
| 701 | PruneVerifyRemoteAlways=false |
| 702 | PruneVerifyUnreachableAlways=false |
| 703 | PruneRemoteName=origin |
| 704 | LfsStorageDir=%s |
| 705 | AccessDownload=none |
| 706 | AccessUpload=none |
| 707 | DownloadTransfers=basic,lfs-standalone-file,ssh |
| 708 | UploadTransfers=basic,lfs-standalone-file,ssh |
| 709 | %s |
| 710 | %s |
| 711 | " "$(git lfs version)" "$(git version)" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$expectedConcurrentTransfers" "$lfsstorage" "$envVars" "$envInitConfig") |
| 712 | actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=") |
| 713 | contains_same_elements "$expected" "$actual" |
| 714 | |
| 715 | ) |
| 716 | end_test |
| 717 | |
| 718 | begin_test "env with multiple ssh remotes" |
| 719 | ( |
| 720 | set -e |
| 721 | reponame="env-with-ssh" |
| 722 | mkdir $reponame |
| 723 | cd $reponame |
| 724 | git init |
| 725 | git remote add origin [email protected]:user/repo.git |
| 726 | git remote add other [email protected]:user/repo.git |
| 727 | |
| 728 | expected='Endpoint=https://git-server.com/user/repo.git/info/lfs (auth=none) |
| 729 | [email protected]:user/repo.git |
| 730 | Endpoint (other)=https://other-git-server.com/user/repo.git/info/lfs (auth=none) |
| 731 | [email protected]:user/repo.git |
| 732 | GIT_SSH=lfs-ssh-echo' |
| 733 | |
| 734 | contains_same_elements "$expected" "$(git lfs env \ |
| 735 | | grep -v "^GIT_EXEC_PATH=" | grep -e "Endpoint" -e "SSH=")" |
| 736 | ) |
| 737 | end_test |
| 738 | |
| 739 | begin_test "env with skip download errors" |
| 740 | ( |
| 741 | set -e |
| 742 | reponame="env-with-skip-dl" |
| 743 | git init $reponame |
| 744 | cd $reponame |
| 745 | |
| 746 | git config lfs.skipdownloaderrors 1 |
| 747 | |
| 748 | localgit=$(canonical_path "$TRASHDIR/$reponame") |
| 749 | localgitstore=$(canonical_path "$TRASHDIR/$reponame") |
| 750 | lfsstorage=$(canonical_path "$TRASHDIR/$reponame/lfs") |
| 751 | localmedia=$(canonical_path "$TRASHDIR/$reponame/lfs/objects") |
| 752 | tempdir=$(canonical_path "$TRASHDIR/$reponame/lfs/tmp") |
| 753 | envVars=$(printf "%s" "$(env | grep "^GIT_")") |
| 754 | |
| 755 | localwd=$(canonical_path "$TRASHDIR/$reponame") |
| 756 | localgit=$(canonical_path "$TRASHDIR/$reponame/.git") |
| 757 | localgitstore=$(canonical_path "$TRASHDIR/$reponame/.git") |
| 758 | lfsstorage=$(canonical_path "$TRASHDIR/$reponame/.git/lfs") |
| 759 | localmedia=$(canonical_path "$TRASHDIR/$reponame/.git/lfs/objects") |
| 760 | tempdir=$(canonical_path "$TRASHDIR/$reponame/.git/lfs/tmp") |
| 761 | envVars=$(printf "%s" "$(env | grep "^GIT_")") |
| 762 | |
| 763 | expectedenabled=$(printf '%s |
| 764 | %s |
| 765 | |
| 766 | LocalWorkingDir=%s |
| 767 | LocalGitDir=%s |
| 768 | LocalGitStorageDir=%s |
| 769 | LocalMediaDir=%s |
| 770 | LocalReferenceDirs= |
| 771 | TempDir=%s |
| 772 | ConcurrentTransfers=%d |
| 773 | TusTransfers=false |
| 774 | BasicTransfersOnly=false |
| 775 | SkipDownloadErrors=true |
| 776 | FetchRecentAlways=false |
| 777 | FetchRecentRefsDays=7 |
| 778 | FetchRecentCommitsDays=0 |
| 779 | FetchRecentRefsIncludeRemotes=true |
| 780 | PruneOffsetDays=3 |
| 781 | PruneVerifyRemoteAlways=false |
| 782 | PruneVerifyUnreachableAlways=false |
| 783 | PruneRemoteName=origin |
| 784 | LfsStorageDir=%s |
| 785 | AccessDownload=none |
| 786 | AccessUpload=none |
| 787 | DownloadTransfers=basic,lfs-standalone-file,ssh |
| 788 | UploadTransfers=basic,lfs-standalone-file,ssh |
| 789 | %s |
| 790 | %s |
| 791 | ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$expectedConcurrentTransfers" "$lfsstorage" "$envVars" "$envInitConfig") |
| 792 | actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=") |
| 793 | contains_same_elements "$expectedenabled" "$actual" |
| 794 | |
| 795 | git config --unset lfs.skipdownloaderrors |
| 796 | # prove it's usually off |
| 797 | expecteddisabled=$(printf '%s |
| 798 | %s |
| 799 | |
| 800 | LocalWorkingDir=%s |
| 801 | LocalGitDir=%s |
| 802 | LocalGitStorageDir=%s |
| 803 | LocalMediaDir=%s |
| 804 | LocalReferenceDirs= |
| 805 | TempDir=%s |
| 806 | ConcurrentTransfers=%d |
| 807 | TusTransfers=false |
| 808 | BasicTransfersOnly=false |
| 809 | SkipDownloadErrors=false |
| 810 | FetchRecentAlways=false |
| 811 | FetchRecentRefsDays=7 |
| 812 | FetchRecentCommitsDays=0 |
| 813 | FetchRecentRefsIncludeRemotes=true |
| 814 | PruneOffsetDays=3 |
| 815 | PruneVerifyRemoteAlways=false |
| 816 | PruneVerifyUnreachableAlways=false |
| 817 | PruneRemoteName=origin |
| 818 | LfsStorageDir=%s |
| 819 | AccessDownload=none |
| 820 | AccessUpload=none |
| 821 | DownloadTransfers=basic,lfs-standalone-file,ssh |
| 822 | UploadTransfers=basic,lfs-standalone-file,ssh |
| 823 | %s |
| 824 | %s |
| 825 | ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$expectedConcurrentTransfers" "$lfsstorage" "$envVars" "$envInitConfig") |
| 826 | actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=") |
| 827 | contains_same_elements "$expecteddisabled" "$actual" |
| 828 | |
| 829 | # now enable via env var |
| 830 | envVarsEnabled=$(printf "%s" "$(GIT_LFS_SKIP_DOWNLOAD_ERRORS=1 env | grep "^GIT_")") |
| 831 | expectedenabled2=$(printf '%s |
| 832 | %s |
| 833 | |
| 834 | LocalWorkingDir=%s |
| 835 | LocalGitDir=%s |
| 836 | LocalGitStorageDir=%s |
| 837 | LocalMediaDir=%s |
| 838 | LocalReferenceDirs= |
| 839 | TempDir=%s |
| 840 | ConcurrentTransfers=%d |
| 841 | TusTransfers=false |
| 842 | BasicTransfersOnly=false |
| 843 | SkipDownloadErrors=true |
| 844 | FetchRecentAlways=false |
| 845 | FetchRecentRefsDays=7 |
| 846 | FetchRecentCommitsDays=0 |
| 847 | FetchRecentRefsIncludeRemotes=true |
| 848 | PruneOffsetDays=3 |
| 849 | PruneVerifyRemoteAlways=false |
| 850 | PruneVerifyUnreachableAlways=false |
| 851 | PruneRemoteName=origin |
| 852 | LfsStorageDir=%s |
| 853 | AccessDownload=none |
| 854 | AccessUpload=none |
| 855 | DownloadTransfers=basic,lfs-standalone-file,ssh |
| 856 | UploadTransfers=basic,lfs-standalone-file,ssh |
| 857 | %s |
| 858 | %s |
| 859 | ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$expectedConcurrentTransfers" "$lfsstorage" "$envVarsEnabled" "$envInitConfig") |
| 860 | actual=$(GIT_LFS_SKIP_DOWNLOAD_ERRORS=1 git lfs env | grep -v "^GIT_EXEC_PATH=") |
| 861 | contains_same_elements "$expectedenabled2" "$actual" |
| 862 | |
| 863 | |
| 864 | |
| 865 | |
| 866 | ) |
| 867 | end_test |
| 868 | |
| 869 | begin_test "env with extra transfer methods" |
| 870 | ( |
| 871 | set -e |
| 872 | reponame="env-with-transfers" |
| 873 | git init $reponame |
| 874 | cd $reponame |
| 875 | |
| 876 | git config lfs.tustransfers true |
| 877 | git config lfs.customtransfer.supertransfer.path /path/to/something |
| 878 | |
| 879 | localgit=$(canonical_path "$TRASHDIR/$reponame") |
| 880 | localgitstore=$(canonical_path "$TRASHDIR/$reponame") |
| 881 | lfsstorage=$(canonical_path "$TRASHDIR/$reponame/lfs") |
| 882 | localmedia=$(canonical_path "$TRASHDIR/$reponame/lfs/objects") |
| 883 | tempdir=$(canonical_path "$TRASHDIR/$reponame/lfs/tmp") |
| 884 | envVars=$(printf "%s" "$(env | grep "^GIT_")") |
| 885 | |
| 886 | localwd=$(canonical_path "$TRASHDIR/$reponame") |
| 887 | localgit=$(canonical_path "$TRASHDIR/$reponame/.git") |
| 888 | localgitstore=$(canonical_path "$TRASHDIR/$reponame/.git") |
| 889 | lfsstorage=$(canonical_path "$TRASHDIR/$reponame/.git/lfs") |
| 890 | localmedia=$(canonical_path "$TRASHDIR/$reponame/.git/lfs/objects") |
| 891 | tempdir=$(canonical_path "$TRASHDIR/$reponame/.git/lfs/tmp") |
| 892 | envVars=$(printf "%s" "$(env | grep "^GIT_")") |
| 893 | |
| 894 | expectedenabled=$(printf '%s |
| 895 | %s |
| 896 | |
| 897 | LocalWorkingDir=%s |
| 898 | LocalGitDir=%s |
| 899 | LocalGitStorageDir=%s |
| 900 | LocalMediaDir=%s |
| 901 | LocalReferenceDirs= |
| 902 | TempDir=%s |
| 903 | ConcurrentTransfers=%d |
| 904 | TusTransfers=true |
| 905 | BasicTransfersOnly=false |
| 906 | SkipDownloadErrors=false |
| 907 | FetchRecentAlways=false |
| 908 | FetchRecentRefsDays=7 |
| 909 | FetchRecentCommitsDays=0 |
| 910 | FetchRecentRefsIncludeRemotes=true |
| 911 | PruneOffsetDays=3 |
| 912 | PruneVerifyRemoteAlways=false |
| 913 | PruneVerifyUnreachableAlways=false |
| 914 | PruneRemoteName=origin |
| 915 | LfsStorageDir=%s |
| 916 | AccessDownload=none |
| 917 | AccessUpload=none |
| 918 | DownloadTransfers=basic,lfs-standalone-file,ssh,supertransfer |
| 919 | UploadTransfers=basic,lfs-standalone-file,ssh,supertransfer,tus |
| 920 | %s |
| 921 | %s |
| 922 | ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$expectedConcurrentTransfers" "$lfsstorage" "$envVars" "$envInitConfig") |
| 923 | actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=") |
| 924 | contains_same_elements "$expectedenabled" "$actual" |
| 925 | |
| 926 | ) |
| 927 | end_test |
| 928 | |
| 929 | begin_test "env with multiple remotes and ref" |
| 930 | ( |
| 931 | set -e |
| 932 | reponame="env-multiple-remotes-ref" |
| 933 | mkdir $reponame |
| 934 | cd $reponame |
| 935 | git init |
| 936 | git remote add origin "$GITSERVER/env-origin-remote" |
| 937 | git remote add other "$GITSERVER/env-other-remote" |
| 938 | |
| 939 | touch a.txt |
| 940 | git add a.txt |
| 941 | git commit -m "initial commit" |
| 942 | |
| 943 | endpoint="$GITSERVER/env-origin-remote.git/info/lfs (auth=none)" |
| 944 | endpoint2="$GITSERVER/env-other-remote.git/info/lfs (auth=none)" |
| 945 | localwd=$(canonical_path "$TRASHDIR/$reponame") |
| 946 | localgit=$(canonical_path "$TRASHDIR/$reponame/.git") |
| 947 | localgitstore=$(canonical_path "$TRASHDIR/$reponame/.git") |
| 948 | lfsstorage=$(canonical_path "$TRASHDIR/$reponame/.git/lfs") |
| 949 | localmedia=$(canonical_path "$TRASHDIR/$reponame/.git/lfs/objects") |
| 950 | tempdir=$(canonical_path "$TRASHDIR/$reponame/.git/lfs/tmp") |
| 951 | envVars=$(printf "%s" "$(env | grep "^GIT_")") |
| 952 | expected=$(printf '%s |
| 953 | %s |
| 954 | |
| 955 | Endpoint=%s |
| 956 | Endpoint (other)=%s |
| 957 | LocalWorkingDir=%s |
| 958 | LocalGitDir=%s |
| 959 | LocalGitStorageDir=%s |
| 960 | LocalMediaDir=%s |
| 961 | LocalReferenceDirs= |
| 962 | TempDir=%s |
| 963 | ConcurrentTransfers=%d |
| 964 | TusTransfers=false |
| 965 | BasicTransfersOnly=false |
| 966 | SkipDownloadErrors=false |
| 967 | FetchRecentAlways=false |
| 968 | FetchRecentRefsDays=7 |
| 969 | FetchRecentCommitsDays=0 |
| 970 | FetchRecentRefsIncludeRemotes=true |
| 971 | PruneOffsetDays=3 |
| 972 | PruneVerifyRemoteAlways=false |
| 973 | PruneVerifyUnreachableAlways=false |
| 974 | PruneRemoteName=origin |
| 975 | LfsStorageDir=%s |
| 976 | AccessDownload=none |
| 977 | AccessUpload=none |
| 978 | DownloadTransfers=basic,lfs-standalone-file,ssh |
| 979 | UploadTransfers=basic,lfs-standalone-file,ssh |
| 980 | %s |
| 981 | %s |
| 982 | ' "$(git lfs version)" "$(git version)" "$endpoint" "$endpoint2" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$expectedConcurrentTransfers" "$lfsstorage" "$envVars" "$envInitConfig") |
| 983 | actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=") |
| 984 | contains_same_elements "$expected" "$actual" |
| 985 | ) |
| 986 | end_test |
| 987 | |
| 988 | |
| 989 | begin_test "env with unicode" |
| 990 | ( |
| 991 | set -e |
| 992 | # This contains a Unicode apostrophe, an E with grave accent, and a Euro sign. |
| 993 | # Only the middle one is representable in ISO-8859-1. |
| 994 | reponame="env-d’autre-nom-très-bizarr€" |
| 995 | mkdir $reponame |
| 996 | cd $reponame |
| 997 | git init |
| 998 | git remote add origin "$GITSERVER/env-origin-remote" |
| 999 | git remote add other "$GITSERVER/env-other-remote" |
| 1000 | |
| 1001 | touch a.txt |
| 1002 | git add a.txt |
| 1003 | git commit -m "initial commit" |
| 1004 | |
| 1005 | # Set by the testsuite. |
| 1006 | unset LC_ALL |
| 1007 | |
| 1008 | endpoint="$GITSERVER/env-origin-remote.git/info/lfs (auth=none)" |
| 1009 | endpoint2="$GITSERVER/env-other-remote.git/info/lfs (auth=none)" |
| 1010 | localwd=$(canonical_path "$TRASHDIR/$reponame") |
| 1011 | localgit=$(canonical_path "$TRASHDIR/$reponame/.git") |
| 1012 | localgitstore=$(canonical_path "$TRASHDIR/$reponame/.git") |
| 1013 | lfsstorage=$(canonical_path "$TRASHDIR/$reponame/.git/lfs") |
| 1014 | localmedia=$(canonical_path "$TRASHDIR/$reponame/.git/lfs/objects") |
| 1015 | tempdir=$(canonical_path "$TRASHDIR/$reponame/.git/lfs/tmp") |
| 1016 | envVars=$(printf "%s" "$(env | grep "^GIT_")") |
| 1017 | expected=$(printf '%s |
| 1018 | %s |
| 1019 | |
| 1020 | Endpoint=%s |
| 1021 | Endpoint (other)=%s |
| 1022 | LocalWorkingDir=%s |
| 1023 | LocalGitDir=%s |
| 1024 | LocalGitStorageDir=%s |
| 1025 | LocalMediaDir=%s |
| 1026 | LocalReferenceDirs= |
| 1027 | TempDir=%s |
| 1028 | ConcurrentTransfers=%d |
| 1029 | TusTransfers=false |
| 1030 | BasicTransfersOnly=false |
| 1031 | SkipDownloadErrors=false |
| 1032 | FetchRecentAlways=false |
| 1033 | FetchRecentRefsDays=7 |
| 1034 | FetchRecentCommitsDays=0 |
| 1035 | FetchRecentRefsIncludeRemotes=true |
| 1036 | PruneOffsetDays=3 |
| 1037 | PruneVerifyRemoteAlways=false |
| 1038 | PruneVerifyUnreachableAlways=false |
| 1039 | PruneRemoteName=origin |
| 1040 | LfsStorageDir=%s |
| 1041 | AccessDownload=none |
| 1042 | AccessUpload=none |
| 1043 | DownloadTransfers=basic,lfs-standalone-file,ssh |
| 1044 | UploadTransfers=basic,lfs-standalone-file,ssh |
| 1045 | %s |
| 1046 | %s |
| 1047 | ' "$(git lfs version)" "$(git version)" "$endpoint" "$endpoint2" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$expectedConcurrentTransfers" "$lfsstorage" "$envVars" "$envInitConfig") |
| 1048 | actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=") |
| 1049 | contains_same_elements "$expected" "$actual" |
| 1050 | ) |
| 1051 | end_test |
| 1052 | |
| 1053 | begin_test "env outside a repository" |
| 1054 | ( |
| 1055 | set -e |
| 1056 | |
| 1057 | # This may or may not work, depending on the system, but it should at least |
| 1058 | # potentially cause Git to print non-English messages. |
| 1059 | export LC_ALL=fr_FR.UTF-8 |
| 1060 | |
| 1061 | localmedia="$(native_path "lfs/objects")" |
| 1062 | lfsstorage=lfs |
| 1063 | tempdir="$(native_path "lfs/tmp")" |
| 1064 | envVars=$(printf "%s" "$(env | grep "^GIT_")") |
| 1065 | expected=$(printf '%s |
| 1066 | %s |
| 1067 | |
| 1068 | LocalWorkingDir= |
| 1069 | LocalGitDir= |
| 1070 | LocalGitStorageDir= |
| 1071 | LocalMediaDir=%s |
| 1072 | LocalReferenceDirs= |
| 1073 | TempDir=%s |
| 1074 | ConcurrentTransfers=%d |
| 1075 | TusTransfers=false |
| 1076 | BasicTransfersOnly=false |
| 1077 | SkipDownloadErrors=false |
| 1078 | FetchRecentAlways=false |
| 1079 | FetchRecentRefsDays=7 |
| 1080 | FetchRecentCommitsDays=0 |
| 1081 | FetchRecentRefsIncludeRemotes=true |
| 1082 | PruneOffsetDays=3 |
| 1083 | PruneVerifyRemoteAlways=false |
| 1084 | PruneVerifyUnreachableAlways=false |
| 1085 | PruneRemoteName=origin |
| 1086 | LfsStorageDir=%s |
| 1087 | AccessDownload=none |
| 1088 | AccessUpload=none |
| 1089 | DownloadTransfers=basic,lfs-standalone-file,ssh |
| 1090 | UploadTransfers=basic,lfs-standalone-file,ssh |
| 1091 | %s |
| 1092 | %s |
| 1093 | ' "$(git lfs version)" "$(git version)" "$localmedia" "$tempdir" "$expectedConcurrentTransfers" "$lfsstorage" "$envVars" "$envInitConfig") |
| 1094 | # We redirect the standard error here because we should not get any error |
| 1095 | # messages, and if we do, we want to fail. |
| 1096 | actual=$(git lfs env 2>&1 | grep -v "^GIT_EXEC_PATH=") |
| 1097 | contains_same_elements "$expected" "$actual" |
| 1098 | ) |
| 1099 | end_test |
| 1100 | |
| 1101 | begin_test "env with duplicate endpoints" |
| 1102 | ( |
| 1103 | set -e |
| 1104 | reponame="env-duplicate-endpoints" |
| 1105 | mkdir $reponame |
| 1106 | cd $reponame |
| 1107 | git init |
| 1108 | git remote add origin "$GITSERVER/env-origin-remote" |
| 1109 | git remote add other "$GITSERVER/env-other-remote" |
| 1110 | |
| 1111 | touch a.txt |
| 1112 | git add a.txt |
| 1113 | git commit -m "initial commit" |
| 1114 | |
| 1115 | cat <<EOF >>.git/config |
| 1116 | [url "https://host.example/domain/"] |
| 1117 | insteadOf = [email protected]:domain/ |
| 1118 | [url "https://host.example/domain/"] |
| 1119 | insteadOf = [email protected]:domain/ |
| 1120 | EOF |
| 1121 | |
| 1122 | git lfs env 2>&1 | tee test.log |
| 1123 | if grep 'warning.*same alias' test.log |
| 1124 | then |
| 1125 | exit 1 |
| 1126 | fi |
| 1127 | |
| 1128 | cat <<EOF >>.git/config |
| 1129 | [url "https://somewhere-else.example/domain/"] |
| 1130 | insteadOf = [email protected]:domain/ |
| 1131 | EOF |
| 1132 | |
| 1133 | git lfs env 2>&1 | tee test.log |
| 1134 | grep 'warning.*same alias' test.log |
| 1135 | ) |
| 1136 | end_test |