tests: cosmetic improvements to the repo-setup test
[git/mingw.git] / t / t1510-repo-setup.sh
blobf42f206547469c28de4fc9bb7ea70cf67655f4d6
1 #!/bin/sh
3 test_description="Tests of cwd/prefix/worktree/gitdir setup in all cases
5 A few rules for repo setup:
7 1. GIT_DIR is relative to user's cwd. --git-dir is equivalent to
8 GIT_DIR.
10 2. .git file is relative to parent directory. .git file is basically
11 symlink in disguise. The directory where .git file points to will
12 become new git_dir.
14 3. core.worktree is relative to git_dir.
16 4. GIT_WORK_TREE is relative to user's cwd. --work-tree is
17 equivalent to GIT_WORK_TREE.
19 5. GIT_WORK_TREE/core.worktree is only effective if GIT_DIR is set
20 Uneffective worktree settings should be warned.
22 6. Effective GIT_WORK_TREE overrides core.worktree and core.bare
24 7. Effective core.worktree conflicts with core.bare
26 8. If GIT_DIR is set but neither worktree nor bare setting is given,
27 original cwd becomes worktree.
29 9. If .git discovery is done inside a repo, the repo becomes a bare
30 repo. .git discovery is performed if GIT_DIR is not set.
32 10. If no worktree is available, cwd remains unchanged, prefix is
33 NULL.
35 11. When user's cwd is outside worktree, cwd remains unchanged,
36 prefix is NULL.
38 . ./test-lib.sh
40 test_repo () {
42 cd "$1" &&
43 if test -n "$2"
44 then
45 GIT_DIR="$2" &&
46 export GIT_DIR
47 fi &&
48 if test -n "$3"
49 then
50 GIT_WORK_TREE="$3" &&
51 export GIT_WORK_TREE
52 fi &&
53 rm -f trace &&
54 GIT_TRACE="$(pwd)/trace" git symbolic-ref HEAD >/dev/null &&
55 grep '^setup: ' trace >result &&
56 test_cmp expected result
60 # Bit 0 = GIT_WORK_TREE
61 # Bit 1 = GIT_DIR
62 # Bit 2 = core.worktree
63 # Bit 3 = .git is a file
64 # Bit 4 = bare repo
65 # Case# = encoding of the above 5 bits
68 # Case #0
70 ############################################################
72 # Input:
74 # - GIT_WORK_TREE is not set
75 # - GIT_DIR is not set
76 # - core.worktree is not set
77 # - .git is a directory
78 # - core.bare is not set, cwd is outside .git
80 # Output:
82 # - worktree is .git's parent directory
83 # - cwd is at worktree root dir
84 # - prefix is calculated
85 # - git_dir is set to ".git"
86 # - cwd can't be outside worktree
88 test_expect_success '#0: setup' '
89 sane_unset GIT_DIR GIT_WORK_TREE &&
90 mkdir 0 0/sub &&
91 (cd 0 && git init) &&
92 here=$(pwd)
95 test_expect_success '#0: at root' '
96 cat >0/expected <<EOF &&
97 setup: git_dir: .git
98 setup: worktree: $here/0
99 setup: cwd: $here/0
100 setup: prefix: (null)
102 test_repo 0
105 test_expect_success '#0: in subdir' '
106 cat >0/sub/expected <<EOF &&
107 setup: git_dir: .git
108 setup: worktree: $here/0
109 setup: cwd: $here/0
110 setup: prefix: sub/
112 test_repo 0/sub
116 # case #1
118 ############################################################
120 # Input:
122 # - GIT_WORK_TREE is set
123 # - GIT_DIR is not set
124 # - core.worktree is not set
125 # - .git is a directory
126 # - core.bare is not set, cwd is outside .git
128 # Output:
130 # GIT_WORK_TREE is ignored -> #0
132 test_expect_success '#1: setup' '
133 sane_unset GIT_DIR GIT_WORK_TREE &&
134 mkdir 1 1/sub 1.wt 1.wt/sub 1/wt 1/wt/sub &&
135 cd 1 &&
136 git init &&
137 GIT_WORK_TREE=non-existent &&
138 export GIT_WORK_TREE &&
139 cd ..
142 test_expect_success '#1: at root' '
143 cat >1/expected <<EOF &&
144 setup: git_dir: .git
145 setup: worktree: $here/1
146 setup: cwd: $here/1
147 setup: prefix: (null)
149 test_repo 1
152 test_expect_success '#1: in subdir' '
153 cat >1/sub/expected <<EOF &&
154 setup: git_dir: .git
155 setup: worktree: $here/1
156 setup: cwd: $here/1
157 setup: prefix: sub/
159 test_repo 1/sub
163 # case #2
165 ############################################################
167 # Input:
169 # - GIT_WORK_TREE is not set
170 # - GIT_DIR is set
171 # - core.worktree is not set
172 # - .git is a directory
173 # - core.bare is not set, cwd is outside .git
175 # Output:
177 # - worktree is at original cwd
178 # - cwd is unchanged
179 # - prefix is NULL
180 # - git_dir is set to $GIT_DIR
181 # - cwd can't be outside worktree
183 test_expect_success '#2: setup' '
184 sane_unset GIT_DIR GIT_WORK_TREE &&
185 mkdir 2 2/sub &&
186 cd 2 && git init && cd ..
189 test_expect_success '#2: at root' '
190 cat >2/expected <<EOF &&
191 setup: git_dir: $here/2/.git
192 setup: worktree: $here/2
193 setup: cwd: $here/2
194 setup: prefix: (null)
196 test_repo 2 "$here/2/.git"
199 test_expect_success '#2: in subdir' '
200 cat >2/sub/expected <<EOF &&
201 setup: git_dir: $here/2/.git
202 setup: worktree: $here/2/sub
203 setup: cwd: $here/2/sub
204 setup: prefix: (null)
206 test_repo 2/sub "$here/2/.git"
209 test_expect_success '#2: relative GIT_DIR at root' '
210 cat >2/expected <<EOF &&
211 setup: git_dir: .git
212 setup: worktree: $here/2
213 setup: cwd: $here/2
214 setup: prefix: (null)
216 test_repo 2 .git
219 test_expect_success '#2: relative GIT_DIR in subdir' '
220 cat >2/sub/expected <<EOF &&
221 setup: git_dir: ../.git
222 setup: worktree: $here/2/sub
223 setup: cwd: $here/2/sub
224 setup: prefix: (null)
226 test_repo 2/sub ../.git
230 # case #3
232 ############################################################
234 # Input:
236 # - GIT_WORK_TREE is set
237 # - GIT_DIR is set
238 # - core.worktree is not set
239 # - .git is a directory
240 # - core.bare is not set, cwd is outside .git
242 # Output:
244 # - worktree is set to $GIT_WORK_TREE
245 # - cwd is at worktree root
246 # - prefix is calculated
247 # - git_dir is set to $GIT_DIR
248 # - cwd can be outside worktree
250 test_expect_success '#3: setup' '
251 sane_unset GIT_DIR GIT_WORK_TREE &&
252 mkdir 3 3/sub 3/sub/sub 3.wt 3.wt/sub 3/wt 3/wt/sub &&
253 cd 3 && git init && cd ..
256 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
257 cat >3/expected <<EOF &&
258 setup: git_dir: .git
259 setup: worktree: $here/3
260 setup: cwd: $here/3
261 setup: prefix: (null)
263 test_repo 3 .git "$here/3"
266 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
267 cat >3/expected <<EOF &&
268 setup: git_dir: .git
269 setup: worktree: $here/3
270 setup: cwd: $here/3
271 setup: prefix: (null)
273 test_repo 3 .git .
276 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=root at root' '
277 cat >3/expected <<EOF &&
278 setup: git_dir: $here/3/.git
279 setup: worktree: $here/3
280 setup: cwd: $here/3
281 setup: prefix: (null)
283 test_repo 3 "$here/3/.git" "$here/3"
286 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
287 cat >3/expected <<EOF &&
288 setup: git_dir: $here/3/.git
289 setup: worktree: $here/3
290 setup: cwd: $here/3
291 setup: prefix: (null)
293 test_repo 3 "$here/3/.git" .
296 test_expect_success '#3: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
297 cat >3/sub/sub/expected <<EOF &&
298 setup: git_dir: $here/3/.git
299 setup: worktree: $here/3
300 setup: cwd: $here/3
301 setup: prefix: sub/sub/
303 test_repo 3/sub/sub ../../.git "$here/3"
306 test_expect_success '#3: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
307 cat >3/sub/sub/expected <<EOF &&
308 setup: git_dir: $here/3/.git
309 setup: worktree: $here/3
310 setup: cwd: $here/3
311 setup: prefix: sub/sub/
313 test_repo 3/sub/sub ../../.git ../..
316 test_expect_success '#3: GIT_DIR, GIT_WORKTREE=root in subdir' '
317 cat >3/sub/expected <<EOF &&
318 setup: git_dir: $here/3/.git
319 setup: worktree: $here/3
320 setup: cwd: $here/3
321 setup: prefix: sub/
323 test_repo 3/sub "$here/3/.git" "$here/3"
326 test_expect_success '#3: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
327 cat >3/sub/sub/expected <<EOF &&
328 setup: git_dir: $here/3/.git
329 setup: worktree: $here/3
330 setup: cwd: $here/3
331 setup: prefix: sub/sub/
333 test_repo 3/sub/sub "$here/3/.git" ../..
336 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
337 cat >3/expected <<EOF &&
338 setup: git_dir: .git
339 setup: worktree: $here/3/wt
340 setup: cwd: $here/3
341 setup: prefix: (null)
343 test_repo 3 .git "$here/3/wt"
346 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
347 cat >3/expected <<EOF &&
348 setup: git_dir: .git
349 setup: worktree: $here/3/wt
350 setup: cwd: $here/3
351 setup: prefix: (null)
353 test_repo 3 .git wt
356 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
357 cat >3/expected <<EOF &&
358 setup: git_dir: $here/3/.git
359 setup: worktree: $here/3/wt
360 setup: cwd: $here/3
361 setup: prefix: (null)
363 test_repo 3 "$here/3/.git" wt
366 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=wt at root' '
367 cat >3/expected <<EOF &&
368 setup: git_dir: $here/3/.git
369 setup: worktree: $here/3/wt
370 setup: cwd: $here/3
371 setup: prefix: (null)
373 test_repo 3 "$here/3/.git" "$here/3/wt"
376 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
377 cat >3/sub/sub/expected <<EOF &&
378 setup: git_dir: ../../.git
379 setup: worktree: $here/3/wt
380 setup: cwd: $here/3/sub/sub
381 setup: prefix: (null)
383 test_repo 3/sub/sub ../../.git "$here/3/wt"
386 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
387 cat >3/sub/sub/expected <<EOF &&
388 setup: git_dir: ../../.git
389 setup: worktree: $here/3/wt
390 setup: cwd: $here/3/sub/sub
391 setup: prefix: (null)
393 test_repo 3/sub/sub ../../.git ../../wt
396 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
397 cat >3/sub/sub/expected <<EOF &&
398 setup: git_dir: $here/3/.git
399 setup: worktree: $here/3/wt
400 setup: cwd: $here/3/sub/sub
401 setup: prefix: (null)
403 test_repo 3/sub/sub "$here/3/.git" ../../wt
406 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
407 cat >3/sub/sub/expected <<EOF &&
408 setup: git_dir: $here/3/.git
409 setup: worktree: $here/3/wt
410 setup: cwd: $here/3/sub/sub
411 setup: prefix: (null)
413 test_repo 3/sub/sub "$here/3/.git" "$here/3/wt"
416 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
417 cat >3/expected <<EOF &&
418 setup: git_dir: $here/3/.git
419 setup: worktree: $here
420 setup: cwd: $here
421 setup: prefix: 3/
423 test_repo 3 .git "$here"
426 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
427 cat >3/expected <<EOF &&
428 setup: git_dir: $here/3/.git
429 setup: worktree: $here
430 setup: cwd: $here
431 setup: prefix: 3/
433 test_repo 3 .git ..
436 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
437 cat >3/expected <<EOF &&
438 setup: git_dir: $here/3/.git
439 setup: worktree: $here
440 setup: cwd: $here
441 setup: prefix: 3/
443 test_repo 3 "$here/3/.git" ..
446 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=.. at root' '
447 cat >3/expected <<EOF &&
448 setup: git_dir: $here/3/.git
449 setup: worktree: $here
450 setup: cwd: $here
451 setup: prefix: 3/
453 test_repo 3 "$here/3/.git" "$here"
456 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
457 cat >3/sub/sub/expected <<EOF &&
458 setup: git_dir: $here/3/.git
459 setup: worktree: $here
460 setup: cwd: $here
461 setup: prefix: 3/sub/sub/
463 test_repo 3/sub/sub ../../.git "$here"
466 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
467 cat >3/sub/sub/expected <<EOF &&
468 setup: git_dir: $here/3/.git
469 setup: worktree: $here
470 setup: cwd: $here
471 setup: prefix: 3/sub/sub/
473 test_repo 3/sub/sub ../../.git ../../..
476 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
477 cat >3/sub/sub/expected <<EOF &&
478 setup: git_dir: $here/3/.git
479 setup: worktree: $here
480 setup: cwd: $here
481 setup: prefix: 3/sub/sub/
483 test_repo 3/sub/sub "$here/3/.git" ../../../
486 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
487 cat >3/sub/sub/expected <<EOF &&
488 setup: git_dir: $here/3/.git
489 setup: worktree: $here
490 setup: cwd: $here
491 setup: prefix: 3/sub/sub/
493 test_repo 3/sub/sub "$here/3/.git" "$here"
497 # case #4
499 ############################################################
501 # Input:
503 # - GIT_WORK_TREE is not set
504 # - GIT_DIR is not set
505 # - core.worktree is set
506 # - .git is a directory
507 # - core.bare is not set, cwd is outside .git
509 # Output:
511 # core.worktree is ignored -> #0
513 test_expect_success '#4: setup' '
514 sane_unset GIT_DIR GIT_WORK_TREE &&
515 mkdir 4 4/sub &&
516 cd 4 &&
517 git init &&
518 git config core.worktree non-existent &&
519 cd ..
522 test_expect_success '#4: at root' '
523 cat >4/expected <<EOF &&
524 setup: git_dir: .git
525 setup: worktree: $here/4
526 setup: cwd: $here/4
527 setup: prefix: (null)
529 test_repo 4
532 test_expect_success '#4: in subdir' '
533 cat >4/sub/expected <<EOF &&
534 setup: git_dir: .git
535 setup: worktree: $here/4
536 setup: cwd: $here/4
537 setup: prefix: sub/
539 test_repo 4/sub
543 # case #5
545 ############################################################
547 # Input:
549 # - GIT_WORK_TREE is set
550 # - GIT_DIR is not set
551 # - core.worktree is set
552 # - .git is a directory
553 # - core.bare is not set, cwd is outside .git
555 # Output:
557 # GIT_WORK_TREE/core.worktree are ignored -> #0
559 test_expect_success '#5: setup' '
560 sane_unset GIT_DIR GIT_WORK_TREE &&
561 mkdir 5 5/sub &&
562 cd 5 &&
563 git init &&
564 git config core.worktree non-existent &&
565 GIT_WORK_TREE=non-existent-too &&
566 export GIT_WORK_TREE &&
567 cd ..
570 test_expect_success '#5: at root' '
571 cat >5/expected <<EOF &&
572 setup: git_dir: .git
573 setup: worktree: $here/5
574 setup: cwd: $here/5
575 setup: prefix: (null)
577 test_repo 5
580 test_expect_success '#5: in subdir' '
581 cat >5/sub/expected <<EOF &&
582 setup: git_dir: .git
583 setup: worktree: $here/5
584 setup: cwd: $here/5
585 setup: prefix: sub/
587 test_repo 5/sub
591 # case #6
593 ############################################################
595 # Input:
597 # - GIT_WORK_TREE is not set
598 # - GIT_DIR is set
599 # - core.worktree is set
600 # - .git is a directory
601 # - core.bare is not set, cwd is outside .git
603 # Output:
605 # - worktree is at core.worktree
606 # - cwd is at worktree root
607 # - prefix is calculated
608 # - git_dir is at $GIT_DIR
609 # - cwd can be outside worktree
611 test_expect_success '#6: setup' '
612 sane_unset GIT_DIR GIT_WORK_TREE &&
613 mkdir 6 6/sub 6/sub/sub 6.wt 6.wt/sub 6/wt 6/wt/sub &&
614 cd 6 && git init && cd ..
617 test_expect_success '#6: GIT_DIR(rel), core.worktree=.. at root' '
618 cat >6/expected <<EOF &&
619 setup: git_dir: .git
620 setup: worktree: $here/6
621 setup: cwd: $here/6
622 setup: prefix: (null)
624 git config --file="$here/6/.git/config" core.worktree "$here/6" &&
625 test_repo 6 .git
628 test_expect_success '#6: GIT_DIR(rel), core.worktree=..(rel) at root' '
629 cat >6/expected <<EOF &&
630 setup: git_dir: .git
631 setup: worktree: $here/6
632 setup: cwd: $here/6
633 setup: prefix: (null)
635 git config --file="$here/6/.git/config" core.worktree .. &&
636 test_repo 6 .git
639 test_expect_success '#6: GIT_DIR, core.worktree=.. at root' '
640 cat >6/expected <<EOF &&
641 setup: git_dir: $here/6/.git
642 setup: worktree: $here/6
643 setup: cwd: $here/6
644 setup: prefix: (null)
646 git config --file="$here/6/.git/config" core.worktree "$here/6" &&
647 test_repo 6 "$here/6/.git"
650 test_expect_success '#6: GIT_DIR, core.worktree=..(rel) at root' '
651 cat >6/expected <<EOF &&
652 setup: git_dir: $here/6/.git
653 setup: worktree: $here/6
654 setup: cwd: $here/6
655 setup: prefix: (null)
657 git config --file="$here/6/.git/config" core.worktree .. &&
658 test_repo 6 "$here/6/.git"
661 test_expect_success '#6: GIT_DIR(rel), core.worktree=.. in subdir' '
662 cat >6/sub/sub/expected <<EOF &&
663 setup: git_dir: $here/6/.git
664 setup: worktree: $here/6
665 setup: cwd: $here/6
666 setup: prefix: sub/sub/
668 git config --file="$here/6/.git/config" core.worktree "$here/6" &&
669 test_repo 6/sub/sub ../../.git
672 test_expect_success '#6: GIT_DIR(rel), core.worktree=..(rel) in subdir' '
673 cat >6/sub/sub/expected <<EOF &&
674 setup: git_dir: $here/6/.git
675 setup: worktree: $here/6
676 setup: cwd: $here/6
677 setup: prefix: sub/sub/
679 git config --file="$here/6/.git/config" core.worktree .. &&
680 test_repo 6/sub/sub ../../.git
683 test_expect_success '#6: GIT_DIR, core.worktree=.. in subdir' '
684 cat >6/sub/expected <<EOF &&
685 setup: git_dir: $here/6/.git
686 setup: worktree: $here/6
687 setup: cwd: $here/6
688 setup: prefix: sub/
690 git config --file="$here/6/.git/config" core.worktree "$here/6" &&
691 test_repo 6/sub "$here/6/.git"
694 test_expect_success '#6: GIT_DIR, core.worktree=..(rel) in subdir' '
695 cat >6/sub/sub/expected <<EOF &&
696 setup: git_dir: $here/6/.git
697 setup: worktree: $here/6
698 setup: cwd: $here/6
699 setup: prefix: sub/sub/
701 git config --file="$here/6/.git/config" core.worktree .. &&
702 test_repo 6/sub/sub "$here/6/.git"
705 test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt at root' '
706 cat >6/expected <<EOF &&
707 setup: git_dir: .git
708 setup: worktree: $here/6/wt
709 setup: cwd: $here/6
710 setup: prefix: (null)
712 git config --file="$here/6/.git/config" core.worktree "$here/6/wt" &&
713 test_repo 6 .git
716 test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt(rel) at root' '
717 cat >6/expected <<EOF &&
718 setup: git_dir: .git
719 setup: worktree: $here/6/wt
720 setup: cwd: $here/6
721 setup: prefix: (null)
723 git config --file="$here/6/.git/config" core.worktree ../wt &&
724 test_repo 6 .git
727 test_expect_success '#6: GIT_DIR, core.worktree=../wt(rel) at root' '
728 cat >6/expected <<EOF &&
729 setup: git_dir: $here/6/.git
730 setup: worktree: $here/6/wt
731 setup: cwd: $here/6
732 setup: prefix: (null)
734 git config --file="$here/6/.git/config" core.worktree ../wt &&
735 test_repo 6 "$here/6/.git"
738 test_expect_success '#6: GIT_DIR, core.worktree=../wt at root' '
739 cat >6/expected <<EOF &&
740 setup: git_dir: $here/6/.git
741 setup: worktree: $here/6/wt
742 setup: cwd: $here/6
743 setup: prefix: (null)
745 git config --file="$here/6/.git/config" core.worktree "$here/6/wt" &&
746 test_repo 6 "$here/6/.git"
749 test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt in subdir' '
750 cat >6/sub/sub/expected <<EOF &&
751 setup: git_dir: ../../.git
752 setup: worktree: $here/6/wt
753 setup: cwd: $here/6/sub/sub
754 setup: prefix: (null)
756 git config --file="$here/6/.git/config" core.worktree "$here/6/wt" &&
757 test_repo 6/sub/sub ../../.git
760 test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt(rel) in subdir' '
761 cat >6/sub/sub/expected <<EOF &&
762 setup: git_dir: ../../.git
763 setup: worktree: $here/6/wt
764 setup: cwd: $here/6/sub/sub
765 setup: prefix: (null)
767 git config --file="$here/6/.git/config" core.worktree ../wt &&
768 test_repo 6/sub/sub ../../.git
771 test_expect_success '#6: GIT_DIR, core.worktree=../wt(rel) in subdir' '
772 cat >6/sub/sub/expected <<EOF &&
773 setup: git_dir: $here/6/.git
774 setup: worktree: $here/6/wt
775 setup: cwd: $here/6/sub/sub
776 setup: prefix: (null)
778 git config --file="$here/6/.git/config" core.worktree ../wt &&
779 test_repo 6/sub/sub "$here/6/.git"
782 test_expect_success '#6: GIT_DIR, core.worktree=../wt in subdir' '
783 cat >6/sub/sub/expected <<EOF &&
784 setup: git_dir: $here/6/.git
785 setup: worktree: $here/6/wt
786 setup: cwd: $here/6/sub/sub
787 setup: prefix: (null)
789 git config --file="$here/6/.git/config" core.worktree "$here/6/wt" &&
790 test_repo 6/sub/sub "$here/6/.git"
793 test_expect_success '#6: GIT_DIR(rel), core.worktree=../.. at root' '
794 cat >6/expected <<EOF &&
795 setup: git_dir: $here/6/.git
796 setup: worktree: $here
797 setup: cwd: $here
798 setup: prefix: 6/
800 git config --file="$here/6/.git/config" core.worktree "$here" &&
801 test_repo 6 .git
804 test_expect_success '#6: GIT_DIR(rel), core.worktree=../..(rel) at root' '
805 cat >6/expected <<EOF &&
806 setup: git_dir: $here/6/.git
807 setup: worktree: $here
808 setup: cwd: $here
809 setup: prefix: 6/
811 git config --file="$here/6/.git/config" core.worktree ../../ &&
812 test_repo 6 .git
815 test_expect_success '#6: GIT_DIR, core.worktree=../..(rel) at root' '
816 cat >6/expected <<EOF &&
817 setup: git_dir: $here/6/.git
818 setup: worktree: $here
819 setup: cwd: $here
820 setup: prefix: 6/
822 git config --file="$here/6/.git/config" core.worktree ../../ &&
823 test_repo 6 "$here/6/.git"
826 test_expect_success '#6: GIT_DIR, core.worktree=../.. at root' '
827 cat >6/expected <<EOF &&
828 setup: git_dir: $here/6/.git
829 setup: worktree: $here
830 setup: cwd: $here
831 setup: prefix: 6/
833 git config --file="$here/6/.git/config" core.worktree "$here" &&
834 test_repo 6 "$here/6/.git"
837 test_expect_success '#6: GIT_DIR(rel), core.worktree=../.. in subdir' '
838 cat >6/sub/sub/expected <<EOF &&
839 setup: git_dir: $here/6/.git
840 setup: worktree: $here
841 setup: cwd: $here
842 setup: prefix: 6/sub/sub/
844 git config --file="$here/6/.git/config" core.worktree "$here" &&
845 test_repo 6/sub/sub ../../.git
848 test_expect_success '#6: GIT_DIR(rel), core.worktree=../..(rel) in subdir' '
849 cat >6/sub/sub/expected <<EOF &&
850 setup: git_dir: $here/6/.git
851 setup: worktree: $here
852 setup: cwd: $here
853 setup: prefix: 6/sub/sub/
855 git config --file="$here/6/.git/config" core.worktree ../.. &&
856 test_repo 6/sub/sub ../../.git
859 test_expect_success '#6: GIT_DIR, core.worktree=../..(rel) in subdir' '
860 cat >6/sub/sub/expected <<EOF &&
861 setup: git_dir: $here/6/.git
862 setup: worktree: $here
863 setup: cwd: $here
864 setup: prefix: 6/sub/sub/
866 git config --file="$here/6/.git/config" core.worktree ../.. &&
867 test_repo 6/sub/sub "$here/6/.git"
870 test_expect_success '#6: GIT_DIR, core.worktree=../.. in subdir' '
871 cat >6/sub/sub/expected <<EOF &&
872 setup: git_dir: $here/6/.git
873 setup: worktree: $here
874 setup: cwd: $here
875 setup: prefix: 6/sub/sub/
877 git config --file="$here/6/.git/config" core.worktree "$here" &&
878 test_repo 6/sub/sub "$here/6/.git"
882 # case #7
884 ############################################################
886 # Input:
888 # - GIT_WORK_TREE is set
889 # - GIT_DIR is set
890 # - core.worktree is set
891 # - .git is a directory
892 # - core.bare is not set, cwd is outside .git
894 # Output:
896 # core.worktree is overridden by GIT_WORK_TREE -> #3
898 test_expect_success '#7: setup' '
899 sane_unset GIT_DIR GIT_WORK_TREE &&
900 mkdir 7 7/sub 7/sub/sub 7.wt 7.wt/sub 7/wt 7/wt/sub &&
901 cd 7 &&
902 git init &&
903 git config core.worktree non-existent &&
904 cd ..
907 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
908 cat >7/expected <<EOF &&
909 setup: git_dir: .git
910 setup: worktree: $here/7
911 setup: cwd: $here/7
912 setup: prefix: (null)
914 test_repo 7 .git "$here/7"
917 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
918 cat >7/expected <<EOF &&
919 setup: git_dir: .git
920 setup: worktree: $here/7
921 setup: cwd: $here/7
922 setup: prefix: (null)
924 test_repo 7 .git .
927 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=root at root' '
928 cat >7/expected <<EOF &&
929 setup: git_dir: $here/7/.git
930 setup: worktree: $here/7
931 setup: cwd: $here/7
932 setup: prefix: (null)
934 test_repo 7 "$here/7/.git" "$here/7"
937 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
938 cat >7/expected <<EOF &&
939 setup: git_dir: $here/7/.git
940 setup: worktree: $here/7
941 setup: cwd: $here/7
942 setup: prefix: (null)
944 test_repo 7 "$here/7/.git" .
947 test_expect_success '#7: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
948 cat >7/sub/sub/expected <<EOF &&
949 setup: git_dir: $here/7/.git
950 setup: worktree: $here/7
951 setup: cwd: $here/7
952 setup: prefix: sub/sub/
954 test_repo 7/sub/sub ../../.git "$here/7"
957 test_expect_success '#7: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
958 cat >7/sub/sub/expected <<EOF &&
959 setup: git_dir: $here/7/.git
960 setup: worktree: $here/7
961 setup: cwd: $here/7
962 setup: prefix: sub/sub/
964 test_repo 7/sub/sub ../../.git ../..
967 test_expect_success '#7: GIT_DIR, GIT_WORKTREE=root in subdir' '
968 cat >7/sub/expected <<EOF &&
969 setup: git_dir: $here/7/.git
970 setup: worktree: $here/7
971 setup: cwd: $here/7
972 setup: prefix: sub/
974 test_repo 7/sub "$here/7/.git" "$here/7"
977 test_expect_success '#7: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
978 cat >7/sub/sub/expected <<EOF &&
979 setup: git_dir: $here/7/.git
980 setup: worktree: $here/7
981 setup: cwd: $here/7
982 setup: prefix: sub/sub/
984 test_repo 7/sub/sub "$here/7/.git" ../..
987 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
988 cat >7/expected <<EOF &&
989 setup: git_dir: .git
990 setup: worktree: $here/7/wt
991 setup: cwd: $here/7
992 setup: prefix: (null)
994 test_repo 7 .git "$here/7/wt"
997 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
998 cat >7/expected <<EOF &&
999 setup: git_dir: .git
1000 setup: worktree: $here/7/wt
1001 setup: cwd: $here/7
1002 setup: prefix: (null)
1004 test_repo 7 .git wt
1007 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
1008 cat >7/expected <<EOF &&
1009 setup: git_dir: $here/7/.git
1010 setup: worktree: $here/7/wt
1011 setup: cwd: $here/7
1012 setup: prefix: (null)
1014 test_repo 7 "$here/7/.git" wt
1017 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=wt at root' '
1018 cat >7/expected <<EOF &&
1019 setup: git_dir: $here/7/.git
1020 setup: worktree: $here/7/wt
1021 setup: cwd: $here/7
1022 setup: prefix: (null)
1024 test_repo 7 "$here/7/.git" "$here/7/wt"
1027 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
1028 cat >7/sub/sub/expected <<EOF &&
1029 setup: git_dir: ../../.git
1030 setup: worktree: $here/7/wt
1031 setup: cwd: $here/7/sub/sub
1032 setup: prefix: (null)
1034 test_repo 7/sub/sub ../../.git "$here/7/wt"
1037 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
1038 cat >7/sub/sub/expected <<EOF &&
1039 setup: git_dir: ../../.git
1040 setup: worktree: $here/7/wt
1041 setup: cwd: $here/7/sub/sub
1042 setup: prefix: (null)
1044 test_repo 7/sub/sub ../../.git ../../wt
1047 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
1048 cat >7/sub/sub/expected <<EOF &&
1049 setup: git_dir: $here/7/.git
1050 setup: worktree: $here/7/wt
1051 setup: cwd: $here/7/sub/sub
1052 setup: prefix: (null)
1054 test_repo 7/sub/sub "$here/7/.git" ../../wt
1057 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
1058 cat >7/sub/sub/expected <<EOF &&
1059 setup: git_dir: $here/7/.git
1060 setup: worktree: $here/7/wt
1061 setup: cwd: $here/7/sub/sub
1062 setup: prefix: (null)
1064 test_repo 7/sub/sub "$here/7/.git" "$here/7/wt"
1067 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
1068 cat >7/expected <<EOF &&
1069 setup: git_dir: $here/7/.git
1070 setup: worktree: $here
1071 setup: cwd: $here
1072 setup: prefix: 7/
1074 test_repo 7 .git "$here"
1077 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
1078 cat >7/expected <<EOF &&
1079 setup: git_dir: $here/7/.git
1080 setup: worktree: $here
1081 setup: cwd: $here
1082 setup: prefix: 7/
1084 test_repo 7 .git ..
1087 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
1088 cat >7/expected <<EOF &&
1089 setup: git_dir: $here/7/.git
1090 setup: worktree: $here
1091 setup: cwd: $here
1092 setup: prefix: 7/
1094 test_repo 7 "$here/7/.git" ..
1097 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=.. at root' '
1098 cat >7/expected <<EOF &&
1099 setup: git_dir: $here/7/.git
1100 setup: worktree: $here
1101 setup: cwd: $here
1102 setup: prefix: 7/
1104 test_repo 7 "$here/7/.git" "$here"
1107 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
1108 cat >7/sub/sub/expected <<EOF &&
1109 setup: git_dir: $here/7/.git
1110 setup: worktree: $here
1111 setup: cwd: $here
1112 setup: prefix: 7/sub/sub/
1114 test_repo 7/sub/sub ../../.git "$here"
1117 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
1118 cat >7/sub/sub/expected <<EOF &&
1119 setup: git_dir: $here/7/.git
1120 setup: worktree: $here
1121 setup: cwd: $here
1122 setup: prefix: 7/sub/sub/
1124 test_repo 7/sub/sub ../../.git ../../..
1127 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
1128 cat >7/sub/sub/expected <<EOF &&
1129 setup: git_dir: $here/7/.git
1130 setup: worktree: $here
1131 setup: cwd: $here
1132 setup: prefix: 7/sub/sub/
1134 test_repo 7/sub/sub "$here/7/.git" ../../../
1137 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
1138 cat >7/sub/sub/expected <<EOF &&
1139 setup: git_dir: $here/7/.git
1140 setup: worktree: $here
1141 setup: cwd: $here
1142 setup: prefix: 7/sub/sub/
1144 test_repo 7/sub/sub "$here/7/.git" "$here"
1148 # case #8
1150 ############################################################
1152 # Input:
1154 # - GIT_WORK_TREE is not set
1155 # - GIT_DIR is not set
1156 # - core.worktree is not set
1157 # - .git is a file
1158 # - core.bare is not set, cwd is outside .git
1160 # Output:
1162 # #0 except that git_dir is set by .git file
1164 test_expect_success '#8: setup' '
1165 sane_unset GIT_DIR GIT_WORK_TREE &&
1166 mkdir 8 8/sub &&
1167 cd 8 &&
1168 git init &&
1169 mv .git ../8.git &&
1170 echo gitdir: ../8.git >.git &&
1171 cd ..
1174 test_expect_success '#8: at root' '
1175 cat >8/expected <<EOF &&
1176 setup: git_dir: $here/8.git
1177 setup: worktree: $here/8
1178 setup: cwd: $here/8
1179 setup: prefix: (null)
1181 test_repo 8
1184 test_expect_success '#8: in subdir' '
1185 cat >8/sub/expected <<EOF &&
1186 setup: git_dir: $here/8.git
1187 setup: worktree: $here/8
1188 setup: cwd: $here/8
1189 setup: prefix: sub/
1191 test_repo 8/sub
1195 # case #9
1197 ############################################################
1199 # Input:
1201 # - GIT_WORK_TREE is set
1202 # - GIT_DIR is not set
1203 # - core.worktree is not set
1204 # - .git is a file
1205 # - core.bare is not set, cwd is outside .git
1207 # Output:
1209 # #1 except that git_dir is set by .git file
1211 test_expect_success '#9: setup' '
1212 sane_unset GIT_DIR GIT_WORK_TREE &&
1213 mkdir 9 9/sub 9.wt 9.wt/sub 9/wt 9/wt/sub &&
1214 cd 9 &&
1215 git init &&
1216 mv .git ../9.git &&
1217 echo gitdir: ../9.git >.git &&
1218 GIT_WORK_TREE=non-existent &&
1219 export GIT_WORK_TREE &&
1220 cd ..
1223 test_expect_success '#9: at root' '
1224 cat >9/expected <<EOF &&
1225 setup: git_dir: $here/9.git
1226 setup: worktree: $here/9
1227 setup: cwd: $here/9
1228 setup: prefix: (null)
1230 test_repo 9
1233 test_expect_success '#9: in subdir' '
1234 cat >9/sub/expected <<EOF &&
1235 setup: git_dir: $here/9.git
1236 setup: worktree: $here/9
1237 setup: cwd: $here/9
1238 setup: prefix: sub/
1240 test_repo 9/sub
1244 # case #10
1246 ############################################################
1248 # Input:
1250 # - GIT_WORK_TREE is not set
1251 # - GIT_DIR is set
1252 # - core.worktree is not set
1253 # - .git is a file
1254 # - core.bare is not set, cwd is outside .git
1256 # Output:
1258 # #2 except that git_dir is set by .git file
1260 test_expect_success '#10: setup' '
1261 sane_unset GIT_DIR GIT_WORK_TREE &&
1262 mkdir 10 10/sub &&
1263 cd 10 &&
1264 git init &&
1265 mv .git ../10.git &&
1266 echo gitdir: ../10.git >.git &&
1267 cd ..
1270 test_expect_success '#10: at root' '
1271 cat >10/expected <<EOF &&
1272 setup: git_dir: $here/10.git
1273 setup: worktree: $here/10
1274 setup: cwd: $here/10
1275 setup: prefix: (null)
1277 test_repo 10 "$here/10/.git"
1280 test_expect_success '#10: in subdir' '
1281 cat >10/sub/expected <<EOF &&
1282 setup: git_dir: $here/10.git
1283 setup: worktree: $here/10/sub
1284 setup: cwd: $here/10/sub
1285 setup: prefix: (null)
1287 test_repo 10/sub "$here/10/.git"
1290 test_expect_success '#10: relative GIT_DIR at root' '
1291 cat >10/expected <<EOF &&
1292 setup: git_dir: $here/10.git
1293 setup: worktree: $here/10
1294 setup: cwd: $here/10
1295 setup: prefix: (null)
1297 test_repo 10 .git
1300 test_expect_success '#10: relative GIT_DIR in subdir' '
1301 cat >10/sub/expected <<EOF &&
1302 setup: git_dir: $here/10.git
1303 setup: worktree: $here/10/sub
1304 setup: cwd: $here/10/sub
1305 setup: prefix: (null)
1307 test_repo 10/sub ../.git
1311 # case #11
1313 ############################################################
1315 # Input:
1317 # - GIT_WORK_TREE is set
1318 # - GIT_DIR is set
1319 # - core.worktree is not set
1320 # - .git is a file
1321 # - core.bare is not set, cwd is outside .git
1323 # Output:
1325 # #3 except that git_dir is set by .git file
1327 test_expect_success '#11: setup' '
1328 sane_unset GIT_DIR GIT_WORK_TREE &&
1329 mkdir 11 11/sub 11/sub/sub 11.wt 11.wt/sub 11/wt 11/wt/sub &&
1330 cd 11 &&
1331 git init &&
1332 mv .git ../11.git &&
1333 echo gitdir: ../11.git >.git &&
1334 cd ..
1337 test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
1338 cat >11/expected <<EOF &&
1339 setup: git_dir: $here/11.git
1340 setup: worktree: $here/11
1341 setup: cwd: $here/11
1342 setup: prefix: (null)
1344 test_repo 11 .git "$here/11"
1347 test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
1348 cat >11/expected <<EOF &&
1349 setup: git_dir: $here/11.git
1350 setup: worktree: $here/11
1351 setup: cwd: $here/11
1352 setup: prefix: (null)
1354 test_repo 11 .git .
1357 test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=root at root' '
1358 cat >11/expected <<EOF &&
1359 setup: git_dir: $here/11.git
1360 setup: worktree: $here/11
1361 setup: cwd: $here/11
1362 setup: prefix: (null)
1364 test_repo 11 "$here/11/.git" "$here/11"
1367 test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
1368 cat >11/expected <<EOF &&
1369 setup: git_dir: $here/11.git
1370 setup: worktree: $here/11
1371 setup: cwd: $here/11
1372 setup: prefix: (null)
1374 test_repo 11 "$here/11/.git" .
1377 test_expect_success '#11: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
1378 cat >11/sub/sub/expected <<EOF &&
1379 setup: git_dir: $here/11.git
1380 setup: worktree: $here/11
1381 setup: cwd: $here/11
1382 setup: prefix: sub/sub/
1384 test_repo 11/sub/sub ../../.git "$here/11"
1387 test_expect_success '#11: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
1388 cat >11/sub/sub/expected <<EOF &&
1389 setup: git_dir: $here/11.git
1390 setup: worktree: $here/11
1391 setup: cwd: $here/11
1392 setup: prefix: sub/sub/
1394 test_repo 11/sub/sub ../../.git ../..
1397 test_expect_success '#11: GIT_DIR, GIT_WORKTREE=root in subdir' '
1398 cat >11/sub/expected <<EOF &&
1399 setup: git_dir: $here/11.git
1400 setup: worktree: $here/11
1401 setup: cwd: $here/11
1402 setup: prefix: sub/
1404 test_repo 11/sub "$here/11/.git" "$here/11"
1407 test_expect_success '#11: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
1408 cat >11/sub/sub/expected <<EOF &&
1409 setup: git_dir: $here/11.git
1410 setup: worktree: $here/11
1411 setup: cwd: $here/11
1412 setup: prefix: sub/sub/
1414 test_repo 11/sub/sub "$here/11/.git" ../..
1417 test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
1418 cat >11/expected <<EOF &&
1419 setup: git_dir: $here/11.git
1420 setup: worktree: $here/11/wt
1421 setup: cwd: $here/11
1422 setup: prefix: (null)
1424 test_repo 11 .git "$here/11/wt"
1427 test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
1428 cat >11/expected <<EOF &&
1429 setup: git_dir: $here/11.git
1430 setup: worktree: $here/11/wt
1431 setup: cwd: $here/11
1432 setup: prefix: (null)
1434 test_repo 11 .git wt
1437 test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
1438 cat >11/expected <<EOF &&
1439 setup: git_dir: $here/11.git
1440 setup: worktree: $here/11/wt
1441 setup: cwd: $here/11
1442 setup: prefix: (null)
1444 test_repo 11 "$here/11/.git" wt
1447 test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=wt at root' '
1448 cat >11/expected <<EOF &&
1449 setup: git_dir: $here/11.git
1450 setup: worktree: $here/11/wt
1451 setup: cwd: $here/11
1452 setup: prefix: (null)
1454 test_repo 11 "$here/11/.git" "$here/11/wt"
1457 test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
1458 cat >11/sub/sub/expected <<EOF &&
1459 setup: git_dir: $here/11.git
1460 setup: worktree: $here/11/wt
1461 setup: cwd: $here/11/sub/sub
1462 setup: prefix: (null)
1464 test_repo 11/sub/sub ../../.git "$here/11/wt"
1467 test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
1468 cat >11/sub/sub/expected <<EOF &&
1469 setup: git_dir: $here/11.git
1470 setup: worktree: $here/11/wt
1471 setup: cwd: $here/11/sub/sub
1472 setup: prefix: (null)
1474 test_repo 11/sub/sub ../../.git ../../wt
1477 test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
1478 cat >11/sub/sub/expected <<EOF &&
1479 setup: git_dir: $here/11.git
1480 setup: worktree: $here/11/wt
1481 setup: cwd: $here/11/sub/sub
1482 setup: prefix: (null)
1484 test_repo 11/sub/sub "$here/11/.git" ../../wt
1487 test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
1488 cat >11/sub/sub/expected <<EOF &&
1489 setup: git_dir: $here/11.git
1490 setup: worktree: $here/11/wt
1491 setup: cwd: $here/11/sub/sub
1492 setup: prefix: (null)
1494 test_repo 11/sub/sub "$here/11/.git" "$here/11/wt"
1497 test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
1498 cat >11/expected <<EOF &&
1499 setup: git_dir: $here/11.git
1500 setup: worktree: $here
1501 setup: cwd: $here
1502 setup: prefix: 11/
1504 test_repo 11 .git "$here"
1507 test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
1508 cat >11/expected <<EOF &&
1509 setup: git_dir: $here/11.git
1510 setup: worktree: $here
1511 setup: cwd: $here
1512 setup: prefix: 11/
1514 test_repo 11 .git ..
1517 test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
1518 cat >11/expected <<EOF &&
1519 setup: git_dir: $here/11.git
1520 setup: worktree: $here
1521 setup: cwd: $here
1522 setup: prefix: 11/
1524 test_repo 11 "$here/11/.git" ..
1527 test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=.. at root' '
1528 cat >11/expected <<EOF &&
1529 setup: git_dir: $here/11.git
1530 setup: worktree: $here
1531 setup: cwd: $here
1532 setup: prefix: 11/
1534 test_repo 11 "$here/11/.git" "$here"
1537 test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
1538 cat >11/sub/sub/expected <<EOF &&
1539 setup: git_dir: $here/11.git
1540 setup: worktree: $here
1541 setup: cwd: $here
1542 setup: prefix: 11/sub/sub/
1544 test_repo 11/sub/sub ../../.git "$here"
1547 test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
1548 cat >11/sub/sub/expected <<EOF &&
1549 setup: git_dir: $here/11.git
1550 setup: worktree: $here
1551 setup: cwd: $here
1552 setup: prefix: 11/sub/sub/
1554 test_repo 11/sub/sub ../../.git ../../..
1557 test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
1558 cat >11/sub/sub/expected <<EOF &&
1559 setup: git_dir: $here/11.git
1560 setup: worktree: $here
1561 setup: cwd: $here
1562 setup: prefix: 11/sub/sub/
1564 test_repo 11/sub/sub "$here/11/.git" ../../../
1567 test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
1568 cat >11/sub/sub/expected <<EOF &&
1569 setup: git_dir: $here/11.git
1570 setup: worktree: $here
1571 setup: cwd: $here
1572 setup: prefix: 11/sub/sub/
1574 test_repo 11/sub/sub "$here/11/.git" "$here"
1578 # case #12
1580 ############################################################
1582 # Input:
1584 # - GIT_WORK_TREE is not set
1585 # - GIT_DIR is not set
1586 # - core.worktree is set
1587 # - .git is a file
1588 # - core.bare is not set, cwd is outside .git
1590 # Output:
1592 # #4 except that git_dir is set by .git file
1595 test_expect_success '#12: setup' '
1596 sane_unset GIT_DIR GIT_WORK_TREE &&
1597 mkdir 12 12/sub 12/sub/sub 12.wt 12.wt/sub 12/wt 12/wt/sub &&
1598 cd 12 &&
1599 git init &&
1600 git config core.worktree non-existent &&
1601 mv .git ../12.git &&
1602 echo gitdir: ../12.git >.git &&
1603 cd ..
1606 test_expect_success '#12: at root' '
1607 cat >12/expected <<EOF &&
1608 setup: git_dir: $here/12.git
1609 setup: worktree: $here/12
1610 setup: cwd: $here/12
1611 setup: prefix: (null)
1613 test_repo 12
1616 test_expect_success '#12: in subdir' '
1617 cat >12/sub/expected <<EOF &&
1618 setup: git_dir: $here/12.git
1619 setup: worktree: $here/12
1620 setup: cwd: $here/12
1621 setup: prefix: sub/
1623 test_repo 12/sub
1627 # case #13
1629 ############################################################
1631 # Input:
1633 # - GIT_WORK_TREE is set
1634 # - GIT_DIR is not set
1635 # - core.worktree is set
1636 # - .git is a file
1637 # - core.bare is not set, cwd is outside .git
1639 # Output:
1641 # #5 except that git_dir is set by .git file
1643 test_expect_success '#13: setup' '
1644 sane_unset GIT_DIR GIT_WORK_TREE &&
1645 mkdir 13 13/sub 13/sub/sub 13.wt 13.wt/sub 13/wt 13/wt/sub &&
1646 cd 13 &&
1647 git init &&
1648 git config core.worktree non-existent &&
1649 GIT_WORK_TREE=non-existent-too &&
1650 export GIT_WORK_TREE &&
1651 mv .git ../13.git &&
1652 echo gitdir: ../13.git >.git &&
1653 cd ..
1656 test_expect_success '#13: at root' '
1657 cat >13/expected <<EOF &&
1658 setup: git_dir: $here/13.git
1659 setup: worktree: $here/13
1660 setup: cwd: $here/13
1661 setup: prefix: (null)
1663 test_repo 13
1666 test_expect_success '#13: in subdir' '
1667 cat >13/sub/expected <<EOF &&
1668 setup: git_dir: $here/13.git
1669 setup: worktree: $here/13
1670 setup: cwd: $here/13
1671 setup: prefix: sub/
1673 test_repo 13/sub
1677 # case #14
1679 ############################################################
1681 # Input:
1683 # - GIT_WORK_TREE is not set
1684 # - GIT_DIR is set
1685 # - core.worktree is set
1686 # - .git is a file
1687 # - core.bare is not set, cwd is outside .git
1689 # Output:
1691 # #6 except that git_dir is set by .git file
1693 test_expect_success '#14: setup' '
1694 sane_unset GIT_DIR GIT_WORK_TREE &&
1695 mkdir 14 14/sub 14/sub/sub 14.wt 14.wt/sub 14/wt 14/wt/sub &&
1696 cd 14 &&
1697 git init &&
1698 mv .git ../14.git &&
1699 echo gitdir: ../14.git >.git &&
1700 cd ..
1703 test_expect_success '#14: GIT_DIR(rel), core.worktree=../14 at root' '
1704 cat >14/expected <<EOF &&
1705 setup: git_dir: $here/14.git
1706 setup: worktree: $here/14
1707 setup: cwd: $here/14
1708 setup: prefix: (null)
1710 git config --file="$here/14.git/config" core.worktree "$here/14" &&
1711 test_repo 14 .git
1714 test_expect_success '#14: GIT_DIR(rel), core.worktree=../14(rel) at root' '
1715 cat >14/expected <<EOF &&
1716 setup: git_dir: $here/14.git
1717 setup: worktree: $here/14
1718 setup: cwd: $here/14
1719 setup: prefix: (null)
1721 git config --file="$here/14.git/config" core.worktree ../14 &&
1722 test_repo 14 .git
1725 test_expect_success '#14: GIT_DIR, core.worktree=../14 at root' '
1726 cat >14/expected <<EOF &&
1727 setup: git_dir: $here/14.git
1728 setup: worktree: $here/14
1729 setup: cwd: $here/14
1730 setup: prefix: (null)
1732 git config --file="$here/14.git/config" core.worktree "$here/14" &&
1733 test_repo 14 "$here/14/.git"
1736 test_expect_success '#14: GIT_DIR, core.worktree=../14(rel) at root' '
1737 cat >14/expected <<EOF &&
1738 setup: git_dir: $here/14.git
1739 setup: worktree: $here/14
1740 setup: cwd: $here/14
1741 setup: prefix: (null)
1743 git config --file="$here/14.git/config" core.worktree ../14 &&
1744 test_repo 14 "$here/14/.git"
1747 test_expect_success '#14: GIT_DIR(rel), core.worktree=../14 in subdir' '
1748 cat >14/sub/sub/expected <<EOF &&
1749 setup: git_dir: $here/14.git
1750 setup: worktree: $here/14
1751 setup: cwd: $here/14
1752 setup: prefix: sub/sub/
1754 git config --file="$here/14.git/config" core.worktree "$here/14" &&
1755 test_repo 14/sub/sub ../../.git
1758 test_expect_success '#14: GIT_DIR(rel), core.worktree=../14(rel) in subdir' '
1759 cat >14/sub/sub/expected <<EOF &&
1760 setup: git_dir: $here/14.git
1761 setup: worktree: $here/14
1762 setup: cwd: $here/14
1763 setup: prefix: sub/sub/
1765 git config --file="$here/14.git/config" core.worktree ../14 &&
1766 test_repo 14/sub/sub ../../.git
1769 test_expect_success '#14: GIT_DIR, core.worktree=../14 in subdir' '
1770 cat >14/sub/expected <<EOF &&
1771 setup: git_dir: $here/14.git
1772 setup: worktree: $here/14
1773 setup: cwd: $here/14
1774 setup: prefix: sub/
1776 git config --file="$here/14.git/config" core.worktree "$here/14" &&
1777 test_repo 14/sub "$here/14/.git"
1780 test_expect_success '#14: GIT_DIR, core.worktree=../14(rel) in subdir' '
1781 cat >14/sub/sub/expected <<EOF &&
1782 setup: git_dir: $here/14.git
1783 setup: worktree: $here/14
1784 setup: cwd: $here/14
1785 setup: prefix: sub/sub/
1787 git config --file="$here/14.git/config" core.worktree ../14 &&
1788 test_repo 14/sub/sub "$here/14/.git"
1791 test_expect_success '#14: GIT_DIR(rel), core.worktree=../14/wt at root' '
1792 cat >14/expected <<EOF &&
1793 setup: git_dir: $here/14.git
1794 setup: worktree: $here/14/wt
1795 setup: cwd: $here/14
1796 setup: prefix: (null)
1798 git config --file="$here/14.git/config" core.worktree "$here/14/wt" &&
1799 test_repo 14 .git
1802 test_expect_success '#14: GIT_DIR(rel), core.worktree=../14/wt(rel) at root' '
1803 cat >14/expected <<EOF &&
1804 setup: git_dir: $here/14.git
1805 setup: worktree: $here/14/wt
1806 setup: cwd: $here/14
1807 setup: prefix: (null)
1809 git config --file="$here/14.git/config" core.worktree ../14/wt &&
1810 test_repo 14 .git
1813 test_expect_success '#14: GIT_DIR, core.worktree=../14/wt(rel) at root' '
1814 cat >14/expected <<EOF &&
1815 setup: git_dir: $here/14.git
1816 setup: worktree: $here/14/wt
1817 setup: cwd: $here/14
1818 setup: prefix: (null)
1820 git config --file="$here/14.git/config" core.worktree ../14/wt &&
1821 test_repo 14 "$here/14/.git"
1824 test_expect_success '#14: GIT_DIR, core.worktree=../14/wt at root' '
1825 cat >14/expected <<EOF &&
1826 setup: git_dir: $here/14.git
1827 setup: worktree: $here/14/wt
1828 setup: cwd: $here/14
1829 setup: prefix: (null)
1831 git config --file="$here/14.git/config" core.worktree "$here/14/wt" &&
1832 test_repo 14 "$here/14/.git"
1835 test_expect_success '#14: GIT_DIR(rel), core.worktree=../14/wt in subdir' '
1836 cat >14/sub/sub/expected <<EOF &&
1837 setup: git_dir: $here/14.git
1838 setup: worktree: $here/14/wt
1839 setup: cwd: $here/14/sub/sub
1840 setup: prefix: (null)
1842 git config --file="$here/14.git/config" core.worktree "$here/14/wt" &&
1843 test_repo 14/sub/sub ../../.git
1846 test_expect_success '#14: GIT_DIR(rel), core.worktree=../14/wt(rel) in subdir' '
1847 cat >14/sub/sub/expected <<EOF &&
1848 setup: git_dir: $here/14.git
1849 setup: worktree: $here/14/wt
1850 setup: cwd: $here/14/sub/sub
1851 setup: prefix: (null)
1853 git config --file="$here/14.git/config" core.worktree ../14/wt &&
1854 test_repo 14/sub/sub ../../.git
1857 test_expect_success '#14: GIT_DIR, core.worktree=../14/wt(rel) in subdir' '
1858 cat >14/sub/sub/expected <<EOF &&
1859 setup: git_dir: $here/14.git
1860 setup: worktree: $here/14/wt
1861 setup: cwd: $here/14/sub/sub
1862 setup: prefix: (null)
1864 git config --file="$here/14.git/config" core.worktree ../14/wt &&
1865 test_repo 14/sub/sub "$here/14/.git"
1868 test_expect_success '#14: GIT_DIR, core.worktree=../14/wt in subdir' '
1869 cat >14/sub/sub/expected <<EOF &&
1870 setup: git_dir: $here/14.git
1871 setup: worktree: $here/14/wt
1872 setup: cwd: $here/14/sub/sub
1873 setup: prefix: (null)
1875 git config --file="$here/14.git/config" core.worktree "$here/14/wt" &&
1876 test_repo 14/sub/sub "$here/14/.git"
1879 test_expect_success '#14: GIT_DIR(rel), core.worktree=.. at root' '
1880 cat >14/expected <<EOF &&
1881 setup: git_dir: $here/14.git
1882 setup: worktree: $here
1883 setup: cwd: $here
1884 setup: prefix: 14/
1886 git config --file="$here/14.git/config" core.worktree "$here" &&
1887 test_repo 14 .git
1890 test_expect_success '#14: GIT_DIR(rel), core.worktree=..(rel) at root' '
1891 cat >14/expected <<EOF &&
1892 setup: git_dir: $here/14.git
1893 setup: worktree: $here
1894 setup: cwd: $here
1895 setup: prefix: 14/
1897 git config --file="$here/14.git/config" core.worktree .. &&
1898 test_repo 14 .git
1901 test_expect_success '#14: GIT_DIR, core.worktree=..(rel) at root' '
1902 cat >14/expected <<EOF &&
1903 setup: git_dir: $here/14.git
1904 setup: worktree: $here
1905 setup: cwd: $here
1906 setup: prefix: 14/
1908 git config --file="$here/14.git/config" core.worktree .. &&
1909 test_repo 14 "$here/14/.git"
1912 test_expect_success '#14: GIT_DIR, core.worktree=.. at root' '
1913 cat >14/expected <<EOF &&
1914 setup: git_dir: $here/14.git
1915 setup: worktree: $here
1916 setup: cwd: $here
1917 setup: prefix: 14/
1919 git config --file="$here/14.git/config" core.worktree "$here" &&
1920 test_repo 14 "$here/14/.git"
1923 test_expect_success '#14: GIT_DIR(rel), core.worktree=.. in subdir' '
1924 cat >14/sub/sub/expected <<EOF &&
1925 setup: git_dir: $here/14.git
1926 setup: worktree: $here
1927 setup: cwd: $here
1928 setup: prefix: 14/sub/sub/
1930 git config --file="$here/14.git/config" core.worktree "$here" &&
1931 test_repo 14/sub/sub ../../.git
1934 test_expect_success '#14: GIT_DIR(rel), core.worktree=..(rel) in subdir' '
1935 cat >14/sub/sub/expected <<EOF &&
1936 setup: git_dir: $here/14.git
1937 setup: worktree: $here
1938 setup: cwd: $here
1939 setup: prefix: 14/sub/sub/
1941 git config --file="$here/14.git/config" core.worktree .. &&
1942 test_repo 14/sub/sub ../../.git
1945 test_expect_success '#14: GIT_DIR, core.worktree=..(rel) in subdir' '
1946 cat >14/sub/sub/expected <<EOF &&
1947 setup: git_dir: $here/14.git
1948 setup: worktree: $here
1949 setup: cwd: $here
1950 setup: prefix: 14/sub/sub/
1952 git config --file="$here/14.git/config" core.worktree .. &&
1953 test_repo 14/sub/sub "$here/14/.git"
1956 test_expect_success '#14: GIT_DIR, core.worktree=.. in subdir' '
1957 cat >14/sub/sub/expected <<EOF &&
1958 setup: git_dir: $here/14.git
1959 setup: worktree: $here
1960 setup: cwd: $here
1961 setup: prefix: 14/sub/sub/
1963 git config --file="$here/14.git/config" core.worktree "$here" &&
1964 test_repo 14/sub/sub "$here/14/.git"
1968 # case #15
1970 ############################################################
1972 # Input:
1974 # - GIT_WORK_TREE is set
1975 # - GIT_DIR is set
1976 # - core.worktree is set
1977 # - .git is a file
1978 # - core.bare is not set, cwd is outside .git
1980 # Output:
1982 # #7 except that git_dir is set by .git file
1984 test_expect_success '#15: setup' '
1985 sane_unset GIT_DIR GIT_WORK_TREE &&
1986 mkdir 15 15/sub 15/sub/sub 15.wt 15.wt/sub 15/wt 15/wt/sub &&
1987 cd 15 &&
1988 git init &&
1989 git config core.worktree non-existent &&
1990 mv .git ../15.git &&
1991 echo gitdir: ../15.git >.git &&
1992 cd ..
1995 test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
1996 cat >15/expected <<EOF &&
1997 setup: git_dir: $here/15.git
1998 setup: worktree: $here/15
1999 setup: cwd: $here/15
2000 setup: prefix: (null)
2002 test_repo 15 .git "$here/15"
2005 test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
2006 cat >15/expected <<EOF &&
2007 setup: git_dir: $here/15.git
2008 setup: worktree: $here/15
2009 setup: cwd: $here/15
2010 setup: prefix: (null)
2012 test_repo 15 .git .
2015 test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=root at root' '
2016 cat >15/expected <<EOF &&
2017 setup: git_dir: $here/15.git
2018 setup: worktree: $here/15
2019 setup: cwd: $here/15
2020 setup: prefix: (null)
2022 test_repo 15 "$here/15/.git" "$here/15"
2025 test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
2026 cat >15/expected <<EOF &&
2027 setup: git_dir: $here/15.git
2028 setup: worktree: $here/15
2029 setup: cwd: $here/15
2030 setup: prefix: (null)
2032 test_repo 15 "$here/15/.git" .
2035 test_expect_success '#15: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
2036 cat >15/sub/sub/expected <<EOF &&
2037 setup: git_dir: $here/15.git
2038 setup: worktree: $here/15
2039 setup: cwd: $here/15
2040 setup: prefix: sub/sub/
2042 test_repo 15/sub/sub ../../.git "$here/15"
2045 test_expect_success '#15: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
2046 cat >15/sub/sub/expected <<EOF &&
2047 setup: git_dir: $here/15.git
2048 setup: worktree: $here/15
2049 setup: cwd: $here/15
2050 setup: prefix: sub/sub/
2052 test_repo 15/sub/sub ../../.git ../..
2055 test_expect_success '#15: GIT_DIR, GIT_WORKTREE=root in subdir' '
2056 cat >15/sub/expected <<EOF &&
2057 setup: git_dir: $here/15.git
2058 setup: worktree: $here/15
2059 setup: cwd: $here/15
2060 setup: prefix: sub/
2062 test_repo 15/sub "$here/15/.git" "$here/15"
2065 test_expect_success '#15: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
2066 cat >15/sub/sub/expected <<EOF &&
2067 setup: git_dir: $here/15.git
2068 setup: worktree: $here/15
2069 setup: cwd: $here/15
2070 setup: prefix: sub/sub/
2072 test_repo 15/sub/sub "$here/15/.git" ../..
2075 test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
2076 cat >15/expected <<EOF &&
2077 setup: git_dir: $here/15.git
2078 setup: worktree: $here/15/wt
2079 setup: cwd: $here/15
2080 setup: prefix: (null)
2082 test_repo 15 .git "$here/15/wt"
2085 test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
2086 cat >15/expected <<EOF &&
2087 setup: git_dir: $here/15.git
2088 setup: worktree: $here/15/wt
2089 setup: cwd: $here/15
2090 setup: prefix: (null)
2092 test_repo 15 .git wt
2095 test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
2096 cat >15/expected <<EOF &&
2097 setup: git_dir: $here/15.git
2098 setup: worktree: $here/15/wt
2099 setup: cwd: $here/15
2100 setup: prefix: (null)
2102 test_repo 15 "$here/15/.git" wt
2105 test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=wt at root' '
2106 cat >15/expected <<EOF &&
2107 setup: git_dir: $here/15.git
2108 setup: worktree: $here/15/wt
2109 setup: cwd: $here/15
2110 setup: prefix: (null)
2112 test_repo 15 "$here/15/.git" "$here/15/wt"
2115 test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
2116 cat >15/sub/sub/expected <<EOF &&
2117 setup: git_dir: $here/15.git
2118 setup: worktree: $here/15/wt
2119 setup: cwd: $here/15/sub/sub
2120 setup: prefix: (null)
2122 test_repo 15/sub/sub ../../.git "$here/15/wt"
2125 test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
2126 cat >15/sub/sub/expected <<EOF &&
2127 setup: git_dir: $here/15.git
2128 setup: worktree: $here/15/wt
2129 setup: cwd: $here/15/sub/sub
2130 setup: prefix: (null)
2132 test_repo 15/sub/sub ../../.git ../../wt
2135 test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
2136 cat >15/sub/sub/expected <<EOF &&
2137 setup: git_dir: $here/15.git
2138 setup: worktree: $here/15/wt
2139 setup: cwd: $here/15/sub/sub
2140 setup: prefix: (null)
2142 test_repo 15/sub/sub "$here/15/.git" ../../wt
2145 test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
2146 cat >15/sub/sub/expected <<EOF &&
2147 setup: git_dir: $here/15.git
2148 setup: worktree: $here/15/wt
2149 setup: cwd: $here/15/sub/sub
2150 setup: prefix: (null)
2152 test_repo 15/sub/sub "$here/15/.git" "$here/15/wt"
2155 test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
2156 cat >15/expected <<EOF &&
2157 setup: git_dir: $here/15.git
2158 setup: worktree: $here
2159 setup: cwd: $here
2160 setup: prefix: 15/
2162 test_repo 15 .git "$here"
2165 test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
2166 cat >15/expected <<EOF &&
2167 setup: git_dir: $here/15.git
2168 setup: worktree: $here
2169 setup: cwd: $here
2170 setup: prefix: 15/
2172 test_repo 15 .git ..
2175 test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
2176 cat >15/expected <<EOF &&
2177 setup: git_dir: $here/15.git
2178 setup: worktree: $here
2179 setup: cwd: $here
2180 setup: prefix: 15/
2182 test_repo 15 "$here/15/.git" ..
2185 test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=.. at root' '
2186 cat >15/expected <<EOF &&
2187 setup: git_dir: $here/15.git
2188 setup: worktree: $here
2189 setup: cwd: $here
2190 setup: prefix: 15/
2192 test_repo 15 "$here/15/.git" "$here"
2195 test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
2196 cat >15/sub/sub/expected <<EOF &&
2197 setup: git_dir: $here/15.git
2198 setup: worktree: $here
2199 setup: cwd: $here
2200 setup: prefix: 15/sub/sub/
2202 test_repo 15/sub/sub ../../.git "$here"
2205 test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
2206 cat >15/sub/sub/expected <<EOF &&
2207 setup: git_dir: $here/15.git
2208 setup: worktree: $here
2209 setup: cwd: $here
2210 setup: prefix: 15/sub/sub/
2212 test_repo 15/sub/sub ../../.git ../../..
2215 test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
2216 cat >15/sub/sub/expected <<EOF &&
2217 setup: git_dir: $here/15.git
2218 setup: worktree: $here
2219 setup: cwd: $here
2220 setup: prefix: 15/sub/sub/
2222 test_repo 15/sub/sub "$here/15/.git" ../../../
2225 test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
2226 cat >15/sub/sub/expected <<EOF &&
2227 setup: git_dir: $here/15.git
2228 setup: worktree: $here
2229 setup: cwd: $here
2230 setup: prefix: 15/sub/sub/
2232 test_repo 15/sub/sub "$here/15/.git" "$here"
2236 # case #16.1
2238 ############################################################
2240 # Input:
2242 # - GIT_WORK_TREE is not set
2243 # - GIT_DIR is not set
2244 # - core.worktree is not set
2245 # - .git is a directory
2246 # - cwd is inside .git
2248 # Output:
2250 # - no worktree
2251 # - cwd is unchanged
2252 # - prefix is NULL
2253 # - git_dir is set
2254 # - cwd can't be outside worktree
2256 test_expect_success '#16.1: setup' '
2257 sane_unset GIT_DIR GIT_WORK_TREE &&
2258 mkdir 16 16/sub &&
2259 cd 16 &&
2260 git init &&
2261 mkdir .git/wt .git/wt/sub &&
2262 cd ..
2265 test_expect_success '#16.1: at .git' '
2266 cat >16/.git/expected <<EOF &&
2267 setup: git_dir: .
2268 setup: worktree: (null)
2269 setup: cwd: $here/16/.git
2270 setup: prefix: (null)
2272 test_repo 16/.git
2275 test_expect_success '#16.1: in .git/wt' '
2276 cat >16/.git/wt/expected <<EOF &&
2277 setup: git_dir: $here/16/.git
2278 setup: worktree: (null)
2279 setup: cwd: $here/16/.git/wt
2280 setup: prefix: (null)
2282 test_repo 16/.git/wt
2285 test_expect_success '#16.1: in .git/wt/sub' '
2286 cat >16/.git/wt/sub/expected <<EOF &&
2287 setup: git_dir: $here/16/.git
2288 setup: worktree: (null)
2289 setup: cwd: $here/16/.git/wt/sub
2290 setup: prefix: (null)
2292 test_repo 16/.git/wt/sub
2296 # case #16.2
2298 ############################################################
2300 # Input:
2302 # - GIT_WORK_TREE is not set
2303 # - GIT_DIR is not set
2304 # - core.worktree is not set
2305 # - .git is a directory
2306 # - core.bare is set
2308 # Output:
2310 # - no worktree
2311 # - cwd is unchanged
2312 # - prefix is NULL
2313 # - git_dir is set
2314 # - cwd can't be outside worktree
2316 test_expect_success '#16.2: setup' '
2317 git config --file="$here/16/.git/config" core.bare true
2320 test_expect_success '#16.2: at .git' '
2321 cat >16/.git/expected <<EOF &&
2322 setup: git_dir: .
2323 setup: worktree: (null)
2324 setup: cwd: $here/16/.git
2325 setup: prefix: (null)
2327 test_repo 16/.git
2330 test_expect_success '#16.2: in .git/wt' '
2331 cat >16/.git/wt/expected <<EOF &&
2332 setup: git_dir: $here/16/.git
2333 setup: worktree: (null)
2334 setup: cwd: $here/16/.git/wt
2335 setup: prefix: (null)
2337 test_repo 16/.git/wt
2340 test_expect_success '#16.2: in .git/wt/sub' '
2341 cat >16/.git/wt/sub/expected <<EOF &&
2342 setup: git_dir: $here/16/.git
2343 setup: worktree: (null)
2344 setup: cwd: $here/16/.git/wt/sub
2345 setup: prefix: (null)
2347 test_repo 16/.git/wt/sub
2350 test_expect_success '#16.2: at root' '
2351 cat >16/expected <<EOF &&
2352 setup: git_dir: .git
2353 setup: worktree: (null)
2354 setup: cwd: $here/16
2355 setup: prefix: (null)
2357 test_repo 16
2360 test_expect_success '#16.2: in subdir' '
2361 cat >16/sub/expected <<EOF &&
2362 setup: git_dir: $here/16/.git
2363 setup: worktree: (null)
2364 setup: cwd: $here/16/sub
2365 setup: prefix: (null)
2367 test_repo 16/sub
2371 # case #17.1
2373 ############################################################
2375 # Input:
2377 # - GIT_WORK_TREE is set
2378 # - GIT_DIR is not set
2379 # - core.worktree is not set
2380 # - .git is a directory
2381 # - cwd is inside .git
2383 # Output:
2385 # GIT_WORK_TREE is ignored -> #16.1 (with warnings perhaps)
2387 test_expect_success '#17.1: setup' '
2388 sane_unset GIT_DIR GIT_WORK_TREE &&
2389 mkdir 17 17/sub &&
2390 cd 17 &&
2391 git init &&
2392 mkdir .git/wt .git/wt/sub &&
2393 GIT_WORK_TREE=non-existent &&
2394 export GIT_WORK_TREE &&
2395 cd ..
2398 test_expect_success '#17.1: at .git' '
2399 cat >17/.git/expected <<EOF &&
2400 setup: git_dir: .
2401 setup: worktree: (null)
2402 setup: cwd: $here/17/.git
2403 setup: prefix: (null)
2405 test_repo 17/.git
2408 test_expect_success '#17.1: in .git/wt' '
2409 cat >17/.git/wt/expected <<EOF &&
2410 setup: git_dir: $here/17/.git
2411 setup: worktree: (null)
2412 setup: cwd: $here/17/.git/wt
2413 setup: prefix: (null)
2415 test_repo 17/.git/wt
2418 test_expect_success '#17.1: in .git/wt/sub' '
2419 cat >17/.git/wt/sub/expected <<EOF &&
2420 setup: git_dir: $here/17/.git
2421 setup: worktree: (null)
2422 setup: cwd: $here/17/.git/wt/sub
2423 setup: prefix: (null)
2425 test_repo 17/.git/wt/sub
2429 # case #17.2
2431 ############################################################
2433 # Input:
2435 # - GIT_WORK_TREE is set
2436 # - GIT_DIR is not set
2437 # - core.worktree is not set
2438 # - .git is a directory
2439 # - core.bare is set
2441 # Output:
2443 # GIT_WORK_TREE is ignored -> #16.2 (with warnings perhaps)
2445 test_expect_success '#17.2: setup' '
2446 git config --file="$here/17/.git/config" core.bare true
2449 test_expect_success '#17.2: at .git' '
2450 cat >17/.git/expected <<EOF &&
2451 setup: git_dir: .
2452 setup: worktree: (null)
2453 setup: cwd: $here/17/.git
2454 setup: prefix: (null)
2456 test_repo 17/.git
2459 test_expect_success '#17.2: in .git/wt' '
2460 cat >17/.git/wt/expected <<EOF &&
2461 setup: git_dir: $here/17/.git
2462 setup: worktree: (null)
2463 setup: cwd: $here/17/.git/wt
2464 setup: prefix: (null)
2466 test_repo 17/.git/wt
2469 test_expect_success '#17.2: in .git/wt/sub' '
2470 cat >17/.git/wt/sub/expected <<EOF &&
2471 setup: git_dir: $here/17/.git
2472 setup: worktree: (null)
2473 setup: cwd: $here/17/.git/wt/sub
2474 setup: prefix: (null)
2476 test_repo 17/.git/wt/sub
2479 test_expect_success '#17.2: at root' '
2480 cat >17/expected <<EOF &&
2481 setup: git_dir: .git
2482 setup: worktree: (null)
2483 setup: cwd: $here/17
2484 setup: prefix: (null)
2486 test_repo 17
2489 test_expect_success '#17.2: in subdir' '
2490 cat >17/sub/expected <<EOF &&
2491 setup: git_dir: $here/17/.git
2492 setup: worktree: (null)
2493 setup: cwd: $here/17/sub
2494 setup: prefix: (null)
2496 test_repo 17/sub
2500 # case #18
2502 ############################################################
2504 # Input:
2506 # - GIT_WORK_TREE is not set
2507 # - GIT_DIR is set
2508 # - core.worktree is not set
2509 # - .git is a directory
2510 # - core.bare is set
2512 # Output:
2514 # - no worktree (rule #8)
2515 # - cwd is unchanged
2516 # - prefix is NULL
2517 # - git_dir is set to $GIT_DIR
2518 # - cwd can't be outside worktree
2520 test_expect_success '#18: setup' '
2521 sane_unset GIT_DIR GIT_WORK_TREE &&
2522 mkdir 18 18/sub &&
2523 cd 18 &&
2524 git init &&
2525 mkdir .git/wt .git/wt/sub &&
2526 git config core.bare true &&
2527 cd ..
2530 test_expect_success '#18: (rel) at root' '
2531 cat >18/expected <<EOF &&
2532 setup: git_dir: .git
2533 setup: worktree: (null)
2534 setup: cwd: $here/18
2535 setup: prefix: (null)
2537 test_repo 18 .git
2540 test_expect_success '#18: at root' '
2541 cat >18/expected <<EOF &&
2542 setup: git_dir: $here/18/.git
2543 setup: worktree: (null)
2544 setup: cwd: $here/18
2545 setup: prefix: (null)
2547 test_repo 18 "$here/18/.git"
2550 test_expect_success '#18: (rel) in subdir' '
2551 cat >18/sub/expected <<EOF &&
2552 setup: git_dir: ../.git
2553 setup: worktree: (null)
2554 setup: cwd: $here/18/sub
2555 setup: prefix: (null)
2557 test_repo 18/sub ../.git
2560 test_expect_success '#18: in subdir' '
2561 cat >18/sub/expected <<EOF &&
2562 setup: git_dir: $here/18/.git
2563 setup: worktree: (null)
2564 setup: cwd: $here/18/sub
2565 setup: prefix: (null)
2567 test_repo 18/sub "$here/18/.git"
2571 # case #19
2573 ############################################################
2575 # Input:
2577 # - GIT_WORK_TREE is set
2578 # - GIT_DIR is set
2579 # - .git is a directory
2580 # - core.worktree is not set
2581 # - core.bare is set
2583 # Output:
2585 # bare repo is overridden by GIT_WORK_TREE -> #3
2587 test_expect_success '#19: setup' '
2588 sane_unset GIT_DIR GIT_WORK_TREE &&
2589 mkdir 19 19/sub 19/sub/sub 19.wt 19.wt/sub 19/wt 19/wt/sub &&
2590 cd 19 &&
2591 git init &&
2592 git config core.bare true &&
2593 cd ..
2596 test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
2597 cat >19/expected <<EOF &&
2598 setup: git_dir: .git
2599 setup: worktree: $here/19
2600 setup: cwd: $here/19
2601 setup: prefix: (null)
2603 test_repo 19 .git "$here/19"
2606 test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
2607 cat >19/expected <<EOF &&
2608 setup: git_dir: .git
2609 setup: worktree: $here/19
2610 setup: cwd: $here/19
2611 setup: prefix: (null)
2613 test_repo 19 .git .
2616 test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=root at root' '
2617 cat >19/expected <<EOF &&
2618 setup: git_dir: $here/19/.git
2619 setup: worktree: $here/19
2620 setup: cwd: $here/19
2621 setup: prefix: (null)
2623 test_repo 19 "$here/19/.git" "$here/19"
2626 test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
2627 cat >19/expected <<EOF &&
2628 setup: git_dir: $here/19/.git
2629 setup: worktree: $here/19
2630 setup: cwd: $here/19
2631 setup: prefix: (null)
2633 test_repo 19 "$here/19/.git" .
2636 test_expect_success '#19: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
2637 cat >19/sub/sub/expected <<EOF &&
2638 setup: git_dir: $here/19/.git
2639 setup: worktree: $here/19
2640 setup: cwd: $here/19
2641 setup: prefix: sub/sub/
2643 test_repo 19/sub/sub ../../.git "$here/19"
2646 test_expect_success '#19: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
2647 cat >19/sub/sub/expected <<EOF &&
2648 setup: git_dir: $here/19/.git
2649 setup: worktree: $here/19
2650 setup: cwd: $here/19
2651 setup: prefix: sub/sub/
2653 test_repo 19/sub/sub ../../.git ../..
2656 test_expect_success '#19: GIT_DIR, GIT_WORKTREE=root in subdir' '
2657 cat >19/sub/expected <<EOF &&
2658 setup: git_dir: $here/19/.git
2659 setup: worktree: $here/19
2660 setup: cwd: $here/19
2661 setup: prefix: sub/
2663 test_repo 19/sub "$here/19/.git" "$here/19"
2666 test_expect_success '#19: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
2667 cat >19/sub/sub/expected <<EOF &&
2668 setup: git_dir: $here/19/.git
2669 setup: worktree: $here/19
2670 setup: cwd: $here/19
2671 setup: prefix: sub/sub/
2673 test_repo 19/sub/sub "$here/19/.git" ../..
2676 test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
2677 cat >19/expected <<EOF &&
2678 setup: git_dir: .git
2679 setup: worktree: $here/19/wt
2680 setup: cwd: $here/19
2681 setup: prefix: (null)
2683 test_repo 19 .git "$here/19/wt"
2686 test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
2687 cat >19/expected <<EOF &&
2688 setup: git_dir: .git
2689 setup: worktree: $here/19/wt
2690 setup: cwd: $here/19
2691 setup: prefix: (null)
2693 test_repo 19 .git wt
2696 test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
2697 cat >19/expected <<EOF &&
2698 setup: git_dir: $here/19/.git
2699 setup: worktree: $here/19/wt
2700 setup: cwd: $here/19
2701 setup: prefix: (null)
2703 test_repo 19 "$here/19/.git" wt
2706 test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=wt at root' '
2707 cat >19/expected <<EOF &&
2708 setup: git_dir: $here/19/.git
2709 setup: worktree: $here/19/wt
2710 setup: cwd: $here/19
2711 setup: prefix: (null)
2713 test_repo 19 "$here/19/.git" "$here/19/wt"
2716 test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
2717 cat >19/sub/sub/expected <<EOF &&
2718 setup: git_dir: ../../.git
2719 setup: worktree: $here/19/wt
2720 setup: cwd: $here/19/sub/sub
2721 setup: prefix: (null)
2723 test_repo 19/sub/sub ../../.git "$here/19/wt"
2726 test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
2727 cat >19/sub/sub/expected <<EOF &&
2728 setup: git_dir: ../../.git
2729 setup: worktree: $here/19/wt
2730 setup: cwd: $here/19/sub/sub
2731 setup: prefix: (null)
2733 test_repo 19/sub/sub ../../.git ../../wt
2736 test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
2737 cat >19/sub/sub/expected <<EOF &&
2738 setup: git_dir: $here/19/.git
2739 setup: worktree: $here/19/wt
2740 setup: cwd: $here/19/sub/sub
2741 setup: prefix: (null)
2743 test_repo 19/sub/sub "$here/19/.git" ../../wt
2746 test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
2747 cat >19/sub/sub/expected <<EOF &&
2748 setup: git_dir: $here/19/.git
2749 setup: worktree: $here/19/wt
2750 setup: cwd: $here/19/sub/sub
2751 setup: prefix: (null)
2753 test_repo 19/sub/sub "$here/19/.git" "$here/19/wt"
2756 test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
2757 cat >19/expected <<EOF &&
2758 setup: git_dir: $here/19/.git
2759 setup: worktree: $here
2760 setup: cwd: $here
2761 setup: prefix: 19/
2763 test_repo 19 .git "$here"
2766 test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
2767 cat >19/expected <<EOF &&
2768 setup: git_dir: $here/19/.git
2769 setup: worktree: $here
2770 setup: cwd: $here
2771 setup: prefix: 19/
2773 test_repo 19 .git ..
2776 test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
2777 cat >19/expected <<EOF &&
2778 setup: git_dir: $here/19/.git
2779 setup: worktree: $here
2780 setup: cwd: $here
2781 setup: prefix: 19/
2783 test_repo 19 "$here/19/.git" ..
2786 test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=.. at root' '
2787 cat >19/expected <<EOF &&
2788 setup: git_dir: $here/19/.git
2789 setup: worktree: $here
2790 setup: cwd: $here
2791 setup: prefix: 19/
2793 test_repo 19 "$here/19/.git" "$here"
2796 test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
2797 cat >19/sub/sub/expected <<EOF &&
2798 setup: git_dir: $here/19/.git
2799 setup: worktree: $here
2800 setup: cwd: $here
2801 setup: prefix: 19/sub/sub/
2803 test_repo 19/sub/sub ../../.git "$here"
2806 test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
2807 cat >19/sub/sub/expected <<EOF &&
2808 setup: git_dir: $here/19/.git
2809 setup: worktree: $here
2810 setup: cwd: $here
2811 setup: prefix: 19/sub/sub/
2813 test_repo 19/sub/sub ../../.git ../../..
2816 test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
2817 cat >19/sub/sub/expected <<EOF &&
2818 setup: git_dir: $here/19/.git
2819 setup: worktree: $here
2820 setup: cwd: $here
2821 setup: prefix: 19/sub/sub/
2823 test_repo 19/sub/sub "$here/19/.git" ../../../
2826 test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
2827 cat >19/sub/sub/expected <<EOF &&
2828 setup: git_dir: $here/19/.git
2829 setup: worktree: $here
2830 setup: cwd: $here
2831 setup: prefix: 19/sub/sub/
2833 test_repo 19/sub/sub "$here/19/.git" "$here"
2837 # case #20.1
2839 ############################################################
2841 # Input:
2843 # - GIT_WORK_TREE is not set
2844 # - GIT_DIR is not set
2845 # - core.worktree is set
2846 # - .git is a directory
2847 # - cwd is inside .git
2849 # Output:
2851 # core.worktree is ignored -> #16.1
2853 test_expect_success '#20.1: setup' '
2854 sane_unset GIT_DIR GIT_WORK_TREE &&
2855 mkdir 20 20/sub &&
2856 cd 20 &&
2857 git init &&
2858 git config core.worktree non-existent &&
2859 mkdir .git/wt .git/wt/sub &&
2860 cd ..
2863 test_expect_success '#20.1: at .git' '
2864 cat >20/.git/expected <<EOF &&
2865 setup: git_dir: .
2866 setup: worktree: (null)
2867 setup: cwd: $here/20/.git
2868 setup: prefix: (null)
2870 test_repo 20/.git
2873 test_expect_success '#20.1: in .git/wt' '
2874 cat >20/.git/wt/expected <<EOF &&
2875 setup: git_dir: $here/20/.git
2876 setup: worktree: (null)
2877 setup: cwd: $here/20/.git/wt
2878 setup: prefix: (null)
2880 test_repo 20/.git/wt
2883 test_expect_success '#20.1: in .git/wt/sub' '
2884 cat >20/.git/wt/sub/expected <<EOF &&
2885 setup: git_dir: $here/20/.git
2886 setup: worktree: (null)
2887 setup: cwd: $here/20/.git/wt/sub
2888 setup: prefix: (null)
2890 test_repo 20/.git/wt/sub
2894 # case #20.2
2896 ############################################################
2898 # Input:
2900 # - GIT_WORK_TREE is not set
2901 # - GIT_DIR is not set
2902 # - core.worktree is set
2903 # - .git is a directory
2904 # - core.bare is set
2906 # Output:
2908 # core.worktree is ignored -> #16.2
2910 test_expect_success '#20.2: setup' '
2911 git config --file="$here/20/.git/config" core.bare true
2914 test_expect_success '#20.2: at .git' '
2915 cat >20/.git/expected <<EOF &&
2916 setup: git_dir: .
2917 setup: worktree: (null)
2918 setup: cwd: $here/20/.git
2919 setup: prefix: (null)
2921 test_repo 20/.git
2924 test_expect_success '#20.2: in .git/wt' '
2925 cat >20/.git/wt/expected <<EOF &&
2926 setup: git_dir: $here/20/.git
2927 setup: worktree: (null)
2928 setup: cwd: $here/20/.git/wt
2929 setup: prefix: (null)
2931 test_repo 20/.git/wt
2934 test_expect_success '#20.2: in .git/wt/sub' '
2935 cat >20/.git/wt/sub/expected <<EOF &&
2936 setup: git_dir: $here/20/.git
2937 setup: worktree: (null)
2938 setup: cwd: $here/20/.git/wt/sub
2939 setup: prefix: (null)
2941 test_repo 20/.git/wt/sub
2944 test_expect_success '#20.2: at root' '
2945 cat >20/expected <<EOF &&
2946 setup: git_dir: .git
2947 setup: worktree: (null)
2948 setup: cwd: $here/20
2949 setup: prefix: (null)
2951 test_repo 20
2954 test_expect_success '#20.2: in subdir' '
2955 cat >20/sub/expected <<EOF &&
2956 setup: git_dir: $here/20/.git
2957 setup: worktree: (null)
2958 setup: cwd: $here/20/sub
2959 setup: prefix: (null)
2961 test_repo 20/sub
2965 # case #21.1
2967 ############################################################
2969 # Input:
2971 # - GIT_WORK_TREE is set
2972 # - GIT_DIR is not set
2973 # - core.worktree is set
2974 # - .git is a directory
2975 # - cwd is inside .git
2977 # Output:
2979 # GIT_WORK_TREE/core.worktree are ignored -> #20.1
2981 test_expect_success '#21.1: setup' '
2982 sane_unset GIT_DIR GIT_WORK_TREE &&
2983 mkdir 21 21/sub &&
2984 cd 21 &&
2985 git init &&
2986 git config core.worktree non-existent &&
2987 GIT_WORK_TREE=non-existent-too &&
2988 export GIT_WORK_TREE &&
2989 mkdir .git/wt .git/wt/sub &&
2990 cd ..
2993 test_expect_success '#21.1: at .git' '
2994 cat >21/.git/expected <<EOF &&
2995 setup: git_dir: .
2996 setup: worktree: (null)
2997 setup: cwd: $here/21/.git
2998 setup: prefix: (null)
3000 test_repo 21/.git
3003 test_expect_success '#21.1: in .git/wt' '
3004 cat >21/.git/wt/expected <<EOF &&
3005 setup: git_dir: $here/21/.git
3006 setup: worktree: (null)
3007 setup: cwd: $here/21/.git/wt
3008 setup: prefix: (null)
3010 test_repo 21/.git/wt
3013 test_expect_success '#21.1: in .git/wt/sub' '
3014 cat >21/.git/wt/sub/expected <<EOF &&
3015 setup: git_dir: $here/21/.git
3016 setup: worktree: (null)
3017 setup: cwd: $here/21/.git/wt/sub
3018 setup: prefix: (null)
3020 test_repo 21/.git/wt/sub
3024 # case #21.2
3026 ############################################################
3028 # Input:
3030 # - GIT_WORK_TREE is set
3031 # - GIT_DIR is not set
3032 # - core.worktree is set
3033 # - .git is a directory
3034 # - core.bare is set
3036 # Output:
3038 # GIT_WORK_TREE/core.worktree are ignored -> #20.2
3040 test_expect_success '#21.2: setup' '
3041 git config --file="$here/21/.git/config" core.bare true
3044 test_expect_success '#21.2: at .git' '
3045 cat >21/.git/expected <<EOF &&
3046 setup: git_dir: .
3047 setup: worktree: (null)
3048 setup: cwd: $here/21/.git
3049 setup: prefix: (null)
3051 test_repo 21/.git
3054 test_expect_success '#21.2: in .git/wt' '
3055 cat >21/.git/wt/expected <<EOF &&
3056 setup: git_dir: $here/21/.git
3057 setup: worktree: (null)
3058 setup: cwd: $here/21/.git/wt
3059 setup: prefix: (null)
3061 test_repo 21/.git/wt
3064 test_expect_success '#21.2: in .git/wt/sub' '
3065 cat >21/.git/wt/sub/expected <<EOF &&
3066 setup: git_dir: $here/21/.git
3067 setup: worktree: (null)
3068 setup: cwd: $here/21/.git/wt/sub
3069 setup: prefix: (null)
3071 test_repo 21/.git/wt/sub
3074 test_expect_success '#21.2: at root' '
3075 cat >21/expected <<EOF &&
3076 setup: git_dir: .git
3077 setup: worktree: (null)
3078 setup: cwd: $here/21
3079 setup: prefix: (null)
3081 test_repo 21
3084 test_expect_success '#21.2: in subdir' '
3085 cat >21/sub/expected <<EOF &&
3086 setup: git_dir: $here/21/.git
3087 setup: worktree: (null)
3088 setup: cwd: $here/21/sub
3089 setup: prefix: (null)
3091 test_repo 21/sub
3095 # case #22.1
3097 ############################################################
3099 # Input:
3101 # - GIT_WORK_TREE is not set
3102 # - GIT_DIR is set
3103 # - core.worktree is set
3104 # - .git is a directory
3105 # - cwd is inside .git
3107 # Output:
3109 # bare attribute is ignored
3111 # - worktree is at core.worktree
3112 # - cwd is at worktree root
3113 # - prefix is calculated
3114 # - git_dir is at $GIT_DIR
3115 # - cwd can be outside worktree
3117 test_expect_success '#22.1: setup' '
3118 sane_unset GIT_DIR GIT_WORK_TREE &&
3119 mkdir 22 &&
3120 cd 22 &&
3121 git init &&
3122 mkdir .git/sub .git/wt .git/wt/sub &&
3123 cd ..
3126 test_expect_success '#22.1: GIT_DIR(rel), core.worktree=. at .git' '
3127 cat >22/.git/expected <<EOF &&
3128 setup: git_dir: .
3129 setup: worktree: $here/22/.git
3130 setup: cwd: $here/22/.git
3131 setup: prefix: (null)
3133 git config --file="$here/22/.git/config" core.worktree "$here/22/.git" &&
3134 test_repo 22/.git .
3137 test_expect_success '#22.1: GIT_DIR(rel), core.worktree=.(rel) at .git' '
3138 cat >22/.git/expected <<EOF &&
3139 setup: git_dir: .
3140 setup: worktree: $here/22/.git
3141 setup: cwd: $here/22/.git
3142 setup: prefix: (null)
3144 git config --file="$here/22/.git/config" core.worktree . &&
3145 test_repo 22/.git .
3148 test_expect_success '#22.1: GIT_DIR, core.worktree=. at .git' '
3149 cat >22/.git/expected <<EOF &&
3150 setup: git_dir: $here/22/.git
3151 setup: worktree: $here/22/.git
3152 setup: cwd: $here/22/.git
3153 setup: prefix: (null)
3155 git config --file="$here/22/.git/config" core.worktree "$here/22/.git" &&
3156 test_repo 22/.git "$here/22/.git"
3159 test_expect_success '#22.1: GIT_DIR, core.worktree=.(rel) at root' '
3160 cat >22/.git/expected <<EOF &&
3161 setup: git_dir: $here/22/.git
3162 setup: worktree: $here/22/.git
3163 setup: cwd: $here/22/.git
3164 setup: prefix: (null)
3166 git config --file="$here/22/.git/config" core.worktree . &&
3167 test_repo 22/.git "$here/22/.git"
3170 test_expect_success '#22.1: GIT_DIR(rel), core.worktree=. in .git/sub' '
3171 cat >22/.git/sub/expected <<EOF &&
3172 setup: git_dir: $here/22/.git
3173 setup: worktree: $here/22/.git
3174 setup: cwd: $here/22/.git
3175 setup: prefix: sub/
3177 git config --file="$here/22/.git/config" core.worktree "$here/22/.git" &&
3178 test_repo 22/.git/sub ..
3181 test_expect_success '#22.1: GIT_DIR(rel), core.worktree=.(rel) in .git/sub' '
3182 cat >22/.git/sub/expected <<EOF &&
3183 setup: git_dir: $here/22/.git
3184 setup: worktree: $here/22/.git
3185 setup: cwd: $here/22/.git
3186 setup: prefix: sub/
3188 git config --file="$here/22/.git/config" core.worktree . &&
3189 test_repo 22/.git/sub/ ..
3192 test_expect_success '#22.1: GIT_DIR, core.worktree=. in .git/sub' '
3193 cat >22/.git/sub/expected <<EOF &&
3194 setup: git_dir: $here/22/.git
3195 setup: worktree: $here/22/.git
3196 setup: cwd: $here/22/.git
3197 setup: prefix: sub/
3199 git config --file="$here/22/.git/config" core.worktree "$here/22/.git" &&
3200 test_repo 22/.git/sub "$here/22/.git"
3203 test_expect_success '#22.1: GIT_DIR, core.worktree=.(rel) in .git/sub' '
3204 cat >22/.git/sub/expected <<EOF &&
3205 setup: git_dir: $here/22/.git
3206 setup: worktree: $here/22/.git
3207 setup: cwd: $here/22/.git
3208 setup: prefix: sub/
3210 git config --file="$here/22/.git/config" core.worktree . &&
3211 test_repo 22/.git/sub "$here/22/.git"
3214 test_expect_success '#22.1: GIT_DIR(rel), core.worktree=wt at .git' '
3215 cat >22/.git/expected <<EOF &&
3216 setup: git_dir: .
3217 setup: worktree: $here/22/.git/wt
3218 setup: cwd: $here/22/.git
3219 setup: prefix: (null)
3221 git config --file="$here/22/.git/config" core.worktree "$here/22/.git/wt" &&
3222 test_repo 22/.git .
3225 test_expect_success '#22.1: GIT_DIR(rel), core.worktree=wt(rel) at .git' '
3226 cat >22/.git/expected <<EOF &&
3227 setup: git_dir: .
3228 setup: worktree: $here/22/.git/wt
3229 setup: cwd: $here/22/.git
3230 setup: prefix: (null)
3232 git config --file="$here/22/.git/config" core.worktree wt &&
3233 test_repo 22/.git .
3236 test_expect_success '#22.1: GIT_DIR, core.worktree=wt(rel) at .git' '
3237 cat >22/.git/expected <<EOF &&
3238 setup: git_dir: $here/22/.git
3239 setup: worktree: $here/22/.git/wt
3240 setup: cwd: $here/22/.git
3241 setup: prefix: (null)
3243 git config --file="$here/22/.git/config" core.worktree wt &&
3244 test_repo 22/.git "$here/22/.git"
3247 test_expect_success '#22.1: GIT_DIR, core.worktree=wt at .git' '
3248 cat >22/.git/expected <<EOF &&
3249 setup: git_dir: $here/22/.git
3250 setup: worktree: $here/22/.git/wt
3251 setup: cwd: $here/22/.git
3252 setup: prefix: (null)
3254 git config --file="$here/22/.git/config" core.worktree "$here/22/.git/wt" &&
3255 test_repo 22/.git "$here/22/.git"
3258 test_expect_success '#22.1: GIT_DIR(rel), core.worktree=wt in .git/sub' '
3259 cat >22/.git/sub/expected <<EOF &&
3260 setup: git_dir: ..
3261 setup: worktree: $here/22/.git/wt
3262 setup: cwd: $here/22/.git/sub
3263 setup: prefix: (null)
3265 git config --file="$here/22/.git/config" core.worktree "$here/22/.git/wt" &&
3266 test_repo 22/.git/sub ..
3269 test_expect_success '#22.1: GIT_DIR(rel), core.worktree=wt(rel) in .git/sub' '
3270 cat >22/.git/sub/expected <<EOF &&
3271 setup: git_dir: ..
3272 setup: worktree: $here/22/.git/wt
3273 setup: cwd: $here/22/.git/sub
3274 setup: prefix: (null)
3276 git config --file="$here/22/.git/config" core.worktree wt &&
3277 test_repo 22/.git/sub ..
3280 test_expect_success '#22.1: GIT_DIR, core.worktree=wt(rel) in .git/sub' '
3281 cat >22/.git/sub/expected <<EOF &&
3282 setup: git_dir: $here/22/.git
3283 setup: worktree: $here/22/.git/wt
3284 setup: cwd: $here/22/.git/sub
3285 setup: prefix: (null)
3287 git config --file="$here/22/.git/config" core.worktree wt &&
3288 test_repo 22/.git/sub "$here/22/.git"
3291 test_expect_success '#22.1: GIT_DIR, core.worktree=wt in .git/sub' '
3292 cat >22/.git/sub/expected <<EOF &&
3293 setup: git_dir: $here/22/.git
3294 setup: worktree: $here/22/.git/wt
3295 setup: cwd: $here/22/.git/sub
3296 setup: prefix: (null)
3298 git config --file="$here/22/.git/config" core.worktree "$here/22/.git/wt" &&
3299 test_repo 22/.git/sub "$here/22/.git"
3302 test_expect_success '#22.1: GIT_DIR(rel), core.worktree=.. at .git' '
3303 cat >22/.git/expected <<EOF &&
3304 setup: git_dir: $here/22/.git
3305 setup: worktree: $here/22
3306 setup: cwd: $here/22
3307 setup: prefix: .git/
3309 git config --file="$here/22/.git/config" core.worktree "$here/22" &&
3310 test_repo 22/.git .
3313 test_expect_success '#22.1: GIT_DIR(rel), core.worktree=..(rel) at .git' '
3314 cat >22/.git/expected <<EOF &&
3315 setup: git_dir: $here/22/.git
3316 setup: worktree: $here/22
3317 setup: cwd: $here/22
3318 setup: prefix: .git/
3320 git config --file="$here/22/.git/config" core.worktree .. &&
3321 test_repo 22/.git .
3324 test_expect_success '#22.1: GIT_DIR, core.worktree=..(rel) at .git' '
3325 cat >22/.git/expected <<EOF &&
3326 setup: git_dir: $here/22/.git
3327 setup: worktree: $here/22
3328 setup: cwd: $here/22
3329 setup: prefix: .git/
3331 git config --file="$here/22/.git/config" core.worktree .. &&
3332 test_repo 22/.git "$here/22/.git"
3335 test_expect_success '#22.1: GIT_DIR, core.worktree=.. at .git' '
3336 cat >22/.git/expected <<EOF &&
3337 setup: git_dir: $here/22/.git
3338 setup: worktree: $here/22
3339 setup: cwd: $here/22
3340 setup: prefix: .git/
3342 git config --file="$here/22/.git/config" core.worktree "$here/22" &&
3343 test_repo 22/.git "$here/22/.git"
3346 test_expect_success '#22.1: GIT_DIR(rel), core.worktree=.. in .git/sub' '
3347 cat >22/.git/sub/expected <<EOF &&
3348 setup: git_dir: $here/22/.git
3349 setup: worktree: $here/22
3350 setup: cwd: $here/22
3351 setup: prefix: .git/sub/
3353 git config --file="$here/22/.git/config" core.worktree "$here/22" &&
3354 test_repo 22/.git/sub ..
3357 test_expect_success '#22.1: GIT_DIR(rel), core.worktree=..(rel) in .git/sub' '
3358 cat >22/.git/sub/expected <<EOF &&
3359 setup: git_dir: $here/22/.git
3360 setup: worktree: $here/22
3361 setup: cwd: $here/22
3362 setup: prefix: .git/sub/
3364 git config --file="$here/22/.git/config" core.worktree .. &&
3365 test_repo 22/.git/sub ..
3368 test_expect_success '#22.1: GIT_DIR, core.worktree=..(rel) in .git/sub' '
3369 cat >22/.git/sub/expected <<EOF &&
3370 setup: git_dir: $here/22/.git
3371 setup: worktree: $here/22
3372 setup: cwd: $here/22
3373 setup: prefix: .git/sub/
3375 git config --file="$here/22/.git/config" core.worktree .. &&
3376 test_repo 22/.git/sub "$here/22/.git"
3379 test_expect_success '#22.1: GIT_DIR, core.worktree=.. in .git/sub' '
3380 cat >22/.git/sub/expected <<EOF &&
3381 setup: git_dir: $here/22/.git
3382 setup: worktree: $here/22
3383 setup: cwd: $here/22
3384 setup: prefix: .git/sub/
3386 git config --file="$here/22/.git/config" core.worktree "$here/22" &&
3387 test_repo 22/.git/sub "$here/22/.git"
3391 # case #22.2
3393 ############################################################
3395 # Input:
3397 # - GIT_WORK_TREE is not set
3398 # - GIT_DIR is set
3399 # - core.worktree is set
3400 # - .git is a directory
3401 # - core.bare is set
3403 # Output:
3405 # core.worktree and core.bare conflict, won't fly.
3407 test_expect_success '#22.2: setup' '
3408 git config --file="$here/22/.git/config" core.bare true
3411 test_expect_success '#22.2: at .git' '
3413 cd 22/.git &&
3414 GIT_DIR=. &&
3415 export GIT_DIR &&
3416 test_must_fail git symbolic-ref HEAD 2>result &&
3417 grep "core.bare and core.worktree do not make sense" result
3421 test_expect_success '#22.2: at root' '
3423 cd 22 &&
3424 GIT_DIR=.git &&
3425 export GIT_DIR &&
3426 test_must_fail git symbolic-ref HEAD 2>result &&
3427 grep "core.bare and core.worktree do not make sense" result
3432 # case #23
3434 ############################################################
3436 # Input:
3438 # - GIT_WORK_TREE is set
3439 # - GIT_DIR is set
3440 # - core.worktree is set
3441 # - .git is a directory
3442 # - core.bare is set
3444 # Output:
3446 # core.worktree is overridden by GIT_WORK_TREE -> #19
3448 test_expect_success '#23: setup' '
3449 sane_unset GIT_DIR GIT_WORK_TREE &&
3450 mkdir 23 23/sub 23/sub/sub 23.wt 23.wt/sub 23/wt 23/wt/sub &&
3451 cd 23 &&
3452 git init &&
3453 git config core.bare true &&
3454 git config core.worktree non-existent &&
3455 cd ..
3458 test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
3459 cat >23/expected <<EOF &&
3460 setup: git_dir: .git
3461 setup: worktree: $here/23
3462 setup: cwd: $here/23
3463 setup: prefix: (null)
3465 test_repo 23 .git "$here/23"
3468 test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
3469 cat >23/expected <<EOF &&
3470 setup: git_dir: .git
3471 setup: worktree: $here/23
3472 setup: cwd: $here/23
3473 setup: prefix: (null)
3475 test_repo 23 .git .
3478 test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=root at root' '
3479 cat >23/expected <<EOF &&
3480 setup: git_dir: $here/23/.git
3481 setup: worktree: $here/23
3482 setup: cwd: $here/23
3483 setup: prefix: (null)
3485 test_repo 23 "$here/23/.git" "$here/23"
3488 test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
3489 cat >23/expected <<EOF &&
3490 setup: git_dir: $here/23/.git
3491 setup: worktree: $here/23
3492 setup: cwd: $here/23
3493 setup: prefix: (null)
3495 test_repo 23 "$here/23/.git" .
3498 test_expect_success '#23: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
3499 cat >23/sub/sub/expected <<EOF &&
3500 setup: git_dir: $here/23/.git
3501 setup: worktree: $here/23
3502 setup: cwd: $here/23
3503 setup: prefix: sub/sub/
3505 test_repo 23/sub/sub ../../.git "$here/23"
3508 test_expect_success '#23: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
3509 cat >23/sub/sub/expected <<EOF &&
3510 setup: git_dir: $here/23/.git
3511 setup: worktree: $here/23
3512 setup: cwd: $here/23
3513 setup: prefix: sub/sub/
3515 test_repo 23/sub/sub ../../.git ../..
3518 test_expect_success '#23: GIT_DIR, GIT_WORKTREE=root in subdir' '
3519 cat >23/sub/expected <<EOF &&
3520 setup: git_dir: $here/23/.git
3521 setup: worktree: $here/23
3522 setup: cwd: $here/23
3523 setup: prefix: sub/
3525 test_repo 23/sub "$here/23/.git" "$here/23"
3528 test_expect_success '#23: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
3529 cat >23/sub/sub/expected <<EOF &&
3530 setup: git_dir: $here/23/.git
3531 setup: worktree: $here/23
3532 setup: cwd: $here/23
3533 setup: prefix: sub/sub/
3535 test_repo 23/sub/sub "$here/23/.git" ../..
3538 test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
3539 cat >23/expected <<EOF &&
3540 setup: git_dir: .git
3541 setup: worktree: $here/23/wt
3542 setup: cwd: $here/23
3543 setup: prefix: (null)
3545 test_repo 23 .git "$here/23/wt"
3548 test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
3549 cat >23/expected <<EOF &&
3550 setup: git_dir: .git
3551 setup: worktree: $here/23/wt
3552 setup: cwd: $here/23
3553 setup: prefix: (null)
3555 test_repo 23 .git wt
3558 test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
3559 cat >23/expected <<EOF &&
3560 setup: git_dir: $here/23/.git
3561 setup: worktree: $here/23/wt
3562 setup: cwd: $here/23
3563 setup: prefix: (null)
3565 test_repo 23 "$here/23/.git" wt
3568 test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt at root' '
3569 cat >23/expected <<EOF &&
3570 setup: git_dir: $here/23/.git
3571 setup: worktree: $here/23/wt
3572 setup: cwd: $here/23
3573 setup: prefix: (null)
3575 test_repo 23 "$here/23/.git" "$here/23/wt"
3578 test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
3579 cat >23/sub/sub/expected <<EOF &&
3580 setup: git_dir: ../../.git
3581 setup: worktree: $here/23/wt
3582 setup: cwd: $here/23/sub/sub
3583 setup: prefix: (null)
3585 test_repo 23/sub/sub ../../.git "$here/23/wt"
3588 test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
3589 cat >23/sub/sub/expected <<EOF &&
3590 setup: git_dir: ../../.git
3591 setup: worktree: $here/23/wt
3592 setup: cwd: $here/23/sub/sub
3593 setup: prefix: (null)
3595 test_repo 23/sub/sub ../../.git ../../wt
3598 test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
3599 cat >23/sub/sub/expected <<EOF &&
3600 setup: git_dir: $here/23/.git
3601 setup: worktree: $here/23/wt
3602 setup: cwd: $here/23/sub/sub
3603 setup: prefix: (null)
3605 test_repo 23/sub/sub "$here/23/.git" ../../wt
3608 test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
3609 cat >23/sub/sub/expected <<EOF &&
3610 setup: git_dir: $here/23/.git
3611 setup: worktree: $here/23/wt
3612 setup: cwd: $here/23/sub/sub
3613 setup: prefix: (null)
3615 test_repo 23/sub/sub "$here/23/.git" "$here/23/wt"
3618 test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
3619 cat >23/expected <<EOF &&
3620 setup: git_dir: $here/23/.git
3621 setup: worktree: $here
3622 setup: cwd: $here
3623 setup: prefix: 23/
3625 test_repo 23 .git "$here"
3628 test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
3629 cat >23/expected <<EOF &&
3630 setup: git_dir: $here/23/.git
3631 setup: worktree: $here
3632 setup: cwd: $here
3633 setup: prefix: 23/
3635 test_repo 23 .git ..
3638 test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
3639 cat >23/expected <<EOF &&
3640 setup: git_dir: $here/23/.git
3641 setup: worktree: $here
3642 setup: cwd: $here
3643 setup: prefix: 23/
3645 test_repo 23 "$here/23/.git" ..
3648 test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=.. at root' '
3649 cat >23/expected <<EOF &&
3650 setup: git_dir: $here/23/.git
3651 setup: worktree: $here
3652 setup: cwd: $here
3653 setup: prefix: 23/
3655 test_repo 23 "$here/23/.git" "$here"
3658 test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
3659 cat >23/sub/sub/expected <<EOF &&
3660 setup: git_dir: $here/23/.git
3661 setup: worktree: $here
3662 setup: cwd: $here
3663 setup: prefix: 23/sub/sub/
3665 test_repo 23/sub/sub ../../.git "$here"
3668 test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
3669 cat >23/sub/sub/expected <<EOF &&
3670 setup: git_dir: $here/23/.git
3671 setup: worktree: $here
3672 setup: cwd: $here
3673 setup: prefix: 23/sub/sub/
3675 test_repo 23/sub/sub ../../.git ../../..
3678 test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
3679 cat >23/sub/sub/expected <<EOF &&
3680 setup: git_dir: $here/23/.git
3681 setup: worktree: $here
3682 setup: cwd: $here
3683 setup: prefix: 23/sub/sub/
3685 test_repo 23/sub/sub "$here/23/.git" ../../../
3688 test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
3689 cat >23/sub/sub/expected <<EOF &&
3690 setup: git_dir: $here/23/.git
3691 setup: worktree: $here
3692 setup: cwd: $here
3693 setup: prefix: 23/sub/sub/
3695 test_repo 23/sub/sub "$here/23/.git" "$here"
3699 # case #24
3701 ############################################################
3703 # Input:
3705 # - GIT_WORK_TREE is not set
3706 # - GIT_DIR is not set
3707 # - core.worktree is not set
3708 # - .git is a file
3709 # - core.bare is set
3711 # Output:
3713 # #16.2 except git_dir is set according to .git file
3715 test_expect_success '#24: setup' '
3716 sane_unset GIT_DIR GIT_WORK_TREE &&
3717 mkdir 24 24/sub &&
3718 cd 24 &&
3719 git init &&
3720 git config core.bare true &&
3721 mv .git ../24.git &&
3722 echo gitdir: ../24.git >.git &&
3723 cd ..
3726 test_expect_success '#24: at root' '
3727 cat >24/expected <<EOF &&
3728 setup: git_dir: $here/24.git
3729 setup: worktree: (null)
3730 setup: cwd: $here/24
3731 setup: prefix: (null)
3733 test_repo 24
3736 test_expect_success '#24: in subdir' '
3737 cat >24/sub/expected <<EOF &&
3738 setup: git_dir: $here/24.git
3739 setup: worktree: (null)
3740 setup: cwd: $here/24/sub
3741 setup: prefix: (null)
3743 test_repo 24/sub
3747 # case #25
3749 ############################################################
3751 # Input:
3753 # - GIT_WORK_TREE is set
3754 # - GIT_DIR is not set
3755 # - core.worktree is not set
3756 # - .git is a file
3757 # - core.bare is set
3759 # Output:
3761 # #17.2 except git_dir is set according to .git file
3763 test_expect_success '#25: setup' '
3764 sane_unset GIT_DIR GIT_WORK_TREE &&
3765 mkdir 25 25/sub &&
3766 cd 25 &&
3767 git init &&
3768 git config core.bare true &&
3769 GIT_WORK_TREE=non-existent &&
3770 export GIT_WORK_TREE &&
3771 mv .git ../25.git &&
3772 echo gitdir: ../25.git >.git &&
3773 cd ..
3776 test_expect_success '#25: at root' '
3777 cat >25/expected <<EOF &&
3778 setup: git_dir: $here/25.git
3779 setup: worktree: (null)
3780 setup: cwd: $here/25
3781 setup: prefix: (null)
3783 test_repo 25
3786 test_expect_success '#25: in subdir' '
3787 cat >25/sub/expected <<EOF &&
3788 setup: git_dir: $here/25.git
3789 setup: worktree: (null)
3790 setup: cwd: $here/25/sub
3791 setup: prefix: (null)
3793 test_repo 25/sub
3797 # case #26
3799 ############################################################
3801 # Input:
3803 # - GIT_WORK_TREE is not set
3804 # - GIT_DIR is set
3805 # - core.worktree is not set
3806 # - .git is a file
3807 # - core.bare is set
3809 # Output:
3811 # #18 except git_dir is set according to .git file
3813 test_expect_success '#26: setup' '
3814 sane_unset GIT_DIR GIT_WORK_TREE &&
3815 mkdir 26 26/sub &&
3816 cd 26 &&
3817 git init &&
3818 git config core.bare true &&
3819 mv .git ../26.git &&
3820 echo gitdir: ../26.git >.git &&
3821 cd ..
3824 test_expect_success '#26: (rel) at root' '
3825 cat >26/expected <<EOF &&
3826 setup: git_dir: $here/26.git
3827 setup: worktree: (null)
3828 setup: cwd: $here/26
3829 setup: prefix: (null)
3831 test_repo 26 .git
3834 test_expect_success '#26: at root' '
3835 cat >26/expected <<EOF &&
3836 setup: git_dir: $here/26.git
3837 setup: worktree: (null)
3838 setup: cwd: $here/26
3839 setup: prefix: (null)
3841 test_repo 26 "$here/26/.git"
3844 test_expect_success '#26: (rel) in subdir' '
3845 cat >26/sub/expected <<EOF &&
3846 setup: git_dir: $here/26.git
3847 setup: worktree: (null)
3848 setup: cwd: $here/26/sub
3849 setup: prefix: (null)
3851 test_repo 26/sub ../.git
3854 test_expect_success '#26: in subdir' '
3855 cat >26/sub/expected <<EOF &&
3856 setup: git_dir: $here/26.git
3857 setup: worktree: (null)
3858 setup: cwd: $here/26/sub
3859 setup: prefix: (null)
3861 test_repo 26/sub "$here/26/.git"
3865 # case #27
3867 ############################################################
3869 # Input:
3871 # - GIT_WORK_TREE is set
3872 # - GIT_DIR is set
3873 # - .git is a file
3874 # - core.worktree is not set
3875 # - core.bare is set
3877 # Output:
3879 # #19 except git_dir is set according to .git file
3881 test_expect_success '#27: setup' '
3882 sane_unset GIT_DIR GIT_WORK_TREE &&
3883 mkdir 27 27/sub 27/sub/sub 27.wt 27.wt/sub 27/wt 27/wt/sub &&
3884 cd 27 &&
3885 git init &&
3886 git config core.bare true &&
3887 mv .git ../27.git &&
3888 echo gitdir: ../27.git >.git &&
3889 cd ..
3892 test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
3893 cat >27/expected <<EOF &&
3894 setup: git_dir: $here/27.git
3895 setup: worktree: $here/27
3896 setup: cwd: $here/27
3897 setup: prefix: (null)
3899 test_repo 27 .git "$here/27"
3902 test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
3903 cat >27/expected <<EOF &&
3904 setup: git_dir: $here/27.git
3905 setup: worktree: $here/27
3906 setup: cwd: $here/27
3907 setup: prefix: (null)
3909 test_repo 27 .git .
3912 test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=root at root' '
3913 cat >27/expected <<EOF &&
3914 setup: git_dir: $here/27.git
3915 setup: worktree: $here/27
3916 setup: cwd: $here/27
3917 setup: prefix: (null)
3919 test_repo 27 "$here/27/.git" "$here/27"
3922 test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
3923 cat >27/expected <<EOF &&
3924 setup: git_dir: $here/27.git
3925 setup: worktree: $here/27
3926 setup: cwd: $here/27
3927 setup: prefix: (null)
3929 test_repo 27 "$here/27/.git" .
3932 test_expect_success '#27: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
3933 cat >27/sub/sub/expected <<EOF &&
3934 setup: git_dir: $here/27.git
3935 setup: worktree: $here/27
3936 setup: cwd: $here/27
3937 setup: prefix: sub/sub/
3939 test_repo 27/sub/sub ../../.git "$here/27"
3942 test_expect_success '#27: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
3943 cat >27/sub/sub/expected <<EOF &&
3944 setup: git_dir: $here/27.git
3945 setup: worktree: $here/27
3946 setup: cwd: $here/27
3947 setup: prefix: sub/sub/
3949 test_repo 27/sub/sub ../../.git ../..
3952 test_expect_success '#27: GIT_DIR, GIT_WORKTREE=root in subdir' '
3953 cat >27/sub/expected <<EOF &&
3954 setup: git_dir: $here/27.git
3955 setup: worktree: $here/27
3956 setup: cwd: $here/27
3957 setup: prefix: sub/
3959 test_repo 27/sub "$here/27/.git" "$here/27"
3962 test_expect_success '#27: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
3963 cat >27/sub/sub/expected <<EOF &&
3964 setup: git_dir: $here/27.git
3965 setup: worktree: $here/27
3966 setup: cwd: $here/27
3967 setup: prefix: sub/sub/
3969 test_repo 27/sub/sub "$here/27/.git" ../..
3972 test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
3973 cat >27/expected <<EOF &&
3974 setup: git_dir: $here/27.git
3975 setup: worktree: $here/27/wt
3976 setup: cwd: $here/27
3977 setup: prefix: (null)
3979 test_repo 27 .git "$here/27/wt"
3982 test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
3983 cat >27/expected <<EOF &&
3984 setup: git_dir: $here/27.git
3985 setup: worktree: $here/27/wt
3986 setup: cwd: $here/27
3987 setup: prefix: (null)
3989 test_repo 27 .git wt
3992 test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
3993 cat >27/expected <<EOF &&
3994 setup: git_dir: $here/27.git
3995 setup: worktree: $here/27/wt
3996 setup: cwd: $here/27
3997 setup: prefix: (null)
3999 test_repo 27 "$here/27/.git" wt
4002 test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=wt at root' '
4003 cat >27/expected <<EOF &&
4004 setup: git_dir: $here/27.git
4005 setup: worktree: $here/27/wt
4006 setup: cwd: $here/27
4007 setup: prefix: (null)
4009 test_repo 27 "$here/27/.git" "$here/27/wt"
4012 test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
4013 cat >27/sub/sub/expected <<EOF &&
4014 setup: git_dir: $here/27.git
4015 setup: worktree: $here/27/wt
4016 setup: cwd: $here/27/sub/sub
4017 setup: prefix: (null)
4019 test_repo 27/sub/sub ../../.git "$here/27/wt"
4022 test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
4023 cat >27/sub/sub/expected <<EOF &&
4024 setup: git_dir: $here/27.git
4025 setup: worktree: $here/27/wt
4026 setup: cwd: $here/27/sub/sub
4027 setup: prefix: (null)
4029 test_repo 27/sub/sub ../../.git ../../wt
4032 test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
4033 cat >27/sub/sub/expected <<EOF &&
4034 setup: git_dir: $here/27.git
4035 setup: worktree: $here/27/wt
4036 setup: cwd: $here/27/sub/sub
4037 setup: prefix: (null)
4039 test_repo 27/sub/sub "$here/27/.git" ../../wt
4042 test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
4043 cat >27/sub/sub/expected <<EOF &&
4044 setup: git_dir: $here/27.git
4045 setup: worktree: $here/27/wt
4046 setup: cwd: $here/27/sub/sub
4047 setup: prefix: (null)
4049 test_repo 27/sub/sub "$here/27/.git" "$here/27/wt"
4052 test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
4053 cat >27/expected <<EOF &&
4054 setup: git_dir: $here/27.git
4055 setup: worktree: $here
4056 setup: cwd: $here
4057 setup: prefix: 27/
4059 test_repo 27 .git "$here"
4062 test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
4063 cat >27/expected <<EOF &&
4064 setup: git_dir: $here/27.git
4065 setup: worktree: $here
4066 setup: cwd: $here
4067 setup: prefix: 27/
4069 test_repo 27 .git ..
4072 test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
4073 cat >27/expected <<EOF &&
4074 setup: git_dir: $here/27.git
4075 setup: worktree: $here
4076 setup: cwd: $here
4077 setup: prefix: 27/
4079 test_repo 27 "$here/27/.git" ..
4082 test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=.. at root' '
4083 cat >27/expected <<EOF &&
4084 setup: git_dir: $here/27.git
4085 setup: worktree: $here
4086 setup: cwd: $here
4087 setup: prefix: 27/
4089 test_repo 27 "$here/27/.git" "$here"
4092 test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
4093 cat >27/sub/sub/expected <<EOF &&
4094 setup: git_dir: $here/27.git
4095 setup: worktree: $here
4096 setup: cwd: $here
4097 setup: prefix: 27/sub/sub/
4099 test_repo 27/sub/sub ../../.git "$here"
4102 test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
4103 cat >27/sub/sub/expected <<EOF &&
4104 setup: git_dir: $here/27.git
4105 setup: worktree: $here
4106 setup: cwd: $here
4107 setup: prefix: 27/sub/sub/
4109 test_repo 27/sub/sub ../../.git ../../..
4112 test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
4113 cat >27/sub/sub/expected <<EOF &&
4114 setup: git_dir: $here/27.git
4115 setup: worktree: $here
4116 setup: cwd: $here
4117 setup: prefix: 27/sub/sub/
4119 test_repo 27/sub/sub "$here/27/.git" ../../../
4122 test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
4123 cat >27/sub/sub/expected <<EOF &&
4124 setup: git_dir: $here/27.git
4125 setup: worktree: $here
4126 setup: cwd: $here
4127 setup: prefix: 27/sub/sub/
4129 test_repo 27/sub/sub "$here/27/.git" "$here"
4133 # case #28
4135 ############################################################
4137 # Input:
4139 # - GIT_WORK_TREE is not set
4140 # - GIT_DIR is not set
4141 # - core.worktree is set
4142 # - .git is a file
4143 # - core.bare is set
4145 # Output:
4147 # core.worktree is ignored -> #24
4149 test_expect_success '#28: setup' '
4150 sane_unset GIT_DIR GIT_WORK_TREE &&
4151 mkdir 28 28/sub &&
4152 cd 28 &&
4153 git init &&
4154 git config core.bare true &&
4155 git config core.worktree non-existent &&
4156 mv .git ../28.git &&
4157 echo gitdir: ../28.git >.git &&
4158 cd ..
4161 test_expect_success '#28: at root' '
4162 cat >28/expected <<EOF &&
4163 setup: git_dir: $here/28.git
4164 setup: worktree: (null)
4165 setup: cwd: $here/28
4166 setup: prefix: (null)
4168 test_repo 28
4171 test_expect_success '#28: in subdir' '
4172 cat >28/sub/expected <<EOF &&
4173 setup: git_dir: $here/28.git
4174 setup: worktree: (null)
4175 setup: cwd: $here/28/sub
4176 setup: prefix: (null)
4178 test_repo 28/sub
4182 # case #29
4184 ############################################################
4186 # Input:
4188 # - GIT_WORK_TREE is set
4189 # - GIT_DIR is not set
4190 # - core.worktree is set
4191 # - .git is a file
4192 # - core.bare is set
4194 # Output:
4196 # GIT_WORK_TREE/core.worktree are ignored -> #28
4198 test_expect_success '#29: setup' '
4199 sane_unset GIT_DIR GIT_WORK_TREE &&
4200 mkdir 29 29/sub &&
4201 cd 29 &&
4202 git init &&
4203 git config core.bare true &&
4204 GIT_WORK_TREE=non-existent &&
4205 export GIT_WORK_TREE &&
4206 mv .git ../29.git &&
4207 echo gitdir: ../29.git >.git &&
4208 cd ..
4211 test_expect_success '#29: at root' '
4212 cat >29/expected <<EOF &&
4213 setup: git_dir: $here/29.git
4214 setup: worktree: (null)
4215 setup: cwd: $here/29
4216 setup: prefix: (null)
4218 test_repo 29
4221 test_expect_success '#29: in subdir' '
4222 cat >29/sub/expected <<EOF &&
4223 setup: git_dir: $here/29.git
4224 setup: worktree: (null)
4225 setup: cwd: $here/29/sub
4226 setup: prefix: (null)
4228 test_repo 29/sub
4232 # case #30
4234 ############################################################
4236 # Input:
4238 # - GIT_WORK_TREE is not set
4239 # - GIT_DIR is set
4240 # - core.worktree is set
4241 # - .git is a file
4242 # - core.bare is set
4244 # Output:
4246 # core.worktree and core.bare conflict, won't fly.
4248 test_expect_success '#30: setup' '
4249 sane_unset GIT_DIR GIT_WORK_TREE &&
4250 mkdir 30 &&
4251 cd 30 &&
4252 git init &&
4253 git config core.bare true &&
4254 git config core.worktree non-existent &&
4255 mv .git ../30.git &&
4256 echo gitdir: ../30.git >.git &&
4257 cd ..
4260 test_expect_success '#30: at root' '
4262 cd 30 &&
4263 GIT_DIR=.git &&
4264 export GIT_DIR &&
4265 test_must_fail git symbolic-ref HEAD 2>result &&
4266 grep "core.bare and core.worktree do not make sense" result
4271 # case #31
4273 ############################################################
4275 # Input:
4277 # - GIT_WORK_TREE is set
4278 # - GIT_DIR is set
4279 # - core.worktree is set
4280 # - .git is a file
4281 # - core.bare is set
4283 # Output:
4285 # #23 except git_dir is set according to .git file
4287 test_expect_success '#31: setup' '
4288 sane_unset GIT_DIR GIT_WORK_TREE &&
4289 mkdir 31 31/sub 31/sub/sub 31.wt 31.wt/sub 31/wt 31/wt/sub &&
4290 cd 31 &&
4291 git init &&
4292 git config core.bare true &&
4293 git config core.worktree non-existent &&
4294 mv .git ../31.git &&
4295 echo gitdir: ../31.git >.git &&
4296 cd ..
4299 test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
4300 cat >31/expected <<EOF &&
4301 setup: git_dir: $here/31.git
4302 setup: worktree: $here/31
4303 setup: cwd: $here/31
4304 setup: prefix: (null)
4306 test_repo 31 .git "$here/31"
4309 test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
4310 cat >31/expected <<EOF &&
4311 setup: git_dir: $here/31.git
4312 setup: worktree: $here/31
4313 setup: cwd: $here/31
4314 setup: prefix: (null)
4316 test_repo 31 .git .
4319 test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=root at root' '
4320 cat >31/expected <<EOF &&
4321 setup: git_dir: $here/31.git
4322 setup: worktree: $here/31
4323 setup: cwd: $here/31
4324 setup: prefix: (null)
4326 test_repo 31 "$here/31/.git" "$here/31"
4329 test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
4330 cat >31/expected <<EOF &&
4331 setup: git_dir: $here/31.git
4332 setup: worktree: $here/31
4333 setup: cwd: $here/31
4334 setup: prefix: (null)
4336 test_repo 31 "$here/31/.git" .
4339 test_expect_success '#31: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
4340 cat >31/sub/sub/expected <<EOF &&
4341 setup: git_dir: $here/31.git
4342 setup: worktree: $here/31
4343 setup: cwd: $here/31
4344 setup: prefix: sub/sub/
4346 test_repo 31/sub/sub ../../.git "$here/31"
4349 test_expect_success '#31: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
4350 cat >31/sub/sub/expected <<EOF &&
4351 setup: git_dir: $here/31.git
4352 setup: worktree: $here/31
4353 setup: cwd: $here/31
4354 setup: prefix: sub/sub/
4356 test_repo 31/sub/sub ../../.git ../..
4359 test_expect_success '#31: GIT_DIR, GIT_WORKTREE=root in subdir' '
4360 cat >31/sub/expected <<EOF &&
4361 setup: git_dir: $here/31.git
4362 setup: worktree: $here/31
4363 setup: cwd: $here/31
4364 setup: prefix: sub/
4366 test_repo 31/sub "$here/31/.git" "$here/31"
4369 test_expect_success '#31: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
4370 cat >31/sub/sub/expected <<EOF &&
4371 setup: git_dir: $here/31.git
4372 setup: worktree: $here/31
4373 setup: cwd: $here/31
4374 setup: prefix: sub/sub/
4376 test_repo 31/sub/sub "$here/31/.git" ../..
4379 test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
4380 cat >31/expected <<EOF &&
4381 setup: git_dir: $here/31.git
4382 setup: worktree: $here/31/wt
4383 setup: cwd: $here/31
4384 setup: prefix: (null)
4386 test_repo 31 .git "$here/31/wt"
4389 test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
4390 cat >31/expected <<EOF &&
4391 setup: git_dir: $here/31.git
4392 setup: worktree: $here/31/wt
4393 setup: cwd: $here/31
4394 setup: prefix: (null)
4396 test_repo 31 .git wt
4399 test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
4400 cat >31/expected <<EOF &&
4401 setup: git_dir: $here/31.git
4402 setup: worktree: $here/31/wt
4403 setup: cwd: $here/31
4404 setup: prefix: (null)
4406 test_repo 31 "$here/31/.git" wt
4409 test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=wt at root' '
4410 cat >31/expected <<EOF &&
4411 setup: git_dir: $here/31.git
4412 setup: worktree: $here/31/wt
4413 setup: cwd: $here/31
4414 setup: prefix: (null)
4416 test_repo 31 "$here/31/.git" "$here/31/wt"
4419 test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
4420 cat >31/sub/sub/expected <<EOF &&
4421 setup: git_dir: $here/31.git
4422 setup: worktree: $here/31/wt
4423 setup: cwd: $here/31/sub/sub
4424 setup: prefix: (null)
4426 test_repo 31/sub/sub ../../.git "$here/31/wt"
4429 test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
4430 cat >31/sub/sub/expected <<EOF &&
4431 setup: git_dir: $here/31.git
4432 setup: worktree: $here/31/wt
4433 setup: cwd: $here/31/sub/sub
4434 setup: prefix: (null)
4436 test_repo 31/sub/sub ../../.git ../../wt
4439 test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
4440 cat >31/sub/sub/expected <<EOF &&
4441 setup: git_dir: $here/31.git
4442 setup: worktree: $here/31/wt
4443 setup: cwd: $here/31/sub/sub
4444 setup: prefix: (null)
4446 test_repo 31/sub/sub "$here/31/.git" ../../wt
4449 test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
4450 cat >31/sub/sub/expected <<EOF &&
4451 setup: git_dir: $here/31.git
4452 setup: worktree: $here/31/wt
4453 setup: cwd: $here/31/sub/sub
4454 setup: prefix: (null)
4456 test_repo 31/sub/sub "$here/31/.git" "$here/31/wt"
4459 test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
4460 cat >31/expected <<EOF &&
4461 setup: git_dir: $here/31.git
4462 setup: worktree: $here
4463 setup: cwd: $here
4464 setup: prefix: 31/
4466 test_repo 31 .git "$here"
4469 test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
4470 cat >31/expected <<EOF &&
4471 setup: git_dir: $here/31.git
4472 setup: worktree: $here
4473 setup: cwd: $here
4474 setup: prefix: 31/
4476 test_repo 31 .git ..
4479 test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
4480 cat >31/expected <<EOF &&
4481 setup: git_dir: $here/31.git
4482 setup: worktree: $here
4483 setup: cwd: $here
4484 setup: prefix: 31/
4486 test_repo 31 "$here/31/.git" ..
4489 test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=.. at root' '
4490 cat >31/expected <<EOF &&
4491 setup: git_dir: $here/31.git
4492 setup: worktree: $here
4493 setup: cwd: $here
4494 setup: prefix: 31/
4496 test_repo 31 "$here/31/.git" "$here"
4499 test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
4500 cat >31/sub/sub/expected <<EOF &&
4501 setup: git_dir: $here/31.git
4502 setup: worktree: $here
4503 setup: cwd: $here
4504 setup: prefix: 31/sub/sub/
4506 test_repo 31/sub/sub ../../.git "$here"
4509 test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
4510 cat >31/sub/sub/expected <<EOF &&
4511 setup: git_dir: $here/31.git
4512 setup: worktree: $here
4513 setup: cwd: $here
4514 setup: prefix: 31/sub/sub/
4516 test_repo 31/sub/sub ../../.git ../../..
4519 test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
4520 cat >31/sub/sub/expected <<EOF &&
4521 setup: git_dir: $here/31.git
4522 setup: worktree: $here
4523 setup: cwd: $here
4524 setup: prefix: 31/sub/sub/
4526 test_repo 31/sub/sub "$here/31/.git" ../../../
4529 test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
4530 cat >31/sub/sub/expected <<EOF &&
4531 setup: git_dir: $here/31.git
4532 setup: worktree: $here
4533 setup: cwd: $here
4534 setup: prefix: 31/sub/sub/
4536 test_repo 31/sub/sub "$here/31/.git" "$here"
4539 test_done