2a3047e2204ed05e22481d8e2c80b38c90432327
[scm/test.git] / test / test-env.sh
1 #!/usr/bin/env bash
2
3 . "test/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 LocalReferenceDir=
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 LocalReferenceDir=
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 LocalReferenceDir=
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 LocalReferenceDir=
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 LocalReferenceDir=
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 LocalReferenceDir=
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 LocalReferenceDir=
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 LocalReferenceDir=
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 LocalReferenceDir=
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   expected5=$(printf '%s
546 %s
547
548 LocalWorkingDir=%s
549 LocalGitDir=%s
550 LocalGitStorageDir=%s
551 LocalMediaDir=%s
552 LocalReferenceDir=
553 TempDir=%s
554 ConcurrentTransfers=3
555 TusTransfers=false
556 BasicTransfersOnly=false
557 SkipDownloadErrors=false
558 FetchRecentAlways=false
559 FetchRecentRefsDays=7
560 FetchRecentCommitsDays=0
561 FetchRecentRefsIncludeRemotes=true
562 PruneOffsetDays=3
563 PruneVerifyRemoteAlways=false
564 PruneRemoteName=origin
565 LfsStorageDir=%s
566 AccessDownload=none
567 AccessUpload=none
568 DownloadTransfers=basic
569 UploadTransfers=basic
570 %s
571 ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$lfsstorage" "$envVars")
572   actual5=$(GIT_DIR=$gitDir GIT_WORK_TREE=a/b git lfs env \
573             | grep -v "^GIT_EXEC_PATH=")
574   contains_same_elements "$expected5" "$actual5"
575
576   cd $TRASHDIR/$reponame/a/b
577   envVars="$(GIT_DIR=$gitDir env | grep "^GIT" | sort)"
578   expected7=$(printf '%s
579 %s
580
581 LocalWorkingDir=%s
582 LocalGitDir=%s
583 LocalGitStorageDir=%s
584 LocalMediaDir=%s
585 LocalReferenceDir=
586 TempDir=%s
587 ConcurrentTransfers=3
588 TusTransfers=false
589 BasicTransfersOnly=false
590 SkipDownloadErrors=false
591 FetchRecentAlways=false
592 FetchRecentRefsDays=7
593 FetchRecentCommitsDays=0
594 FetchRecentRefsIncludeRemotes=true
595 PruneOffsetDays=3
596 PruneVerifyRemoteAlways=false
597 PruneRemoteName=origin
598 LfsStorageDir=%s
599 AccessDownload=none
600 AccessUpload=none
601 DownloadTransfers=basic
602 UploadTransfers=basic
603 %s
604 %s
605 ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$lfsstorage" "$envVars" "$envInitConfig")
606   actual7=$(GIT_DIR=$gitDir git lfs env | grep -v "^GIT_EXEC_PATH=")
607   contains_same_elements "$expected7" "$actual7"
608
609   cd $TRASHDIR/$reponame/a
610   envVars="$(GIT_WORK_TREE=$workTree env | grep "^GIT" | sort)"
611   expected8=$(printf '%s
612 %s
613
614 LocalWorkingDir=%s
615 LocalGitDir=%s
616 LocalGitStorageDir=%s
617 LocalMediaDir=%s
618 LocalReferenceDir=
619 TempDir=%s
620 ConcurrentTransfers=3
621 TusTransfers=false
622 BasicTransfersOnly=false
623 SkipDownloadErrors=false
624 FetchRecentAlways=false
625 FetchRecentRefsDays=7
626 FetchRecentCommitsDays=0
627 FetchRecentRefsIncludeRemotes=true
628 PruneOffsetDays=3
629 PruneVerifyRemoteAlways=false
630 PruneRemoteName=origin
631 LfsStorageDir=%s
632 AccessDownload=none
633 AccessUpload=none
634 DownloadTransfers=basic
635 UploadTransfers=basic
636 %s
637 %s
638 ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$lfsstorage" "$envVars" "$envInitConfig")
639   actual8=$(GIT_WORK_TREE=$workTree git lfs env | grep -v "^GIT_EXEC_PATH=")
640   contains_same_elements "$expected8" "$actual8"
641 )
642 end_test
643
644 begin_test "env with bare repo"
645 (
646   set -e
647   reponame="env-with-bare-repo"
648   git init --bare $reponame
649   cd $reponame
650
651   localgit=$(native_path "$TRASHDIR/$reponame")
652   localgitstore=$(native_path "$TRASHDIR/$reponame")
653   lfsstorage=$(native_path "$TRASHDIR/$reponame/lfs")
654   localmedia=$(native_path "$TRASHDIR/$reponame/lfs/objects")
655   tempdir=$(native_path "$TRASHDIR/$reponame/lfs/tmp")
656   envVars=$(printf "%s" "$(env | grep "^GIT")")
657
658   expected=$(printf "%s\n%s\n
659 LocalWorkingDir=
660 LocalGitDir=%s
661 LocalGitStorageDir=%s
662 LocalMediaDir=%s
663 LocalReferenceDir=
664 TempDir=%s
665 ConcurrentTransfers=3
666 TusTransfers=false
667 BasicTransfersOnly=false
668 SkipDownloadErrors=false
669 FetchRecentAlways=false
670 FetchRecentRefsDays=7
671 FetchRecentCommitsDays=0
672 FetchRecentRefsIncludeRemotes=true
673 PruneOffsetDays=3
674 PruneVerifyRemoteAlways=false
675 PruneRemoteName=origin
676 LfsStorageDir=%s
677 AccessDownload=none
678 AccessUpload=none
679 DownloadTransfers=basic
680 UploadTransfers=basic
681 %s
682 %s
683 " "$(git lfs version)" "$(git version)" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$lfsstorage" "$envVars" "$envInitConfig")
684   actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=")
685   contains_same_elements "$expected" "$actual"
686
687 )
688 end_test
689
690 begin_test "env with multiple ssh remotes"
691 (
692   set -e
693   reponame="env-with-ssh"
694   mkdir $reponame
695   cd $reponame
696   git init
697   git remote add origin git@git-server.com:user/repo.git
698   git remote add other git@other-git-server.com:user/repo.git
699
700   expected='Endpoint=https://git-server.com/user/repo.git/info/lfs (auth=none)
701   SSH=git@git-server.com:user/repo.git
702 Endpoint (other)=https://other-git-server.com/user/repo.git/info/lfs (auth=none)
703   SSH=git@other-git-server.com:user/repo.git
704 GIT_SSH=lfs-ssh-echo'
705
706   contains_same_elements "$expected" "$(git lfs env \
707     | grep -v "^GIT_EXEC_PATH=" | grep -e "Endpoint" -e "SSH=")"
708 )
709 end_test
710
711 begin_test "env with skip download errors"
712 (
713   set -e
714   reponame="env-with-skip-dl"
715   git init $reponame
716   cd $reponame
717
718   git config lfs.skipdownloaderrors 1
719
720   localgit=$(native_path "$TRASHDIR/$reponame")
721   localgitstore=$(native_path "$TRASHDIR/$reponame")
722   lfsstorage=$(native_path "$TRASHDIR/$reponame/lfs")
723   localmedia=$(native_path "$TRASHDIR/$reponame/lfs/objects")
724   tempdir=$(native_path "$TRASHDIR/$reponame/lfs/tmp")
725   envVars=$(printf "%s" "$(env | grep "^GIT")")
726
727   localwd=$(native_path "$TRASHDIR/$reponame")
728   localgit=$(native_path "$TRASHDIR/$reponame/.git")
729   localgitstore=$(native_path "$TRASHDIR/$reponame/.git")
730   lfsstorage=$(native_path "$TRASHDIR/$reponame/.git/lfs")
731   localmedia=$(native_path "$TRASHDIR/$reponame/.git/lfs/objects")
732   tempdir=$(native_path "$TRASHDIR/$reponame/.git/lfs/tmp")
733   envVars=$(printf "%s" "$(env | grep "^GIT")")
734
735   expectedenabled=$(printf '%s
736 %s
737
738 LocalWorkingDir=%s
739 LocalGitDir=%s
740 LocalGitStorageDir=%s
741 LocalMediaDir=%s
742 LocalReferenceDir=
743 TempDir=%s
744 ConcurrentTransfers=3
745 TusTransfers=false
746 BasicTransfersOnly=false
747 SkipDownloadErrors=true
748 FetchRecentAlways=false
749 FetchRecentRefsDays=7
750 FetchRecentCommitsDays=0
751 FetchRecentRefsIncludeRemotes=true
752 PruneOffsetDays=3
753 PruneVerifyRemoteAlways=false
754 PruneRemoteName=origin
755 LfsStorageDir=%s
756 AccessDownload=none
757 AccessUpload=none
758 DownloadTransfers=basic
759 UploadTransfers=basic
760 %s
761 %s
762 ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$lfsstorage" "$envVars" "$envInitConfig")
763   actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=")
764   contains_same_elements "$expectedenabled" "$actual"
765
766   git config --unset lfs.skipdownloaderrors
767   # prove it's usually off
768   expecteddisabled=$(printf '%s
769 %s
770
771 LocalWorkingDir=%s
772 LocalGitDir=%s
773 LocalGitStorageDir=%s
774 LocalMediaDir=%s
775 LocalReferenceDir=
776 TempDir=%s
777 ConcurrentTransfers=3
778 TusTransfers=false
779 BasicTransfersOnly=false
780 SkipDownloadErrors=true
781 FetchRecentAlways=false
782 FetchRecentRefsDays=7
783 FetchRecentCommitsDays=0
784 FetchRecentRefsIncludeRemotes=true
785 PruneOffsetDays=3
786 PruneVerifyRemoteAlways=false
787 PruneRemoteName=origin
788 LfsStorageDir=%s
789 AccessDownload=none
790 AccessUpload=none
791 DownloadTransfers=basic
792 UploadTransfers=basic
793 %s
794 %s
795 ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$lfsstorage" "$envVars" "$envInitConfig")
796   actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=")
797   contains_same_elements "$expecteddisabled" "$actual"
798
799   # now enable via env var
800   actual=$(GIT_LFS_SKIP_DOWNLOAD_ERRORS=1 git lfs env | grep -v "^GIT_EXEC_PATH=")
801   contains_same_elements "$expectedenabled" "$actual"
802
803
804
805
806 )
807 end_test
808
809 begin_test "env with extra transfer methods"
810 (
811   set -e
812   reponame="env-with-transfers"
813   git init $reponame
814   cd $reponame
815
816   git config lfs.tustransfers true
817   git config lfs.customtransfer.supertransfer.path /path/to/something
818
819   localgit=$(native_path "$TRASHDIR/$reponame")
820   localgitstore=$(native_path "$TRASHDIR/$reponame")
821   lfsstorage=$(native_path "$TRASHDIR/$reponame/lfs")
822   localmedia=$(native_path "$TRASHDIR/$reponame/lfs/objects")
823   tempdir=$(native_path "$TRASHDIR/$reponame/lfs/tmp")
824   envVars=$(printf "%s" "$(env | grep "^GIT")")
825
826   localwd=$(native_path "$TRASHDIR/$reponame")
827   localgit=$(native_path "$TRASHDIR/$reponame/.git")
828   localgitstore=$(native_path "$TRASHDIR/$reponame/.git")
829   lfsstorage=$(native_path "$TRASHDIR/$reponame/.git/lfs")
830   localmedia=$(native_path "$TRASHDIR/$reponame/.git/lfs/objects")
831   tempdir=$(native_path "$TRASHDIR/$reponame/.git/lfs/tmp")
832   envVars=$(printf "%s" "$(env | grep "^GIT")")
833
834   expectedenabled=$(printf '%s
835 %s
836
837 LocalWorkingDir=%s
838 LocalGitDir=%s
839 LocalGitStorageDir=%s
840 LocalMediaDir=%s
841 LocalReferenceDir=
842 TempDir=%s
843 ConcurrentTransfers=3
844 TusTransfers=true
845 BasicTransfersOnly=false
846 SkipDownloadErrors=false
847 FetchRecentAlways=false
848 FetchRecentRefsDays=7
849 FetchRecentCommitsDays=0
850 FetchRecentRefsIncludeRemotes=true
851 PruneOffsetDays=3
852 PruneVerifyRemoteAlways=false
853 PruneRemoteName=origin
854 LfsStorageDir=%s
855 AccessDownload=none
856 AccessUpload=none
857 DownloadTransfers=basic,supertransfer
858 UploadTransfers=basic,supertransfer,tus
859 %s
860 %s
861 ' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$lfsstorage" "$envVars" "$envInitConfig")
862   actual=$(git lfs env | grep -v "^GIT_EXEC_PATH=")
863   contains_same_elements "$expectedenabled" "$actual"
864
865 )
866 end_test