Fix expected values of setup tests on Windows
[git/jnareb-git.git] / t / t1510-repo-setup.sh
blobe9c451cc585dca951e55c51ab25634ad5acd55d4
1 #!/bin/sh
3 test_description='Tests of cwd/prefix/worktree/gitdir setup in all cases'
5 . ./test-lib.sh
8 # A few rules for repo setup:
10 # 1. GIT_DIR is relative to user's cwd. --git-dir is equivalent to
11 # GIT_DIR.
13 # 2. .git file is relative to parent directory. .git file is basically
14 # symlink in disguise. The directory where .git file points to will
15 # become new git_dir.
17 # 3. core.worktree is relative to git_dir.
19 # 4. GIT_WORK_TREE is relative to user's cwd. --work-tree is
20 # equivalent to GIT_WORK_TREE.
22 # 5. GIT_WORK_TREE/core.worktree is only effective if GIT_DIR is set
23 # Uneffective worktree settings should be warned.
25 # 6. Effective GIT_WORK_TREE overrides core.worktree and core.bare
27 # 7. Effective core.worktree conflicts with core.bare
29 # 8. If GIT_DIR is set but neither worktree nor bare setting is given,
30 # original cwd becomes worktree.
32 # 9. If .git discovery is done inside a repo, the repo becomes a bare
33 # repo. .git discovery is performed if GIT_DIR is not set.
35 # 10. If no worktree is available, cwd remains unchanged, prefix is
36 # NULL.
38 # 11. When user's cwd is outside worktree, cwd remains unchanged,
39 # prefix is NULL.
42 test_repo() {
44 cd "$1" &&
45 if test -n "$2"; then GIT_DIR="$2" && export GIT_DIR; fi &&
46 if test -n "$3"; then GIT_WORK_TREE="$3" && export GIT_WORK_TREE; fi &&
47 rm -f trace &&
48 GIT_TRACE="`pwd`/trace" git symbolic-ref HEAD >/dev/null &&
49 grep '^setup: ' trace >result &&
50 test_cmp expected result
54 # Bit 0 = GIT_WORK_TREE
55 # Bit 1 = GIT_DIR
56 # Bit 2 = core.worktree
57 # Bit 3 = .git is a file
58 # Bit 4 = bare repo
59 # Case# = encoding of the above 5 bits
62 # Case #0
64 ############################################################
66 # Input:
68 # - GIT_WORK_TREE is not set
69 # - GIT_DIR is not set
70 # - core.worktree is not set
71 # - .git is a directory
72 # - core.bare is not set, cwd is outside .git
74 # Output:
76 # - worktree is .git's parent directory
77 # - cwd is at worktree root dir
78 # - prefix is calculated
79 # - git_dir is set to ".git"
80 # - cwd can't be outside worktree
82 test_expect_success '#0: setup' '
83 sane_unset GIT_DIR GIT_WORK_TREE &&
84 mkdir 0 0/sub &&
85 (cd 0 && git init) &&
86 here=$(pwd)
89 test_expect_success '#0: at root' '
90 cat >0/expected <<EOF &&
91 setup: git_dir: .git
92 setup: worktree: $here/0
93 setup: cwd: $here/0
94 setup: prefix: (null)
95 EOF
96 test_repo 0
99 test_expect_success '#0: in subdir' '
100 cat >0/sub/expected <<EOF &&
101 setup: git_dir: .git
102 setup: worktree: $here/0
103 setup: cwd: $here/0
104 setup: prefix: sub/
106 test_repo 0/sub
110 # case #1
112 ############################################################
114 # Input:
116 # - GIT_WORK_TREE is set
117 # - GIT_DIR is not set
118 # - core.worktree is not set
119 # - .git is a directory
120 # - core.bare is not set, cwd is outside .git
122 # Output:
124 # GIT_WORK_TREE is ignored -> #0
126 test_expect_success '#1: setup' '
127 sane_unset GIT_DIR GIT_WORK_TREE &&
128 mkdir 1 1/sub 1.wt 1.wt/sub 1/wt 1/wt/sub &&
129 cd 1 &&
130 git init &&
131 GIT_WORK_TREE=non-existent &&
132 export GIT_WORK_TREE &&
133 cd ..
136 test_expect_success '#1: at root' '
137 cat >1/expected <<EOF &&
138 setup: git_dir: .git
139 setup: worktree: $here/1
140 setup: cwd: $here/1
141 setup: prefix: (null)
143 test_repo 1
146 test_expect_success '#1: in subdir' '
147 cat >1/sub/expected <<EOF &&
148 setup: git_dir: .git
149 setup: worktree: $here/1
150 setup: cwd: $here/1
151 setup: prefix: sub/
153 test_repo 1/sub
157 # case #2
159 ############################################################
161 # Input:
163 # - GIT_WORK_TREE is not set
164 # - GIT_DIR is set
165 # - core.worktree is not set
166 # - .git is a directory
167 # - core.bare is not set, cwd is outside .git
169 # Output:
171 # - worktree is at original cwd
172 # - cwd is unchanged
173 # - prefix is NULL
174 # - git_dir is set to $GIT_DIR
175 # - cwd can't be outside worktree
177 test_expect_success '#2: setup' '
178 sane_unset GIT_DIR GIT_WORK_TREE &&
179 mkdir 2 2/sub &&
180 cd 2 && git init && cd ..
183 test_expect_success '#2: at root' '
184 cat >2/expected <<EOF &&
185 setup: git_dir: $here/2/.git
186 setup: worktree: $here/2
187 setup: cwd: $here/2
188 setup: prefix: (null)
190 test_repo 2 "$here/2/.git"
193 test_expect_success '#2: in subdir' '
194 cat >2/sub/expected <<EOF &&
195 setup: git_dir: $here/2/.git
196 setup: worktree: $here/2/sub
197 setup: cwd: $here/2/sub
198 setup: prefix: (null)
200 test_repo 2/sub "$here/2/.git"
203 test_expect_success '#2: relative GIT_DIR at root' '
204 cat >2/expected <<EOF &&
205 setup: git_dir: .git
206 setup: worktree: $here/2
207 setup: cwd: $here/2
208 setup: prefix: (null)
210 test_repo 2 .git
213 test_expect_success '#2: relative GIT_DIR in subdir' '
214 cat >2/sub/expected <<EOF &&
215 setup: git_dir: ../.git
216 setup: worktree: $here/2/sub
217 setup: cwd: $here/2/sub
218 setup: prefix: (null)
220 test_repo 2/sub ../.git
224 # case #3
226 ############################################################
228 # Input:
230 # - GIT_WORK_TREE is set
231 # - GIT_DIR is set
232 # - core.worktree is not set
233 # - .git is a directory
234 # - core.bare is not set, cwd is outside .git
236 # Output:
238 # - worktree is set to $GIT_WORK_TREE
239 # - cwd is at worktree root
240 # - prefix is calculated
241 # - git_dir is set to $GIT_DIR
242 # - cwd can be outside worktree
244 test_expect_success '#3: setup' '
245 sane_unset GIT_DIR GIT_WORK_TREE &&
246 mkdir 3 3/sub 3/sub/sub 3.wt 3.wt/sub 3/wt 3/wt/sub &&
247 cd 3 && git init && cd ..
250 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
251 cat >3/expected <<EOF &&
252 setup: git_dir: .git
253 setup: worktree: $here/3
254 setup: cwd: $here/3
255 setup: prefix: (null)
257 test_repo 3 .git "$here/3"
260 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
261 cat >3/expected <<EOF &&
262 setup: git_dir: .git
263 setup: worktree: $here/3
264 setup: cwd: $here/3
265 setup: prefix: (null)
267 test_repo 3 .git .
270 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=root at root' '
271 cat >3/expected <<EOF &&
272 setup: git_dir: $here/3/.git
273 setup: worktree: $here/3
274 setup: cwd: $here/3
275 setup: prefix: (null)
277 test_repo 3 "$here/3/.git" "$here/3"
280 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
281 cat >3/expected <<EOF &&
282 setup: git_dir: $here/3/.git
283 setup: worktree: $here/3
284 setup: cwd: $here/3
285 setup: prefix: (null)
287 test_repo 3 "$here/3/.git" .
290 test_expect_success '#3: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
291 cat >3/sub/sub/expected <<EOF &&
292 setup: git_dir: $here/3/.git
293 setup: worktree: $here/3
294 setup: cwd: $here/3
295 setup: prefix: sub/sub/
297 test_repo 3/sub/sub ../../.git "$here/3"
300 test_expect_success '#3: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
301 cat >3/sub/sub/expected <<EOF &&
302 setup: git_dir: $here/3/.git
303 setup: worktree: $here/3
304 setup: cwd: $here/3
305 setup: prefix: sub/sub/
307 test_repo 3/sub/sub ../../.git ../..
310 test_expect_success '#3: GIT_DIR, GIT_WORKTREE=root in subdir' '
311 cat >3/sub/expected <<EOF &&
312 setup: git_dir: $here/3/.git
313 setup: worktree: $here/3
314 setup: cwd: $here/3
315 setup: prefix: sub/
317 test_repo 3/sub "$here/3/.git" "$here/3"
320 test_expect_success '#3: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
321 cat >3/sub/sub/expected <<EOF &&
322 setup: git_dir: $here/3/.git
323 setup: worktree: $here/3
324 setup: cwd: $here/3
325 setup: prefix: sub/sub/
327 test_repo 3/sub/sub "$here/3/.git" ../..
330 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
331 cat >3/expected <<EOF &&
332 setup: git_dir: .git
333 setup: worktree: $here/3/wt
334 setup: cwd: $here/3
335 setup: prefix: (null)
337 test_repo 3 .git "$here/3/wt"
340 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
341 cat >3/expected <<EOF &&
342 setup: git_dir: .git
343 setup: worktree: $here/3/wt
344 setup: cwd: $here/3
345 setup: prefix: (null)
347 test_repo 3 .git wt
350 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
351 cat >3/expected <<EOF &&
352 setup: git_dir: $here/3/.git
353 setup: worktree: $here/3/wt
354 setup: cwd: $here/3
355 setup: prefix: (null)
357 test_repo 3 "$here/3/.git" wt
360 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=wt at root' '
361 cat >3/expected <<EOF &&
362 setup: git_dir: $here/3/.git
363 setup: worktree: $here/3/wt
364 setup: cwd: $here/3
365 setup: prefix: (null)
367 test_repo 3 "$here/3/.git" "$here/3/wt"
370 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
371 cat >3/sub/sub/expected <<EOF &&
372 setup: git_dir: ../../.git
373 setup: worktree: $here/3/wt
374 setup: cwd: $here/3/sub/sub
375 setup: prefix: (null)
377 test_repo 3/sub/sub ../../.git "$here/3/wt"
380 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
381 cat >3/sub/sub/expected <<EOF &&
382 setup: git_dir: ../../.git
383 setup: worktree: $here/3/wt
384 setup: cwd: $here/3/sub/sub
385 setup: prefix: (null)
387 test_repo 3/sub/sub ../../.git ../../wt
390 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
391 cat >3/sub/sub/expected <<EOF &&
392 setup: git_dir: $here/3/.git
393 setup: worktree: $here/3/wt
394 setup: cwd: $here/3/sub/sub
395 setup: prefix: (null)
397 test_repo 3/sub/sub "$here/3/.git" ../../wt
400 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
401 cat >3/sub/sub/expected <<EOF &&
402 setup: git_dir: $here/3/.git
403 setup: worktree: $here/3/wt
404 setup: cwd: $here/3/sub/sub
405 setup: prefix: (null)
407 test_repo 3/sub/sub "$here/3/.git" "$here/3/wt"
410 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
411 cat >3/expected <<EOF &&
412 setup: git_dir: $here/3/.git
413 setup: worktree: $here
414 setup: cwd: $here
415 setup: prefix: 3/
417 test_repo 3 .git "$here"
420 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
421 cat >3/expected <<EOF &&
422 setup: git_dir: $here/3/.git
423 setup: worktree: $here
424 setup: cwd: $here
425 setup: prefix: 3/
427 test_repo 3 .git ..
430 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
431 cat >3/expected <<EOF &&
432 setup: git_dir: $here/3/.git
433 setup: worktree: $here
434 setup: cwd: $here
435 setup: prefix: 3/
437 test_repo 3 "$here/3/.git" ..
440 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=.. at root' '
441 cat >3/expected <<EOF &&
442 setup: git_dir: $here/3/.git
443 setup: worktree: $here
444 setup: cwd: $here
445 setup: prefix: 3/
447 test_repo 3 "$here/3/.git" "$here"
450 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
451 cat >3/sub/sub/expected <<EOF &&
452 setup: git_dir: $here/3/.git
453 setup: worktree: $here
454 setup: cwd: $here
455 setup: prefix: 3/sub/sub/
457 test_repo 3/sub/sub ../../.git "$here"
460 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
461 cat >3/sub/sub/expected <<EOF &&
462 setup: git_dir: $here/3/.git
463 setup: worktree: $here
464 setup: cwd: $here
465 setup: prefix: 3/sub/sub/
467 test_repo 3/sub/sub ../../.git ../../..
470 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
471 cat >3/sub/sub/expected <<EOF &&
472 setup: git_dir: $here/3/.git
473 setup: worktree: $here
474 setup: cwd: $here
475 setup: prefix: 3/sub/sub/
477 test_repo 3/sub/sub "$here/3/.git" ../../../
480 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
481 cat >3/sub/sub/expected <<EOF &&
482 setup: git_dir: $here/3/.git
483 setup: worktree: $here
484 setup: cwd: $here
485 setup: prefix: 3/sub/sub/
487 test_repo 3/sub/sub "$here/3/.git" "$here"
491 # case #4
493 ############################################################
495 # Input:
497 # - GIT_WORK_TREE is not set
498 # - GIT_DIR is not set
499 # - core.worktree is set
500 # - .git is a directory
501 # - core.bare is not set, cwd is outside .git
503 # Output:
505 # core.worktree is ignored -> #0
507 test_expect_success '#4: setup' '
508 sane_unset GIT_DIR GIT_WORK_TREE &&
509 mkdir 4 4/sub &&
510 cd 4 &&
511 git init &&
512 git config core.worktree non-existent &&
513 cd ..
516 test_expect_success '#4: at root' '
517 cat >4/expected <<EOF &&
518 setup: git_dir: .git
519 setup: worktree: $here/4
520 setup: cwd: $here/4
521 setup: prefix: (null)
523 test_repo 4
526 test_expect_success '#4: in subdir' '
527 cat >4/sub/expected <<EOF &&
528 setup: git_dir: .git
529 setup: worktree: $here/4
530 setup: cwd: $here/4
531 setup: prefix: sub/
533 test_repo 4/sub
537 # case #5
539 ############################################################
541 # Input:
543 # - GIT_WORK_TREE is set
544 # - GIT_DIR is not set
545 # - core.worktree is set
546 # - .git is a directory
547 # - core.bare is not set, cwd is outside .git
549 # Output:
551 # GIT_WORK_TREE/core.worktree are ignored -> #0
553 test_expect_success '#5: setup' '
554 sane_unset GIT_DIR GIT_WORK_TREE &&
555 mkdir 5 5/sub &&
556 cd 5 &&
557 git init &&
558 git config core.worktree non-existent &&
559 GIT_WORK_TREE=non-existent-too &&
560 export GIT_WORK_TREE &&
561 cd ..
564 test_expect_success '#5: at root' '
565 cat >5/expected <<EOF &&
566 setup: git_dir: .git
567 setup: worktree: $here/5
568 setup: cwd: $here/5
569 setup: prefix: (null)
571 test_repo 5
574 test_expect_success '#5: in subdir' '
575 cat >5/sub/expected <<EOF &&
576 setup: git_dir: .git
577 setup: worktree: $here/5
578 setup: cwd: $here/5
579 setup: prefix: sub/
581 test_repo 5/sub
585 # case #6
587 ############################################################
589 # Input:
591 # - GIT_WORK_TREE is not set
592 # - GIT_DIR is set
593 # - core.worktree is set
594 # - .git is a directory
595 # - core.bare is not set, cwd is outside .git
597 # Output:
599 # - worktree is at core.worktree
600 # - cwd is at worktree root
601 # - prefix is calculated
602 # - git_dir is at $GIT_DIR
603 # - cwd can be outside worktree
605 test_expect_success '#6: setup' '
606 sane_unset GIT_DIR GIT_WORK_TREE &&
607 mkdir 6 6/sub 6/sub/sub 6.wt 6.wt/sub 6/wt 6/wt/sub &&
608 cd 6 && git init && cd ..
611 test_expect_success '#6: GIT_DIR(rel), core.worktree=.. at root' '
612 cat >6/expected <<EOF &&
613 setup: git_dir: .git
614 setup: worktree: $here/6
615 setup: cwd: $here/6
616 setup: prefix: (null)
618 git config --file="$here/6/.git/config" core.worktree "$here/6" &&
619 test_repo 6 .git
622 test_expect_success '#6: GIT_DIR(rel), core.worktree=..(rel) at root' '
623 cat >6/expected <<EOF &&
624 setup: git_dir: .git
625 setup: worktree: $here/6
626 setup: cwd: $here/6
627 setup: prefix: (null)
629 git config --file="$here/6/.git/config" core.worktree .. &&
630 test_repo 6 .git
633 test_expect_success '#6: GIT_DIR, core.worktree=.. at root' '
634 cat >6/expected <<EOF &&
635 setup: git_dir: $here/6/.git
636 setup: worktree: $here/6
637 setup: cwd: $here/6
638 setup: prefix: (null)
640 git config --file="$here/6/.git/config" core.worktree "$here/6" &&
641 test_repo 6 "$here/6/.git"
644 test_expect_success '#6: GIT_DIR, core.worktree=..(rel) at root' '
645 cat >6/expected <<EOF &&
646 setup: git_dir: $here/6/.git
647 setup: worktree: $here/6
648 setup: cwd: $here/6
649 setup: prefix: (null)
651 git config --file="$here/6/.git/config" core.worktree .. &&
652 test_repo 6 "$here/6/.git"
655 test_expect_success '#6: GIT_DIR(rel), core.worktree=.. in subdir' '
656 cat >6/sub/sub/expected <<EOF &&
657 setup: git_dir: $here/6/.git
658 setup: worktree: $here/6
659 setup: cwd: $here/6
660 setup: prefix: sub/sub/
662 git config --file="$here/6/.git/config" core.worktree "$here/6" &&
663 test_repo 6/sub/sub ../../.git
666 test_expect_success '#6: GIT_DIR(rel), core.worktree=..(rel) in subdir' '
667 cat >6/sub/sub/expected <<EOF &&
668 setup: git_dir: $here/6/.git
669 setup: worktree: $here/6
670 setup: cwd: $here/6
671 setup: prefix: sub/sub/
673 git config --file="$here/6/.git/config" core.worktree .. &&
674 test_repo 6/sub/sub ../../.git
677 test_expect_success '#6: GIT_DIR, core.worktree=.. in subdir' '
678 cat >6/sub/expected <<EOF &&
679 setup: git_dir: $here/6/.git
680 setup: worktree: $here/6
681 setup: cwd: $here/6
682 setup: prefix: sub/
684 git config --file="$here/6/.git/config" core.worktree "$here/6" &&
685 test_repo 6/sub "$here/6/.git"
688 test_expect_success '#6: GIT_DIR, core.worktree=..(rel) in subdir' '
689 cat >6/sub/sub/expected <<EOF &&
690 setup: git_dir: $here/6/.git
691 setup: worktree: $here/6
692 setup: cwd: $here/6
693 setup: prefix: sub/sub/
695 git config --file="$here/6/.git/config" core.worktree .. &&
696 test_repo 6/sub/sub "$here/6/.git"
699 test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt at root' '
700 cat >6/expected <<EOF &&
701 setup: git_dir: .git
702 setup: worktree: $here/6/wt
703 setup: cwd: $here/6
704 setup: prefix: (null)
706 git config --file="$here/6/.git/config" core.worktree "$here/6/wt" &&
707 test_repo 6 .git
710 test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt(rel) at root' '
711 cat >6/expected <<EOF &&
712 setup: git_dir: .git
713 setup: worktree: $here/6/wt
714 setup: cwd: $here/6
715 setup: prefix: (null)
717 git config --file="$here/6/.git/config" core.worktree ../wt &&
718 test_repo 6 .git
721 test_expect_success '#6: GIT_DIR, core.worktree=../wt(rel) at root' '
722 cat >6/expected <<EOF &&
723 setup: git_dir: $here/6/.git
724 setup: worktree: $here/6/wt
725 setup: cwd: $here/6
726 setup: prefix: (null)
728 git config --file="$here/6/.git/config" core.worktree ../wt &&
729 test_repo 6 "$here/6/.git"
732 test_expect_success '#6: GIT_DIR, core.worktree=../wt at root' '
733 cat >6/expected <<EOF &&
734 setup: git_dir: $here/6/.git
735 setup: worktree: $here/6/wt
736 setup: cwd: $here/6
737 setup: prefix: (null)
739 git config --file="$here/6/.git/config" core.worktree "$here/6/wt" &&
740 test_repo 6 "$here/6/.git"
743 test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt in subdir' '
744 cat >6/sub/sub/expected <<EOF &&
745 setup: git_dir: ../../.git
746 setup: worktree: $here/6/wt
747 setup: cwd: $here/6/sub/sub
748 setup: prefix: (null)
750 git config --file="$here/6/.git/config" core.worktree "$here/6/wt" &&
751 test_repo 6/sub/sub ../../.git
754 test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt(rel) in subdir' '
755 cat >6/sub/sub/expected <<EOF &&
756 setup: git_dir: ../../.git
757 setup: worktree: $here/6/wt
758 setup: cwd: $here/6/sub/sub
759 setup: prefix: (null)
761 git config --file="$here/6/.git/config" core.worktree ../wt &&
762 test_repo 6/sub/sub ../../.git
765 test_expect_success '#6: GIT_DIR, core.worktree=../wt(rel) in subdir' '
766 cat >6/sub/sub/expected <<EOF &&
767 setup: git_dir: $here/6/.git
768 setup: worktree: $here/6/wt
769 setup: cwd: $here/6/sub/sub
770 setup: prefix: (null)
772 git config --file="$here/6/.git/config" core.worktree ../wt &&
773 test_repo 6/sub/sub "$here/6/.git"
776 test_expect_success '#6: GIT_DIR, core.worktree=../wt in subdir' '
777 cat >6/sub/sub/expected <<EOF &&
778 setup: git_dir: $here/6/.git
779 setup: worktree: $here/6/wt
780 setup: cwd: $here/6/sub/sub
781 setup: prefix: (null)
783 git config --file="$here/6/.git/config" core.worktree "$here/6/wt" &&
784 test_repo 6/sub/sub "$here/6/.git"
787 test_expect_success '#6: GIT_DIR(rel), core.worktree=../.. at root' '
788 cat >6/expected <<EOF &&
789 setup: git_dir: $here/6/.git
790 setup: worktree: $here
791 setup: cwd: $here
792 setup: prefix: 6/
794 git config --file="$here/6/.git/config" core.worktree "$here" &&
795 test_repo 6 .git
798 test_expect_success '#6: GIT_DIR(rel), core.worktree=../..(rel) at root' '
799 cat >6/expected <<EOF &&
800 setup: git_dir: $here/6/.git
801 setup: worktree: $here
802 setup: cwd: $here
803 setup: prefix: 6/
805 git config --file="$here/6/.git/config" core.worktree ../../ &&
806 test_repo 6 .git
809 test_expect_success '#6: GIT_DIR, core.worktree=../..(rel) at root' '
810 cat >6/expected <<EOF &&
811 setup: git_dir: $here/6/.git
812 setup: worktree: $here
813 setup: cwd: $here
814 setup: prefix: 6/
816 git config --file="$here/6/.git/config" core.worktree ../../ &&
817 test_repo 6 "$here/6/.git"
820 test_expect_success '#6: GIT_DIR, core.worktree=../.. at root' '
821 cat >6/expected <<EOF &&
822 setup: git_dir: $here/6/.git
823 setup: worktree: $here
824 setup: cwd: $here
825 setup: prefix: 6/
827 git config --file="$here/6/.git/config" core.worktree "$here" &&
828 test_repo 6 "$here/6/.git"
831 test_expect_success '#6: GIT_DIR(rel), core.worktree=../.. in subdir' '
832 cat >6/sub/sub/expected <<EOF &&
833 setup: git_dir: $here/6/.git
834 setup: worktree: $here
835 setup: cwd: $here
836 setup: prefix: 6/sub/sub/
838 git config --file="$here/6/.git/config" core.worktree "$here" &&
839 test_repo 6/sub/sub ../../.git
842 test_expect_success '#6: GIT_DIR(rel), core.worktree=../..(rel) in subdir' '
843 cat >6/sub/sub/expected <<EOF &&
844 setup: git_dir: $here/6/.git
845 setup: worktree: $here
846 setup: cwd: $here
847 setup: prefix: 6/sub/sub/
849 git config --file="$here/6/.git/config" core.worktree ../.. &&
850 test_repo 6/sub/sub ../../.git
853 test_expect_success '#6: GIT_DIR, core.worktree=../..(rel) in subdir' '
854 cat >6/sub/sub/expected <<EOF &&
855 setup: git_dir: $here/6/.git
856 setup: worktree: $here
857 setup: cwd: $here
858 setup: prefix: 6/sub/sub/
860 git config --file="$here/6/.git/config" core.worktree ../.. &&
861 test_repo 6/sub/sub "$here/6/.git"
864 test_expect_success '#6: GIT_DIR, core.worktree=../.. in subdir' '
865 cat >6/sub/sub/expected <<EOF &&
866 setup: git_dir: $here/6/.git
867 setup: worktree: $here
868 setup: cwd: $here
869 setup: prefix: 6/sub/sub/
871 git config --file="$here/6/.git/config" core.worktree "$here" &&
872 test_repo 6/sub/sub "$here/6/.git"
876 # case #7
878 ############################################################
880 # Input:
882 # - GIT_WORK_TREE is set
883 # - GIT_DIR is set
884 # - core.worktree is set
885 # - .git is a directory
886 # - core.bare is not set, cwd is outside .git
888 # Output:
890 # core.worktree is overridden by GIT_WORK_TREE -> #3
892 test_expect_success '#7: setup' '
893 sane_unset GIT_DIR GIT_WORK_TREE &&
894 mkdir 7 7/sub 7/sub/sub 7.wt 7.wt/sub 7/wt 7/wt/sub &&
895 cd 7 &&
896 git init &&
897 git config core.worktree non-existent &&
898 cd ..
901 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
902 cat >7/expected <<EOF &&
903 setup: git_dir: .git
904 setup: worktree: $here/7
905 setup: cwd: $here/7
906 setup: prefix: (null)
908 test_repo 7 .git "$here/7"
911 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
912 cat >7/expected <<EOF &&
913 setup: git_dir: .git
914 setup: worktree: $here/7
915 setup: cwd: $here/7
916 setup: prefix: (null)
918 test_repo 7 .git .
921 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=root at root' '
922 cat >7/expected <<EOF &&
923 setup: git_dir: $here/7/.git
924 setup: worktree: $here/7
925 setup: cwd: $here/7
926 setup: prefix: (null)
928 test_repo 7 "$here/7/.git" "$here/7"
931 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
932 cat >7/expected <<EOF &&
933 setup: git_dir: $here/7/.git
934 setup: worktree: $here/7
935 setup: cwd: $here/7
936 setup: prefix: (null)
938 test_repo 7 "$here/7/.git" .
941 test_expect_success '#7: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
942 cat >7/sub/sub/expected <<EOF &&
943 setup: git_dir: $here/7/.git
944 setup: worktree: $here/7
945 setup: cwd: $here/7
946 setup: prefix: sub/sub/
948 test_repo 7/sub/sub ../../.git "$here/7"
951 test_expect_success '#7: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
952 cat >7/sub/sub/expected <<EOF &&
953 setup: git_dir: $here/7/.git
954 setup: worktree: $here/7
955 setup: cwd: $here/7
956 setup: prefix: sub/sub/
958 test_repo 7/sub/sub ../../.git ../..
961 test_expect_success '#7: GIT_DIR, GIT_WORKTREE=root in subdir' '
962 cat >7/sub/expected <<EOF &&
963 setup: git_dir: $here/7/.git
964 setup: worktree: $here/7
965 setup: cwd: $here/7
966 setup: prefix: sub/
968 test_repo 7/sub "$here/7/.git" "$here/7"
971 test_expect_success '#7: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
972 cat >7/sub/sub/expected <<EOF &&
973 setup: git_dir: $here/7/.git
974 setup: worktree: $here/7
975 setup: cwd: $here/7
976 setup: prefix: sub/sub/
978 test_repo 7/sub/sub "$here/7/.git" ../..
981 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
982 cat >7/expected <<EOF &&
983 setup: git_dir: .git
984 setup: worktree: $here/7/wt
985 setup: cwd: $here/7
986 setup: prefix: (null)
988 test_repo 7 .git "$here/7/wt"
991 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
992 cat >7/expected <<EOF &&
993 setup: git_dir: .git
994 setup: worktree: $here/7/wt
995 setup: cwd: $here/7
996 setup: prefix: (null)
998 test_repo 7 .git wt
1001 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
1002 cat >7/expected <<EOF &&
1003 setup: git_dir: $here/7/.git
1004 setup: worktree: $here/7/wt
1005 setup: cwd: $here/7
1006 setup: prefix: (null)
1008 test_repo 7 "$here/7/.git" wt
1011 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=wt at root' '
1012 cat >7/expected <<EOF &&
1013 setup: git_dir: $here/7/.git
1014 setup: worktree: $here/7/wt
1015 setup: cwd: $here/7
1016 setup: prefix: (null)
1018 test_repo 7 "$here/7/.git" "$here/7/wt"
1021 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
1022 cat >7/sub/sub/expected <<EOF &&
1023 setup: git_dir: ../../.git
1024 setup: worktree: $here/7/wt
1025 setup: cwd: $here/7/sub/sub
1026 setup: prefix: (null)
1028 test_repo 7/sub/sub ../../.git "$here/7/wt"
1031 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
1032 cat >7/sub/sub/expected <<EOF &&
1033 setup: git_dir: ../../.git
1034 setup: worktree: $here/7/wt
1035 setup: cwd: $here/7/sub/sub
1036 setup: prefix: (null)
1038 test_repo 7/sub/sub ../../.git ../../wt
1041 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
1042 cat >7/sub/sub/expected <<EOF &&
1043 setup: git_dir: $here/7/.git
1044 setup: worktree: $here/7/wt
1045 setup: cwd: $here/7/sub/sub
1046 setup: prefix: (null)
1048 test_repo 7/sub/sub "$here/7/.git" ../../wt
1051 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
1052 cat >7/sub/sub/expected <<EOF &&
1053 setup: git_dir: $here/7/.git
1054 setup: worktree: $here/7/wt
1055 setup: cwd: $here/7/sub/sub
1056 setup: prefix: (null)
1058 test_repo 7/sub/sub "$here/7/.git" "$here/7/wt"
1061 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
1062 cat >7/expected <<EOF &&
1063 setup: git_dir: $here/7/.git
1064 setup: worktree: $here
1065 setup: cwd: $here
1066 setup: prefix: 7/
1068 test_repo 7 .git "$here"
1071 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
1072 cat >7/expected <<EOF &&
1073 setup: git_dir: $here/7/.git
1074 setup: worktree: $here
1075 setup: cwd: $here
1076 setup: prefix: 7/
1078 test_repo 7 .git ..
1081 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
1082 cat >7/expected <<EOF &&
1083 setup: git_dir: $here/7/.git
1084 setup: worktree: $here
1085 setup: cwd: $here
1086 setup: prefix: 7/
1088 test_repo 7 "$here/7/.git" ..
1091 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=.. at root' '
1092 cat >7/expected <<EOF &&
1093 setup: git_dir: $here/7/.git
1094 setup: worktree: $here
1095 setup: cwd: $here
1096 setup: prefix: 7/
1098 test_repo 7 "$here/7/.git" "$here"
1101 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
1102 cat >7/sub/sub/expected <<EOF &&
1103 setup: git_dir: $here/7/.git
1104 setup: worktree: $here
1105 setup: cwd: $here
1106 setup: prefix: 7/sub/sub/
1108 test_repo 7/sub/sub ../../.git "$here"
1111 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
1112 cat >7/sub/sub/expected <<EOF &&
1113 setup: git_dir: $here/7/.git
1114 setup: worktree: $here
1115 setup: cwd: $here
1116 setup: prefix: 7/sub/sub/
1118 test_repo 7/sub/sub ../../.git ../../..
1121 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
1122 cat >7/sub/sub/expected <<EOF &&
1123 setup: git_dir: $here/7/.git
1124 setup: worktree: $here
1125 setup: cwd: $here
1126 setup: prefix: 7/sub/sub/
1128 test_repo 7/sub/sub "$here/7/.git" ../../../
1131 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
1132 cat >7/sub/sub/expected <<EOF &&
1133 setup: git_dir: $here/7/.git
1134 setup: worktree: $here
1135 setup: cwd: $here
1136 setup: prefix: 7/sub/sub/
1138 test_repo 7/sub/sub "$here/7/.git" "$here"
1142 # case #8
1144 ############################################################
1146 # Input:
1148 # - GIT_WORK_TREE is not set
1149 # - GIT_DIR is not set
1150 # - core.worktree is not set
1151 # - .git is a file
1152 # - core.bare is not set, cwd is outside .git
1154 # Output:
1156 # #0 except that git_dir is set by .git file
1158 test_expect_success '#8: setup' '
1159 sane_unset GIT_DIR GIT_WORK_TREE &&
1160 mkdir 8 8/sub &&
1161 cd 8 &&
1162 git init &&
1163 mv .git ../8.git &&
1164 echo gitdir: ../8.git >.git &&
1165 cd ..
1168 test_expect_success '#8: at root' '
1169 cat >8/expected <<EOF &&
1170 setup: git_dir: $here/8.git
1171 setup: worktree: $here/8
1172 setup: cwd: $here/8
1173 setup: prefix: (null)
1175 test_repo 8
1178 test_expect_success '#8: in subdir' '
1179 cat >8/sub/expected <<EOF &&
1180 setup: git_dir: $here/8.git
1181 setup: worktree: $here/8
1182 setup: cwd: $here/8
1183 setup: prefix: sub/
1185 test_repo 8/sub
1189 # case #9
1191 ############################################################
1193 # Input:
1195 # - GIT_WORK_TREE is set
1196 # - GIT_DIR is not set
1197 # - core.worktree is not set
1198 # - .git is a file
1199 # - core.bare is not set, cwd is outside .git
1201 # Output:
1203 # #1 except that git_dir is set by .git file
1205 test_expect_success '#9: setup' '
1206 sane_unset GIT_DIR GIT_WORK_TREE &&
1207 mkdir 9 9/sub 9.wt 9.wt/sub 9/wt 9/wt/sub &&
1208 cd 9 &&
1209 git init &&
1210 mv .git ../9.git &&
1211 echo gitdir: ../9.git >.git &&
1212 GIT_WORK_TREE=non-existent &&
1213 export GIT_WORK_TREE &&
1214 cd ..
1217 test_expect_success '#9: at root' '
1218 cat >9/expected <<EOF &&
1219 setup: git_dir: $here/9.git
1220 setup: worktree: $here/9
1221 setup: cwd: $here/9
1222 setup: prefix: (null)
1224 test_repo 9
1227 test_expect_success '#9: in subdir' '
1228 cat >9/sub/expected <<EOF &&
1229 setup: git_dir: $here/9.git
1230 setup: worktree: $here/9
1231 setup: cwd: $here/9
1232 setup: prefix: sub/
1234 test_repo 9/sub
1238 # case #10
1240 ############################################################
1242 # Input:
1244 # - GIT_WORK_TREE is not set
1245 # - GIT_DIR is set
1246 # - core.worktree is not set
1247 # - .git is a file
1248 # - core.bare is not set, cwd is outside .git
1250 # Output:
1252 # #2 except that git_dir is set by .git file
1254 test_expect_success '#10: setup' '
1255 sane_unset GIT_DIR GIT_WORK_TREE &&
1256 mkdir 10 10/sub &&
1257 cd 10 &&
1258 git init &&
1259 mv .git ../10.git &&
1260 echo gitdir: ../10.git >.git &&
1261 cd ..
1264 test_expect_success '#10: at root' '
1265 cat >10/expected <<EOF &&
1266 setup: git_dir: $here/10.git
1267 setup: worktree: $here/10
1268 setup: cwd: $here/10
1269 setup: prefix: (null)
1271 test_repo 10 "$here/10/.git"
1274 test_expect_success '#10: in subdir' '
1275 cat >10/sub/expected <<EOF &&
1276 setup: git_dir: $here/10.git
1277 setup: worktree: $here/10/sub
1278 setup: cwd: $here/10/sub
1279 setup: prefix: (null)
1281 test_repo 10/sub "$here/10/.git"
1284 test_expect_success '#10: relative GIT_DIR at root' '
1285 cat >10/expected <<EOF &&
1286 setup: git_dir: $here/10.git
1287 setup: worktree: $here/10
1288 setup: cwd: $here/10
1289 setup: prefix: (null)
1291 test_repo 10 .git
1294 test_expect_success '#10: relative GIT_DIR in subdir' '
1295 cat >10/sub/expected <<EOF &&
1296 setup: git_dir: $here/10.git
1297 setup: worktree: $here/10/sub
1298 setup: cwd: $here/10/sub
1299 setup: prefix: (null)
1301 test_repo 10/sub ../.git
1305 # case #11
1307 ############################################################
1309 # Input:
1311 # - GIT_WORK_TREE is set
1312 # - GIT_DIR is set
1313 # - core.worktree is not set
1314 # - .git is a file
1315 # - core.bare is not set, cwd is outside .git
1317 # Output:
1319 # #3 except that git_dir is set by .git file
1321 test_expect_success '#11: setup' '
1322 sane_unset GIT_DIR GIT_WORK_TREE &&
1323 mkdir 11 11/sub 11/sub/sub 11.wt 11.wt/sub 11/wt 11/wt/sub &&
1324 cd 11 &&
1325 git init &&
1326 mv .git ../11.git &&
1327 echo gitdir: ../11.git >.git &&
1328 cd ..
1331 test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
1332 cat >11/expected <<EOF &&
1333 setup: git_dir: $here/11.git
1334 setup: worktree: $here/11
1335 setup: cwd: $here/11
1336 setup: prefix: (null)
1338 test_repo 11 .git "$here/11"
1341 test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
1342 cat >11/expected <<EOF &&
1343 setup: git_dir: $here/11.git
1344 setup: worktree: $here/11
1345 setup: cwd: $here/11
1346 setup: prefix: (null)
1348 test_repo 11 .git .
1351 test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=root at root' '
1352 cat >11/expected <<EOF &&
1353 setup: git_dir: $here/11.git
1354 setup: worktree: $here/11
1355 setup: cwd: $here/11
1356 setup: prefix: (null)
1358 test_repo 11 "$here/11/.git" "$here/11"
1361 test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
1362 cat >11/expected <<EOF &&
1363 setup: git_dir: $here/11.git
1364 setup: worktree: $here/11
1365 setup: cwd: $here/11
1366 setup: prefix: (null)
1368 test_repo 11 "$here/11/.git" .
1371 test_expect_success '#11: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
1372 cat >11/sub/sub/expected <<EOF &&
1373 setup: git_dir: $here/11.git
1374 setup: worktree: $here/11
1375 setup: cwd: $here/11
1376 setup: prefix: sub/sub/
1378 test_repo 11/sub/sub ../../.git "$here/11"
1381 test_expect_success '#11: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
1382 cat >11/sub/sub/expected <<EOF &&
1383 setup: git_dir: $here/11.git
1384 setup: worktree: $here/11
1385 setup: cwd: $here/11
1386 setup: prefix: sub/sub/
1388 test_repo 11/sub/sub ../../.git ../..
1391 test_expect_success '#11: GIT_DIR, GIT_WORKTREE=root in subdir' '
1392 cat >11/sub/expected <<EOF &&
1393 setup: git_dir: $here/11.git
1394 setup: worktree: $here/11
1395 setup: cwd: $here/11
1396 setup: prefix: sub/
1398 test_repo 11/sub "$here/11/.git" "$here/11"
1401 test_expect_success '#11: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
1402 cat >11/sub/sub/expected <<EOF &&
1403 setup: git_dir: $here/11.git
1404 setup: worktree: $here/11
1405 setup: cwd: $here/11
1406 setup: prefix: sub/sub/
1408 test_repo 11/sub/sub "$here/11/.git" ../..
1411 test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
1412 cat >11/expected <<EOF &&
1413 setup: git_dir: $here/11.git
1414 setup: worktree: $here/11/wt
1415 setup: cwd: $here/11
1416 setup: prefix: (null)
1418 test_repo 11 .git "$here/11/wt"
1421 test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
1422 cat >11/expected <<EOF &&
1423 setup: git_dir: $here/11.git
1424 setup: worktree: $here/11/wt
1425 setup: cwd: $here/11
1426 setup: prefix: (null)
1428 test_repo 11 .git wt
1431 test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
1432 cat >11/expected <<EOF &&
1433 setup: git_dir: $here/11.git
1434 setup: worktree: $here/11/wt
1435 setup: cwd: $here/11
1436 setup: prefix: (null)
1438 test_repo 11 "$here/11/.git" wt
1441 test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=wt at root' '
1442 cat >11/expected <<EOF &&
1443 setup: git_dir: $here/11.git
1444 setup: worktree: $here/11/wt
1445 setup: cwd: $here/11
1446 setup: prefix: (null)
1448 test_repo 11 "$here/11/.git" "$here/11/wt"
1451 test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
1452 cat >11/sub/sub/expected <<EOF &&
1453 setup: git_dir: $here/11.git
1454 setup: worktree: $here/11/wt
1455 setup: cwd: $here/11/sub/sub
1456 setup: prefix: (null)
1458 test_repo 11/sub/sub ../../.git "$here/11/wt"
1461 test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
1462 cat >11/sub/sub/expected <<EOF &&
1463 setup: git_dir: $here/11.git
1464 setup: worktree: $here/11/wt
1465 setup: cwd: $here/11/sub/sub
1466 setup: prefix: (null)
1468 test_repo 11/sub/sub ../../.git ../../wt
1471 test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
1472 cat >11/sub/sub/expected <<EOF &&
1473 setup: git_dir: $here/11.git
1474 setup: worktree: $here/11/wt
1475 setup: cwd: $here/11/sub/sub
1476 setup: prefix: (null)
1478 test_repo 11/sub/sub "$here/11/.git" ../../wt
1481 test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
1482 cat >11/sub/sub/expected <<EOF &&
1483 setup: git_dir: $here/11.git
1484 setup: worktree: $here/11/wt
1485 setup: cwd: $here/11/sub/sub
1486 setup: prefix: (null)
1488 test_repo 11/sub/sub "$here/11/.git" "$here/11/wt"
1491 test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
1492 cat >11/expected <<EOF &&
1493 setup: git_dir: $here/11.git
1494 setup: worktree: $here
1495 setup: cwd: $here
1496 setup: prefix: 11/
1498 test_repo 11 .git "$here"
1501 test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
1502 cat >11/expected <<EOF &&
1503 setup: git_dir: $here/11.git
1504 setup: worktree: $here
1505 setup: cwd: $here
1506 setup: prefix: 11/
1508 test_repo 11 .git ..
1511 test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
1512 cat >11/expected <<EOF &&
1513 setup: git_dir: $here/11.git
1514 setup: worktree: $here
1515 setup: cwd: $here
1516 setup: prefix: 11/
1518 test_repo 11 "$here/11/.git" ..
1521 test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=.. at root' '
1522 cat >11/expected <<EOF &&
1523 setup: git_dir: $here/11.git
1524 setup: worktree: $here
1525 setup: cwd: $here
1526 setup: prefix: 11/
1528 test_repo 11 "$here/11/.git" "$here"
1531 test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
1532 cat >11/sub/sub/expected <<EOF &&
1533 setup: git_dir: $here/11.git
1534 setup: worktree: $here
1535 setup: cwd: $here
1536 setup: prefix: 11/sub/sub/
1538 test_repo 11/sub/sub ../../.git "$here"
1541 test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
1542 cat >11/sub/sub/expected <<EOF &&
1543 setup: git_dir: $here/11.git
1544 setup: worktree: $here
1545 setup: cwd: $here
1546 setup: prefix: 11/sub/sub/
1548 test_repo 11/sub/sub ../../.git ../../..
1551 test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
1552 cat >11/sub/sub/expected <<EOF &&
1553 setup: git_dir: $here/11.git
1554 setup: worktree: $here
1555 setup: cwd: $here
1556 setup: prefix: 11/sub/sub/
1558 test_repo 11/sub/sub "$here/11/.git" ../../../
1561 test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
1562 cat >11/sub/sub/expected <<EOF &&
1563 setup: git_dir: $here/11.git
1564 setup: worktree: $here
1565 setup: cwd: $here
1566 setup: prefix: 11/sub/sub/
1568 test_repo 11/sub/sub "$here/11/.git" "$here"
1572 # case #12
1574 ############################################################
1576 # Input:
1578 # - GIT_WORK_TREE is not set
1579 # - GIT_DIR is not set
1580 # - core.worktree is set
1581 # - .git is a file
1582 # - core.bare is not set, cwd is outside .git
1584 # Output:
1586 # #4 except that git_dir is set by .git file
1589 test_expect_success '#12: setup' '
1590 sane_unset GIT_DIR GIT_WORK_TREE &&
1591 mkdir 12 12/sub 12/sub/sub 12.wt 12.wt/sub 12/wt 12/wt/sub &&
1592 cd 12 &&
1593 git init &&
1594 git config core.worktree non-existent &&
1595 mv .git ../12.git &&
1596 echo gitdir: ../12.git >.git &&
1597 cd ..
1600 test_expect_success '#12: at root' '
1601 cat >12/expected <<EOF &&
1602 setup: git_dir: $here/12.git
1603 setup: worktree: $here/12
1604 setup: cwd: $here/12
1605 setup: prefix: (null)
1607 test_repo 12
1610 test_expect_success '#12: in subdir' '
1611 cat >12/sub/expected <<EOF &&
1612 setup: git_dir: $here/12.git
1613 setup: worktree: $here/12
1614 setup: cwd: $here/12
1615 setup: prefix: sub/
1617 test_repo 12/sub
1621 # case #13
1623 ############################################################
1625 # Input:
1627 # - GIT_WORK_TREE is set
1628 # - GIT_DIR is not set
1629 # - core.worktree is set
1630 # - .git is a file
1631 # - core.bare is not set, cwd is outside .git
1633 # Output:
1635 # #5 except that git_dir is set by .git file
1637 test_expect_success '#13: setup' '
1638 sane_unset GIT_DIR GIT_WORK_TREE &&
1639 mkdir 13 13/sub 13/sub/sub 13.wt 13.wt/sub 13/wt 13/wt/sub &&
1640 cd 13 &&
1641 git init &&
1642 git config core.worktree non-existent &&
1643 GIT_WORK_TREE=non-existent-too &&
1644 export GIT_WORK_TREE &&
1645 mv .git ../13.git &&
1646 echo gitdir: ../13.git >.git &&
1647 cd ..
1650 test_expect_success '#13: at root' '
1651 cat >13/expected <<EOF &&
1652 setup: git_dir: $here/13.git
1653 setup: worktree: $here/13
1654 setup: cwd: $here/13
1655 setup: prefix: (null)
1657 test_repo 13
1660 test_expect_success '#13: in subdir' '
1661 cat >13/sub/expected <<EOF &&
1662 setup: git_dir: $here/13.git
1663 setup: worktree: $here/13
1664 setup: cwd: $here/13
1665 setup: prefix: sub/
1667 test_repo 13/sub
1671 # case #14
1673 ############################################################
1675 # Input:
1677 # - GIT_WORK_TREE is not set
1678 # - GIT_DIR is set
1679 # - core.worktree is set
1680 # - .git is a file
1681 # - core.bare is not set, cwd is outside .git
1683 # Output:
1685 # #6 except that git_dir is set by .git file
1687 test_expect_success '#14: setup' '
1688 sane_unset GIT_DIR GIT_WORK_TREE &&
1689 mkdir 14 14/sub 14/sub/sub 14.wt 14.wt/sub 14/wt 14/wt/sub &&
1690 cd 14 &&
1691 git init &&
1692 mv .git ../14.git &&
1693 echo gitdir: ../14.git >.git &&
1694 cd ..
1697 test_expect_success '#14: GIT_DIR(rel), core.worktree=../14 at root' '
1698 cat >14/expected <<EOF &&
1699 setup: git_dir: $here/14.git
1700 setup: worktree: $here/14
1701 setup: cwd: $here/14
1702 setup: prefix: (null)
1704 git config --file="$here/14.git/config" core.worktree "$here/14" &&
1705 test_repo 14 .git
1708 test_expect_success '#14: GIT_DIR(rel), core.worktree=../14(rel) at root' '
1709 cat >14/expected <<EOF &&
1710 setup: git_dir: $here/14.git
1711 setup: worktree: $here/14
1712 setup: cwd: $here/14
1713 setup: prefix: (null)
1715 git config --file="$here/14.git/config" core.worktree ../14 &&
1716 test_repo 14 .git
1719 test_expect_success '#14: GIT_DIR, core.worktree=../14 at root' '
1720 cat >14/expected <<EOF &&
1721 setup: git_dir: $here/14.git
1722 setup: worktree: $here/14
1723 setup: cwd: $here/14
1724 setup: prefix: (null)
1726 git config --file="$here/14.git/config" core.worktree "$here/14" &&
1727 test_repo 14 "$here/14/.git"
1730 test_expect_success '#14: GIT_DIR, core.worktree=../14(rel) at root' '
1731 cat >14/expected <<EOF &&
1732 setup: git_dir: $here/14.git
1733 setup: worktree: $here/14
1734 setup: cwd: $here/14
1735 setup: prefix: (null)
1737 git config --file="$here/14.git/config" core.worktree ../14 &&
1738 test_repo 14 "$here/14/.git"
1741 test_expect_success '#14: GIT_DIR(rel), core.worktree=../14 in subdir' '
1742 cat >14/sub/sub/expected <<EOF &&
1743 setup: git_dir: $here/14.git
1744 setup: worktree: $here/14
1745 setup: cwd: $here/14
1746 setup: prefix: sub/sub/
1748 git config --file="$here/14.git/config" core.worktree "$here/14" &&
1749 test_repo 14/sub/sub ../../.git
1752 test_expect_success '#14: GIT_DIR(rel), core.worktree=../14(rel) in subdir' '
1753 cat >14/sub/sub/expected <<EOF &&
1754 setup: git_dir: $here/14.git
1755 setup: worktree: $here/14
1756 setup: cwd: $here/14
1757 setup: prefix: sub/sub/
1759 git config --file="$here/14.git/config" core.worktree ../14 &&
1760 test_repo 14/sub/sub ../../.git
1763 test_expect_success '#14: GIT_DIR, core.worktree=../14 in subdir' '
1764 cat >14/sub/expected <<EOF &&
1765 setup: git_dir: $here/14.git
1766 setup: worktree: $here/14
1767 setup: cwd: $here/14
1768 setup: prefix: sub/
1770 git config --file="$here/14.git/config" core.worktree "$here/14" &&
1771 test_repo 14/sub "$here/14/.git"
1774 test_expect_success '#14: GIT_DIR, core.worktree=../14(rel) in subdir' '
1775 cat >14/sub/sub/expected <<EOF &&
1776 setup: git_dir: $here/14.git
1777 setup: worktree: $here/14
1778 setup: cwd: $here/14
1779 setup: prefix: sub/sub/
1781 git config --file="$here/14.git/config" core.worktree ../14 &&
1782 test_repo 14/sub/sub "$here/14/.git"
1785 test_expect_success '#14: GIT_DIR(rel), core.worktree=../14/wt at root' '
1786 cat >14/expected <<EOF &&
1787 setup: git_dir: $here/14.git
1788 setup: worktree: $here/14/wt
1789 setup: cwd: $here/14
1790 setup: prefix: (null)
1792 git config --file="$here/14.git/config" core.worktree "$here/14/wt" &&
1793 test_repo 14 .git
1796 test_expect_success '#14: GIT_DIR(rel), core.worktree=../14/wt(rel) at root' '
1797 cat >14/expected <<EOF &&
1798 setup: git_dir: $here/14.git
1799 setup: worktree: $here/14/wt
1800 setup: cwd: $here/14
1801 setup: prefix: (null)
1803 git config --file="$here/14.git/config" core.worktree ../14/wt &&
1804 test_repo 14 .git
1807 test_expect_success '#14: GIT_DIR, core.worktree=../14/wt(rel) at root' '
1808 cat >14/expected <<EOF &&
1809 setup: git_dir: $here/14.git
1810 setup: worktree: $here/14/wt
1811 setup: cwd: $here/14
1812 setup: prefix: (null)
1814 git config --file="$here/14.git/config" core.worktree ../14/wt &&
1815 test_repo 14 "$here/14/.git"
1818 test_expect_success '#14: GIT_DIR, core.worktree=../14/wt at root' '
1819 cat >14/expected <<EOF &&
1820 setup: git_dir: $here/14.git
1821 setup: worktree: $here/14/wt
1822 setup: cwd: $here/14
1823 setup: prefix: (null)
1825 git config --file="$here/14.git/config" core.worktree "$here/14/wt" &&
1826 test_repo 14 "$here/14/.git"
1829 test_expect_success '#14: GIT_DIR(rel), core.worktree=../14/wt in subdir' '
1830 cat >14/sub/sub/expected <<EOF &&
1831 setup: git_dir: $here/14.git
1832 setup: worktree: $here/14/wt
1833 setup: cwd: $here/14/sub/sub
1834 setup: prefix: (null)
1836 git config --file="$here/14.git/config" core.worktree "$here/14/wt" &&
1837 test_repo 14/sub/sub ../../.git
1840 test_expect_success '#14: GIT_DIR(rel), core.worktree=../14/wt(rel) in subdir' '
1841 cat >14/sub/sub/expected <<EOF &&
1842 setup: git_dir: $here/14.git
1843 setup: worktree: $here/14/wt
1844 setup: cwd: $here/14/sub/sub
1845 setup: prefix: (null)
1847 git config --file="$here/14.git/config" core.worktree ../14/wt &&
1848 test_repo 14/sub/sub ../../.git
1851 test_expect_success '#14: GIT_DIR, core.worktree=../14/wt(rel) in subdir' '
1852 cat >14/sub/sub/expected <<EOF &&
1853 setup: git_dir: $here/14.git
1854 setup: worktree: $here/14/wt
1855 setup: cwd: $here/14/sub/sub
1856 setup: prefix: (null)
1858 git config --file="$here/14.git/config" core.worktree ../14/wt &&
1859 test_repo 14/sub/sub "$here/14/.git"
1862 test_expect_success '#14: GIT_DIR, core.worktree=../14/wt in subdir' '
1863 cat >14/sub/sub/expected <<EOF &&
1864 setup: git_dir: $here/14.git
1865 setup: worktree: $here/14/wt
1866 setup: cwd: $here/14/sub/sub
1867 setup: prefix: (null)
1869 git config --file="$here/14.git/config" core.worktree "$here/14/wt" &&
1870 test_repo 14/sub/sub "$here/14/.git"
1873 test_expect_success '#14: GIT_DIR(rel), core.worktree=.. at root' '
1874 cat >14/expected <<EOF &&
1875 setup: git_dir: $here/14.git
1876 setup: worktree: $here
1877 setup: cwd: $here
1878 setup: prefix: 14/
1880 git config --file="$here/14.git/config" core.worktree "$here" &&
1881 test_repo 14 .git
1884 test_expect_success '#14: GIT_DIR(rel), core.worktree=..(rel) at root' '
1885 cat >14/expected <<EOF &&
1886 setup: git_dir: $here/14.git
1887 setup: worktree: $here
1888 setup: cwd: $here
1889 setup: prefix: 14/
1891 git config --file="$here/14.git/config" core.worktree .. &&
1892 test_repo 14 .git
1895 test_expect_success '#14: GIT_DIR, core.worktree=..(rel) at root' '
1896 cat >14/expected <<EOF &&
1897 setup: git_dir: $here/14.git
1898 setup: worktree: $here
1899 setup: cwd: $here
1900 setup: prefix: 14/
1902 git config --file="$here/14.git/config" core.worktree .. &&
1903 test_repo 14 "$here/14/.git"
1906 test_expect_success '#14: GIT_DIR, core.worktree=.. at root' '
1907 cat >14/expected <<EOF &&
1908 setup: git_dir: $here/14.git
1909 setup: worktree: $here
1910 setup: cwd: $here
1911 setup: prefix: 14/
1913 git config --file="$here/14.git/config" core.worktree "$here" &&
1914 test_repo 14 "$here/14/.git"
1917 test_expect_success '#14: GIT_DIR(rel), core.worktree=.. in subdir' '
1918 cat >14/sub/sub/expected <<EOF &&
1919 setup: git_dir: $here/14.git
1920 setup: worktree: $here
1921 setup: cwd: $here
1922 setup: prefix: 14/sub/sub/
1924 git config --file="$here/14.git/config" core.worktree "$here" &&
1925 test_repo 14/sub/sub ../../.git
1928 test_expect_success '#14: GIT_DIR(rel), core.worktree=..(rel) in subdir' '
1929 cat >14/sub/sub/expected <<EOF &&
1930 setup: git_dir: $here/14.git
1931 setup: worktree: $here
1932 setup: cwd: $here
1933 setup: prefix: 14/sub/sub/
1935 git config --file="$here/14.git/config" core.worktree .. &&
1936 test_repo 14/sub/sub ../../.git
1939 test_expect_success '#14: GIT_DIR, core.worktree=..(rel) in subdir' '
1940 cat >14/sub/sub/expected <<EOF &&
1941 setup: git_dir: $here/14.git
1942 setup: worktree: $here
1943 setup: cwd: $here
1944 setup: prefix: 14/sub/sub/
1946 git config --file="$here/14.git/config" core.worktree .. &&
1947 test_repo 14/sub/sub "$here/14/.git"
1950 test_expect_success '#14: GIT_DIR, core.worktree=.. in subdir' '
1951 cat >14/sub/sub/expected <<EOF &&
1952 setup: git_dir: $here/14.git
1953 setup: worktree: $here
1954 setup: cwd: $here
1955 setup: prefix: 14/sub/sub/
1957 git config --file="$here/14.git/config" core.worktree "$here" &&
1958 test_repo 14/sub/sub "$here/14/.git"
1962 # case #15
1964 ############################################################
1966 # Input:
1968 # - GIT_WORK_TREE is set
1969 # - GIT_DIR is set
1970 # - core.worktree is set
1971 # - .git is a file
1972 # - core.bare is not set, cwd is outside .git
1974 # Output:
1976 # #7 except that git_dir is set by .git file
1978 test_expect_success '#15: setup' '
1979 sane_unset GIT_DIR GIT_WORK_TREE &&
1980 mkdir 15 15/sub 15/sub/sub 15.wt 15.wt/sub 15/wt 15/wt/sub &&
1981 cd 15 &&
1982 git init &&
1983 git config core.worktree non-existent &&
1984 mv .git ../15.git &&
1985 echo gitdir: ../15.git >.git &&
1986 cd ..
1989 test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
1990 cat >15/expected <<EOF &&
1991 setup: git_dir: $here/15.git
1992 setup: worktree: $here/15
1993 setup: cwd: $here/15
1994 setup: prefix: (null)
1996 test_repo 15 .git "$here/15"
1999 test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
2000 cat >15/expected <<EOF &&
2001 setup: git_dir: $here/15.git
2002 setup: worktree: $here/15
2003 setup: cwd: $here/15
2004 setup: prefix: (null)
2006 test_repo 15 .git .
2009 test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=root at root' '
2010 cat >15/expected <<EOF &&
2011 setup: git_dir: $here/15.git
2012 setup: worktree: $here/15
2013 setup: cwd: $here/15
2014 setup: prefix: (null)
2016 test_repo 15 "$here/15/.git" "$here/15"
2019 test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
2020 cat >15/expected <<EOF &&
2021 setup: git_dir: $here/15.git
2022 setup: worktree: $here/15
2023 setup: cwd: $here/15
2024 setup: prefix: (null)
2026 test_repo 15 "$here/15/.git" .
2029 test_expect_success '#15: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
2030 cat >15/sub/sub/expected <<EOF &&
2031 setup: git_dir: $here/15.git
2032 setup: worktree: $here/15
2033 setup: cwd: $here/15
2034 setup: prefix: sub/sub/
2036 test_repo 15/sub/sub ../../.git "$here/15"
2039 test_expect_success '#15: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
2040 cat >15/sub/sub/expected <<EOF &&
2041 setup: git_dir: $here/15.git
2042 setup: worktree: $here/15
2043 setup: cwd: $here/15
2044 setup: prefix: sub/sub/
2046 test_repo 15/sub/sub ../../.git ../..
2049 test_expect_success '#15: GIT_DIR, GIT_WORKTREE=root in subdir' '
2050 cat >15/sub/expected <<EOF &&
2051 setup: git_dir: $here/15.git
2052 setup: worktree: $here/15
2053 setup: cwd: $here/15
2054 setup: prefix: sub/
2056 test_repo 15/sub "$here/15/.git" "$here/15"
2059 test_expect_success '#15: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
2060 cat >15/sub/sub/expected <<EOF &&
2061 setup: git_dir: $here/15.git
2062 setup: worktree: $here/15
2063 setup: cwd: $here/15
2064 setup: prefix: sub/sub/
2066 test_repo 15/sub/sub "$here/15/.git" ../..
2069 test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
2070 cat >15/expected <<EOF &&
2071 setup: git_dir: $here/15.git
2072 setup: worktree: $here/15/wt
2073 setup: cwd: $here/15
2074 setup: prefix: (null)
2076 test_repo 15 .git "$here/15/wt"
2079 test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
2080 cat >15/expected <<EOF &&
2081 setup: git_dir: $here/15.git
2082 setup: worktree: $here/15/wt
2083 setup: cwd: $here/15
2084 setup: prefix: (null)
2086 test_repo 15 .git wt
2089 test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
2090 cat >15/expected <<EOF &&
2091 setup: git_dir: $here/15.git
2092 setup: worktree: $here/15/wt
2093 setup: cwd: $here/15
2094 setup: prefix: (null)
2096 test_repo 15 "$here/15/.git" wt
2099 test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=wt at root' '
2100 cat >15/expected <<EOF &&
2101 setup: git_dir: $here/15.git
2102 setup: worktree: $here/15/wt
2103 setup: cwd: $here/15
2104 setup: prefix: (null)
2106 test_repo 15 "$here/15/.git" "$here/15/wt"
2109 test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
2110 cat >15/sub/sub/expected <<EOF &&
2111 setup: git_dir: $here/15.git
2112 setup: worktree: $here/15/wt
2113 setup: cwd: $here/15/sub/sub
2114 setup: prefix: (null)
2116 test_repo 15/sub/sub ../../.git "$here/15/wt"
2119 test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
2120 cat >15/sub/sub/expected <<EOF &&
2121 setup: git_dir: $here/15.git
2122 setup: worktree: $here/15/wt
2123 setup: cwd: $here/15/sub/sub
2124 setup: prefix: (null)
2126 test_repo 15/sub/sub ../../.git ../../wt
2129 test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
2130 cat >15/sub/sub/expected <<EOF &&
2131 setup: git_dir: $here/15.git
2132 setup: worktree: $here/15/wt
2133 setup: cwd: $here/15/sub/sub
2134 setup: prefix: (null)
2136 test_repo 15/sub/sub "$here/15/.git" ../../wt
2139 test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
2140 cat >15/sub/sub/expected <<EOF &&
2141 setup: git_dir: $here/15.git
2142 setup: worktree: $here/15/wt
2143 setup: cwd: $here/15/sub/sub
2144 setup: prefix: (null)
2146 test_repo 15/sub/sub "$here/15/.git" "$here/15/wt"
2149 test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
2150 cat >15/expected <<EOF &&
2151 setup: git_dir: $here/15.git
2152 setup: worktree: $here
2153 setup: cwd: $here
2154 setup: prefix: 15/
2156 test_repo 15 .git "$here"
2159 test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
2160 cat >15/expected <<EOF &&
2161 setup: git_dir: $here/15.git
2162 setup: worktree: $here
2163 setup: cwd: $here
2164 setup: prefix: 15/
2166 test_repo 15 .git ..
2169 test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
2170 cat >15/expected <<EOF &&
2171 setup: git_dir: $here/15.git
2172 setup: worktree: $here
2173 setup: cwd: $here
2174 setup: prefix: 15/
2176 test_repo 15 "$here/15/.git" ..
2179 test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=.. at root' '
2180 cat >15/expected <<EOF &&
2181 setup: git_dir: $here/15.git
2182 setup: worktree: $here
2183 setup: cwd: $here
2184 setup: prefix: 15/
2186 test_repo 15 "$here/15/.git" "$here"
2189 test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
2190 cat >15/sub/sub/expected <<EOF &&
2191 setup: git_dir: $here/15.git
2192 setup: worktree: $here
2193 setup: cwd: $here
2194 setup: prefix: 15/sub/sub/
2196 test_repo 15/sub/sub ../../.git "$here"
2199 test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
2200 cat >15/sub/sub/expected <<EOF &&
2201 setup: git_dir: $here/15.git
2202 setup: worktree: $here
2203 setup: cwd: $here
2204 setup: prefix: 15/sub/sub/
2206 test_repo 15/sub/sub ../../.git ../../..
2209 test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
2210 cat >15/sub/sub/expected <<EOF &&
2211 setup: git_dir: $here/15.git
2212 setup: worktree: $here
2213 setup: cwd: $here
2214 setup: prefix: 15/sub/sub/
2216 test_repo 15/sub/sub "$here/15/.git" ../../../
2219 test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
2220 cat >15/sub/sub/expected <<EOF &&
2221 setup: git_dir: $here/15.git
2222 setup: worktree: $here
2223 setup: cwd: $here
2224 setup: prefix: 15/sub/sub/
2226 test_repo 15/sub/sub "$here/15/.git" "$here"
2230 # case #16.1
2232 ############################################################
2234 # Input:
2236 # - GIT_WORK_TREE is not set
2237 # - GIT_DIR is not set
2238 # - core.worktree is not set
2239 # - .git is a directory
2240 # - cwd is inside .git
2242 # Output:
2244 # - no worktree
2245 # - cwd is unchanged
2246 # - prefix is NULL
2247 # - git_dir is set
2248 # - cwd can't be outside worktree
2250 test_expect_success '#16.1: setup' '
2251 sane_unset GIT_DIR GIT_WORK_TREE &&
2252 mkdir 16 16/sub &&
2253 cd 16 &&
2254 git init &&
2255 mkdir .git/wt .git/wt/sub &&
2256 cd ..
2259 test_expect_success '#16.1: at .git' '
2260 cat >16/.git/expected <<EOF &&
2261 setup: git_dir: .
2262 setup: worktree: (null)
2263 setup: cwd: $here/16/.git
2264 setup: prefix: (null)
2266 test_repo 16/.git
2269 test_expect_success '#16.1: in .git/wt' '
2270 cat >16/.git/wt/expected <<EOF &&
2271 setup: git_dir: $here/16/.git
2272 setup: worktree: (null)
2273 setup: cwd: $here/16/.git/wt
2274 setup: prefix: (null)
2276 test_repo 16/.git/wt
2279 test_expect_success '#16.1: in .git/wt/sub' '
2280 cat >16/.git/wt/sub/expected <<EOF &&
2281 setup: git_dir: $here/16/.git
2282 setup: worktree: (null)
2283 setup: cwd: $here/16/.git/wt/sub
2284 setup: prefix: (null)
2286 test_repo 16/.git/wt/sub
2290 # case #16.2
2292 ############################################################
2294 # Input:
2296 # - GIT_WORK_TREE is not set
2297 # - GIT_DIR is not set
2298 # - core.worktree is not set
2299 # - .git is a directory
2300 # - core.bare is set
2302 # Output:
2304 # - no worktree
2305 # - cwd is unchanged
2306 # - prefix is NULL
2307 # - git_dir is set
2308 # - cwd can't be outside worktree
2310 test_expect_success '#16.2: setup' '
2311 git config --file="$here/16/.git/config" core.bare true
2314 test_expect_success '#16.2: at .git' '
2315 cat >16/.git/expected <<EOF &&
2316 setup: git_dir: .
2317 setup: worktree: (null)
2318 setup: cwd: $here/16/.git
2319 setup: prefix: (null)
2321 test_repo 16/.git
2324 test_expect_success '#16.2: in .git/wt' '
2325 cat >16/.git/wt/expected <<EOF &&
2326 setup: git_dir: $here/16/.git
2327 setup: worktree: (null)
2328 setup: cwd: $here/16/.git/wt
2329 setup: prefix: (null)
2331 test_repo 16/.git/wt
2334 test_expect_success '#16.2: in .git/wt/sub' '
2335 cat >16/.git/wt/sub/expected <<EOF &&
2336 setup: git_dir: $here/16/.git
2337 setup: worktree: (null)
2338 setup: cwd: $here/16/.git/wt/sub
2339 setup: prefix: (null)
2341 test_repo 16/.git/wt/sub
2344 test_expect_success '#16.2: at root' '
2345 cat >16/expected <<EOF &&
2346 setup: git_dir: .git
2347 setup: worktree: (null)
2348 setup: cwd: $here/16
2349 setup: prefix: (null)
2351 test_repo 16
2354 test_expect_success '#16.2: in subdir' '
2355 cat >16/sub/expected <<EOF &&
2356 setup: git_dir: $here/16/.git
2357 setup: worktree: (null)
2358 setup: cwd: $here/16/sub
2359 setup: prefix: (null)
2361 test_repo 16/sub
2365 # case #17.1
2367 ############################################################
2369 # Input:
2371 # - GIT_WORK_TREE is set
2372 # - GIT_DIR is not set
2373 # - core.worktree is not set
2374 # - .git is a directory
2375 # - cwd is inside .git
2377 # Output:
2379 # GIT_WORK_TREE is ignored -> #16.1 (with warnings perhaps)
2381 test_expect_success '#17.1: setup' '
2382 sane_unset GIT_DIR GIT_WORK_TREE &&
2383 mkdir 17 17/sub &&
2384 cd 17 &&
2385 git init &&
2386 mkdir .git/wt .git/wt/sub &&
2387 GIT_WORK_TREE=non-existent &&
2388 export GIT_WORK_TREE &&
2389 cd ..
2392 test_expect_success '#17.1: at .git' '
2393 cat >17/.git/expected <<EOF &&
2394 setup: git_dir: .
2395 setup: worktree: (null)
2396 setup: cwd: $here/17/.git
2397 setup: prefix: (null)
2399 test_repo 17/.git
2402 test_expect_success '#17.1: in .git/wt' '
2403 cat >17/.git/wt/expected <<EOF &&
2404 setup: git_dir: $here/17/.git
2405 setup: worktree: (null)
2406 setup: cwd: $here/17/.git/wt
2407 setup: prefix: (null)
2409 test_repo 17/.git/wt
2412 test_expect_success '#17.1: in .git/wt/sub' '
2413 cat >17/.git/wt/sub/expected <<EOF &&
2414 setup: git_dir: $here/17/.git
2415 setup: worktree: (null)
2416 setup: cwd: $here/17/.git/wt/sub
2417 setup: prefix: (null)
2419 test_repo 17/.git/wt/sub
2423 # case #17.2
2425 ############################################################
2427 # Input:
2429 # - GIT_WORK_TREE is set
2430 # - GIT_DIR is not set
2431 # - core.worktree is not set
2432 # - .git is a directory
2433 # - core.bare is set
2435 # Output:
2437 # GIT_WORK_TREE is ignored -> #16.2 (with warnings perhaps)
2439 test_expect_success '#17.2: setup' '
2440 git config --file="$here/17/.git/config" core.bare true
2443 test_expect_success '#17.2: at .git' '
2444 cat >17/.git/expected <<EOF &&
2445 setup: git_dir: .
2446 setup: worktree: (null)
2447 setup: cwd: $here/17/.git
2448 setup: prefix: (null)
2450 test_repo 17/.git
2453 test_expect_success '#17.2: in .git/wt' '
2454 cat >17/.git/wt/expected <<EOF &&
2455 setup: git_dir: $here/17/.git
2456 setup: worktree: (null)
2457 setup: cwd: $here/17/.git/wt
2458 setup: prefix: (null)
2460 test_repo 17/.git/wt
2463 test_expect_success '#17.2: in .git/wt/sub' '
2464 cat >17/.git/wt/sub/expected <<EOF &&
2465 setup: git_dir: $here/17/.git
2466 setup: worktree: (null)
2467 setup: cwd: $here/17/.git/wt/sub
2468 setup: prefix: (null)
2470 test_repo 17/.git/wt/sub
2473 test_expect_success '#17.2: at root' '
2474 cat >17/expected <<EOF &&
2475 setup: git_dir: .git
2476 setup: worktree: (null)
2477 setup: cwd: $here/17
2478 setup: prefix: (null)
2480 test_repo 17
2483 test_expect_success '#17.2: in subdir' '
2484 cat >17/sub/expected <<EOF &&
2485 setup: git_dir: $here/17/.git
2486 setup: worktree: (null)
2487 setup: cwd: $here/17/sub
2488 setup: prefix: (null)
2490 test_repo 17/sub
2494 # case #18
2496 ############################################################
2498 # Input:
2500 # - GIT_WORK_TREE is not set
2501 # - GIT_DIR is set
2502 # - core.worktree is not set
2503 # - .git is a directory
2504 # - core.bare is set
2506 # Output:
2508 # - no worktree (rule #8)
2509 # - cwd is unchanged
2510 # - prefix is NULL
2511 # - git_dir is set to $GIT_DIR
2512 # - cwd can't be outside worktree
2514 test_expect_success '#18: setup' '
2515 sane_unset GIT_DIR GIT_WORK_TREE &&
2516 mkdir 18 18/sub &&
2517 cd 18 &&
2518 git init &&
2519 mkdir .git/wt .git/wt/sub &&
2520 git config core.bare true &&
2521 cd ..
2524 test_expect_success '#18: (rel) at root' '
2525 cat >18/expected <<EOF &&
2526 setup: git_dir: .git
2527 setup: worktree: (null)
2528 setup: cwd: $here/18
2529 setup: prefix: (null)
2531 test_repo 18 .git
2534 test_expect_success '#18: at root' '
2535 cat >18/expected <<EOF &&
2536 setup: git_dir: $here/18/.git
2537 setup: worktree: (null)
2538 setup: cwd: $here/18
2539 setup: prefix: (null)
2541 test_repo 18 "$here/18/.git"
2544 test_expect_success '#18: (rel) in subdir' '
2545 cat >18/sub/expected <<EOF &&
2546 setup: git_dir: ../.git
2547 setup: worktree: (null)
2548 setup: cwd: $here/18/sub
2549 setup: prefix: (null)
2551 test_repo 18/sub ../.git
2554 test_expect_success '#18: in subdir' '
2555 cat >18/sub/expected <<EOF &&
2556 setup: git_dir: $here/18/.git
2557 setup: worktree: (null)
2558 setup: cwd: $here/18/sub
2559 setup: prefix: (null)
2561 test_repo 18/sub "$here/18/.git"
2565 # case #19
2567 ############################################################
2569 # Input:
2571 # - GIT_WORK_TREE is set
2572 # - GIT_DIR is set
2573 # - .git is a directory
2574 # - core.worktree is not set
2575 # - core.bare is set
2577 # Output:
2579 # bare repo is overridden by GIT_WORK_TREE -> #3
2581 test_expect_success '#19: setup' '
2582 sane_unset GIT_DIR GIT_WORK_TREE &&
2583 mkdir 19 19/sub 19/sub/sub 19.wt 19.wt/sub 19/wt 19/wt/sub &&
2584 cd 19 &&
2585 git init &&
2586 git config core.bare true &&
2587 cd ..
2590 test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
2591 cat >19/expected <<EOF &&
2592 setup: git_dir: .git
2593 setup: worktree: $here/19
2594 setup: cwd: $here/19
2595 setup: prefix: (null)
2597 test_repo 19 .git "$here/19"
2600 test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
2601 cat >19/expected <<EOF &&
2602 setup: git_dir: .git
2603 setup: worktree: $here/19
2604 setup: cwd: $here/19
2605 setup: prefix: (null)
2607 test_repo 19 .git .
2610 test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=root at root' '
2611 cat >19/expected <<EOF &&
2612 setup: git_dir: $here/19/.git
2613 setup: worktree: $here/19
2614 setup: cwd: $here/19
2615 setup: prefix: (null)
2617 test_repo 19 "$here/19/.git" "$here/19"
2620 test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
2621 cat >19/expected <<EOF &&
2622 setup: git_dir: $here/19/.git
2623 setup: worktree: $here/19
2624 setup: cwd: $here/19
2625 setup: prefix: (null)
2627 test_repo 19 "$here/19/.git" .
2630 test_expect_success '#19: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
2631 cat >19/sub/sub/expected <<EOF &&
2632 setup: git_dir: $here/19/.git
2633 setup: worktree: $here/19
2634 setup: cwd: $here/19
2635 setup: prefix: sub/sub/
2637 test_repo 19/sub/sub ../../.git "$here/19"
2640 test_expect_success '#19: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
2641 cat >19/sub/sub/expected <<EOF &&
2642 setup: git_dir: $here/19/.git
2643 setup: worktree: $here/19
2644 setup: cwd: $here/19
2645 setup: prefix: sub/sub/
2647 test_repo 19/sub/sub ../../.git ../..
2650 test_expect_success '#19: GIT_DIR, GIT_WORKTREE=root in subdir' '
2651 cat >19/sub/expected <<EOF &&
2652 setup: git_dir: $here/19/.git
2653 setup: worktree: $here/19
2654 setup: cwd: $here/19
2655 setup: prefix: sub/
2657 test_repo 19/sub "$here/19/.git" "$here/19"
2660 test_expect_success '#19: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
2661 cat >19/sub/sub/expected <<EOF &&
2662 setup: git_dir: $here/19/.git
2663 setup: worktree: $here/19
2664 setup: cwd: $here/19
2665 setup: prefix: sub/sub/
2667 test_repo 19/sub/sub "$here/19/.git" ../..
2670 test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
2671 cat >19/expected <<EOF &&
2672 setup: git_dir: .git
2673 setup: worktree: $here/19/wt
2674 setup: cwd: $here/19
2675 setup: prefix: (null)
2677 test_repo 19 .git "$here/19/wt"
2680 test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
2681 cat >19/expected <<EOF &&
2682 setup: git_dir: .git
2683 setup: worktree: $here/19/wt
2684 setup: cwd: $here/19
2685 setup: prefix: (null)
2687 test_repo 19 .git wt
2690 test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
2691 cat >19/expected <<EOF &&
2692 setup: git_dir: $here/19/.git
2693 setup: worktree: $here/19/wt
2694 setup: cwd: $here/19
2695 setup: prefix: (null)
2697 test_repo 19 "$here/19/.git" wt
2700 test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=wt at root' '
2701 cat >19/expected <<EOF &&
2702 setup: git_dir: $here/19/.git
2703 setup: worktree: $here/19/wt
2704 setup: cwd: $here/19
2705 setup: prefix: (null)
2707 test_repo 19 "$here/19/.git" "$here/19/wt"
2710 test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
2711 cat >19/sub/sub/expected <<EOF &&
2712 setup: git_dir: ../../.git
2713 setup: worktree: $here/19/wt
2714 setup: cwd: $here/19/sub/sub
2715 setup: prefix: (null)
2717 test_repo 19/sub/sub ../../.git "$here/19/wt"
2720 test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
2721 cat >19/sub/sub/expected <<EOF &&
2722 setup: git_dir: ../../.git
2723 setup: worktree: $here/19/wt
2724 setup: cwd: $here/19/sub/sub
2725 setup: prefix: (null)
2727 test_repo 19/sub/sub ../../.git ../../wt
2730 test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
2731 cat >19/sub/sub/expected <<EOF &&
2732 setup: git_dir: $here/19/.git
2733 setup: worktree: $here/19/wt
2734 setup: cwd: $here/19/sub/sub
2735 setup: prefix: (null)
2737 test_repo 19/sub/sub "$here/19/.git" ../../wt
2740 test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
2741 cat >19/sub/sub/expected <<EOF &&
2742 setup: git_dir: $here/19/.git
2743 setup: worktree: $here/19/wt
2744 setup: cwd: $here/19/sub/sub
2745 setup: prefix: (null)
2747 test_repo 19/sub/sub "$here/19/.git" "$here/19/wt"
2750 test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
2751 cat >19/expected <<EOF &&
2752 setup: git_dir: $here/19/.git
2753 setup: worktree: $here
2754 setup: cwd: $here
2755 setup: prefix: 19/
2757 test_repo 19 .git "$here"
2760 test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
2761 cat >19/expected <<EOF &&
2762 setup: git_dir: $here/19/.git
2763 setup: worktree: $here
2764 setup: cwd: $here
2765 setup: prefix: 19/
2767 test_repo 19 .git ..
2770 test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
2771 cat >19/expected <<EOF &&
2772 setup: git_dir: $here/19/.git
2773 setup: worktree: $here
2774 setup: cwd: $here
2775 setup: prefix: 19/
2777 test_repo 19 "$here/19/.git" ..
2780 test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=.. at root' '
2781 cat >19/expected <<EOF &&
2782 setup: git_dir: $here/19/.git
2783 setup: worktree: $here
2784 setup: cwd: $here
2785 setup: prefix: 19/
2787 test_repo 19 "$here/19/.git" "$here"
2790 test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
2791 cat >19/sub/sub/expected <<EOF &&
2792 setup: git_dir: $here/19/.git
2793 setup: worktree: $here
2794 setup: cwd: $here
2795 setup: prefix: 19/sub/sub/
2797 test_repo 19/sub/sub ../../.git "$here"
2800 test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
2801 cat >19/sub/sub/expected <<EOF &&
2802 setup: git_dir: $here/19/.git
2803 setup: worktree: $here
2804 setup: cwd: $here
2805 setup: prefix: 19/sub/sub/
2807 test_repo 19/sub/sub ../../.git ../../..
2810 test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
2811 cat >19/sub/sub/expected <<EOF &&
2812 setup: git_dir: $here/19/.git
2813 setup: worktree: $here
2814 setup: cwd: $here
2815 setup: prefix: 19/sub/sub/
2817 test_repo 19/sub/sub "$here/19/.git" ../../../
2820 test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
2821 cat >19/sub/sub/expected <<EOF &&
2822 setup: git_dir: $here/19/.git
2823 setup: worktree: $here
2824 setup: cwd: $here
2825 setup: prefix: 19/sub/sub/
2827 test_repo 19/sub/sub "$here/19/.git" "$here"
2831 # case #20.1
2833 ############################################################
2835 # Input:
2837 # - GIT_WORK_TREE is not set
2838 # - GIT_DIR is not set
2839 # - core.worktree is set
2840 # - .git is a directory
2841 # - cwd is inside .git
2843 # Output:
2845 # core.worktree is ignored -> #16.1
2847 test_expect_success '#20.1: setup' '
2848 sane_unset GIT_DIR GIT_WORK_TREE &&
2849 mkdir 20 20/sub &&
2850 cd 20 &&
2851 git init &&
2852 git config core.worktree non-existent &&
2853 mkdir .git/wt .git/wt/sub &&
2854 cd ..
2857 test_expect_success '#20.1: at .git' '
2858 cat >20/.git/expected <<EOF &&
2859 setup: git_dir: .
2860 setup: worktree: (null)
2861 setup: cwd: $here/20/.git
2862 setup: prefix: (null)
2864 test_repo 20/.git
2867 test_expect_success '#20.1: in .git/wt' '
2868 cat >20/.git/wt/expected <<EOF &&
2869 setup: git_dir: $here/20/.git
2870 setup: worktree: (null)
2871 setup: cwd: $here/20/.git/wt
2872 setup: prefix: (null)
2874 test_repo 20/.git/wt
2877 test_expect_success '#20.1: in .git/wt/sub' '
2878 cat >20/.git/wt/sub/expected <<EOF &&
2879 setup: git_dir: $here/20/.git
2880 setup: worktree: (null)
2881 setup: cwd: $here/20/.git/wt/sub
2882 setup: prefix: (null)
2884 test_repo 20/.git/wt/sub
2888 # case #20.2
2890 ############################################################
2892 # Input:
2894 # - GIT_WORK_TREE is not set
2895 # - GIT_DIR is not set
2896 # - core.worktree is set
2897 # - .git is a directory
2898 # - core.bare is set
2900 # Output:
2902 # core.worktree is ignored -> #16.2
2904 test_expect_success '#20.2: setup' '
2905 git config --file="$here/20/.git/config" core.bare true
2908 test_expect_success '#20.2: at .git' '
2909 cat >20/.git/expected <<EOF &&
2910 setup: git_dir: .
2911 setup: worktree: (null)
2912 setup: cwd: $here/20/.git
2913 setup: prefix: (null)
2915 test_repo 20/.git
2918 test_expect_success '#20.2: in .git/wt' '
2919 cat >20/.git/wt/expected <<EOF &&
2920 setup: git_dir: $here/20/.git
2921 setup: worktree: (null)
2922 setup: cwd: $here/20/.git/wt
2923 setup: prefix: (null)
2925 test_repo 20/.git/wt
2928 test_expect_success '#20.2: in .git/wt/sub' '
2929 cat >20/.git/wt/sub/expected <<EOF &&
2930 setup: git_dir: $here/20/.git
2931 setup: worktree: (null)
2932 setup: cwd: $here/20/.git/wt/sub
2933 setup: prefix: (null)
2935 test_repo 20/.git/wt/sub
2938 test_expect_success '#20.2: at root' '
2939 cat >20/expected <<EOF &&
2940 setup: git_dir: .git
2941 setup: worktree: (null)
2942 setup: cwd: $here/20
2943 setup: prefix: (null)
2945 test_repo 20
2948 test_expect_success '#20.2: in subdir' '
2949 cat >20/sub/expected <<EOF &&
2950 setup: git_dir: $here/20/.git
2951 setup: worktree: (null)
2952 setup: cwd: $here/20/sub
2953 setup: prefix: (null)
2955 test_repo 20/sub
2959 # case #21.1
2961 ############################################################
2963 # Input:
2965 # - GIT_WORK_TREE is set
2966 # - GIT_DIR is not set
2967 # - core.worktree is set
2968 # - .git is a directory
2969 # - cwd is inside .git
2971 # Output:
2973 # GIT_WORK_TREE/core.worktree are ignored -> #20.1
2975 test_expect_success '#21.1: setup' '
2976 sane_unset GIT_DIR GIT_WORK_TREE &&
2977 mkdir 21 21/sub &&
2978 cd 21 &&
2979 git init &&
2980 git config core.worktree non-existent &&
2981 GIT_WORK_TREE=non-existent-too &&
2982 export GIT_WORK_TREE &&
2983 mkdir .git/wt .git/wt/sub &&
2984 cd ..
2987 test_expect_success '#21.1: at .git' '
2988 cat >21/.git/expected <<EOF &&
2989 setup: git_dir: .
2990 setup: worktree: (null)
2991 setup: cwd: $here/21/.git
2992 setup: prefix: (null)
2994 test_repo 21/.git
2997 test_expect_success '#21.1: in .git/wt' '
2998 cat >21/.git/wt/expected <<EOF &&
2999 setup: git_dir: $here/21/.git
3000 setup: worktree: (null)
3001 setup: cwd: $here/21/.git/wt
3002 setup: prefix: (null)
3004 test_repo 21/.git/wt
3007 test_expect_success '#21.1: in .git/wt/sub' '
3008 cat >21/.git/wt/sub/expected <<EOF &&
3009 setup: git_dir: $here/21/.git
3010 setup: worktree: (null)
3011 setup: cwd: $here/21/.git/wt/sub
3012 setup: prefix: (null)
3014 test_repo 21/.git/wt/sub
3018 # case #21.2
3020 ############################################################
3022 # Input:
3024 # - GIT_WORK_TREE is set
3025 # - GIT_DIR is not set
3026 # - core.worktree is set
3027 # - .git is a directory
3028 # - core.bare is set
3030 # Output:
3032 # GIT_WORK_TREE/core.worktree are ignored -> #20.2
3034 test_expect_success '#21.2: setup' '
3035 git config --file="$here/21/.git/config" core.bare true
3038 test_expect_success '#21.2: at .git' '
3039 cat >21/.git/expected <<EOF &&
3040 setup: git_dir: .
3041 setup: worktree: (null)
3042 setup: cwd: $here/21/.git
3043 setup: prefix: (null)
3045 test_repo 21/.git
3048 test_expect_success '#21.2: in .git/wt' '
3049 cat >21/.git/wt/expected <<EOF &&
3050 setup: git_dir: $here/21/.git
3051 setup: worktree: (null)
3052 setup: cwd: $here/21/.git/wt
3053 setup: prefix: (null)
3055 test_repo 21/.git/wt
3058 test_expect_success '#21.2: in .git/wt/sub' '
3059 cat >21/.git/wt/sub/expected <<EOF &&
3060 setup: git_dir: $here/21/.git
3061 setup: worktree: (null)
3062 setup: cwd: $here/21/.git/wt/sub
3063 setup: prefix: (null)
3065 test_repo 21/.git/wt/sub
3068 test_expect_success '#21.2: at root' '
3069 cat >21/expected <<EOF &&
3070 setup: git_dir: .git
3071 setup: worktree: (null)
3072 setup: cwd: $here/21
3073 setup: prefix: (null)
3075 test_repo 21
3078 test_expect_success '#21.2: in subdir' '
3079 cat >21/sub/expected <<EOF &&
3080 setup: git_dir: $here/21/.git
3081 setup: worktree: (null)
3082 setup: cwd: $here/21/sub
3083 setup: prefix: (null)
3085 test_repo 21/sub
3089 # case #22.1
3091 ############################################################
3093 # Input:
3095 # - GIT_WORK_TREE is not set
3096 # - GIT_DIR is set
3097 # - core.worktree is set
3098 # - .git is a directory
3099 # - cwd is inside .git
3101 # Output:
3103 # bare attribute is ignored
3105 # - worktree is at core.worktree
3106 # - cwd is at worktree root
3107 # - prefix is calculated
3108 # - git_dir is at $GIT_DIR
3109 # - cwd can be outside worktree
3111 test_expect_success '#22.1: setup' '
3112 sane_unset GIT_DIR GIT_WORK_TREE &&
3113 mkdir 22 &&
3114 cd 22 &&
3115 git init &&
3116 mkdir .git/sub .git/wt .git/wt/sub &&
3117 cd ..
3120 test_expect_success '#22.1: GIT_DIR(rel), core.worktree=. at .git' '
3121 cat >22/.git/expected <<EOF &&
3122 setup: git_dir: .
3123 setup: worktree: $here/22/.git
3124 setup: cwd: $here/22/.git
3125 setup: prefix: (null)
3127 git config --file="$here/22/.git/config" core.worktree "$here/22/.git" &&
3128 test_repo 22/.git .
3131 test_expect_success '#22.1: GIT_DIR(rel), core.worktree=.(rel) at .git' '
3132 cat >22/.git/expected <<EOF &&
3133 setup: git_dir: .
3134 setup: worktree: $here/22/.git
3135 setup: cwd: $here/22/.git
3136 setup: prefix: (null)
3138 git config --file="$here/22/.git/config" core.worktree . &&
3139 test_repo 22/.git .
3142 test_expect_success '#22.1: GIT_DIR, core.worktree=. at .git' '
3143 cat >22/.git/expected <<EOF &&
3144 setup: git_dir: $here/22/.git
3145 setup: worktree: $here/22/.git
3146 setup: cwd: $here/22/.git
3147 setup: prefix: (null)
3149 git config --file="$here/22/.git/config" core.worktree "$here/22/.git" &&
3150 test_repo 22/.git "$here/22/.git"
3153 test_expect_success '#22.1: GIT_DIR, core.worktree=.(rel) at root' '
3154 cat >22/.git/expected <<EOF &&
3155 setup: git_dir: $here/22/.git
3156 setup: worktree: $here/22/.git
3157 setup: cwd: $here/22/.git
3158 setup: prefix: (null)
3160 git config --file="$here/22/.git/config" core.worktree . &&
3161 test_repo 22/.git "$here/22/.git"
3164 test_expect_success '#22.1: GIT_DIR(rel), core.worktree=. in .git/sub' '
3165 cat >22/.git/sub/expected <<EOF &&
3166 setup: git_dir: $here/22/.git
3167 setup: worktree: $here/22/.git
3168 setup: cwd: $here/22/.git
3169 setup: prefix: sub/
3171 git config --file="$here/22/.git/config" core.worktree "$here/22/.git" &&
3172 test_repo 22/.git/sub ..
3175 test_expect_success '#22.1: GIT_DIR(rel), core.worktree=.(rel) in .git/sub' '
3176 cat >22/.git/sub/expected <<EOF &&
3177 setup: git_dir: $here/22/.git
3178 setup: worktree: $here/22/.git
3179 setup: cwd: $here/22/.git
3180 setup: prefix: sub/
3182 git config --file="$here/22/.git/config" core.worktree . &&
3183 test_repo 22/.git/sub/ ..
3186 test_expect_success '#22.1: GIT_DIR, core.worktree=. in .git/sub' '
3187 cat >22/.git/sub/expected <<EOF &&
3188 setup: git_dir: $here/22/.git
3189 setup: worktree: $here/22/.git
3190 setup: cwd: $here/22/.git
3191 setup: prefix: sub/
3193 git config --file="$here/22/.git/config" core.worktree "$here/22/.git" &&
3194 test_repo 22/.git/sub "$here/22/.git"
3197 test_expect_success '#22.1: GIT_DIR, core.worktree=.(rel) in .git/sub' '
3198 cat >22/.git/sub/expected <<EOF &&
3199 setup: git_dir: $here/22/.git
3200 setup: worktree: $here/22/.git
3201 setup: cwd: $here/22/.git
3202 setup: prefix: sub/
3204 git config --file="$here/22/.git/config" core.worktree . &&
3205 test_repo 22/.git/sub "$here/22/.git"
3208 test_expect_success '#22.1: GIT_DIR(rel), core.worktree=wt at .git' '
3209 cat >22/.git/expected <<EOF &&
3210 setup: git_dir: .
3211 setup: worktree: $here/22/.git/wt
3212 setup: cwd: $here/22/.git
3213 setup: prefix: (null)
3215 git config --file="$here/22/.git/config" core.worktree "$here/22/.git/wt" &&
3216 test_repo 22/.git .
3219 test_expect_success '#22.1: GIT_DIR(rel), core.worktree=wt(rel) at .git' '
3220 cat >22/.git/expected <<EOF &&
3221 setup: git_dir: .
3222 setup: worktree: $here/22/.git/wt
3223 setup: cwd: $here/22/.git
3224 setup: prefix: (null)
3226 git config --file="$here/22/.git/config" core.worktree wt &&
3227 test_repo 22/.git .
3230 test_expect_success '#22.1: GIT_DIR, core.worktree=wt(rel) at .git' '
3231 cat >22/.git/expected <<EOF &&
3232 setup: git_dir: $here/22/.git
3233 setup: worktree: $here/22/.git/wt
3234 setup: cwd: $here/22/.git
3235 setup: prefix: (null)
3237 git config --file="$here/22/.git/config" core.worktree wt &&
3238 test_repo 22/.git "$here/22/.git"
3241 test_expect_success '#22.1: GIT_DIR, core.worktree=wt at .git' '
3242 cat >22/.git/expected <<EOF &&
3243 setup: git_dir: $here/22/.git
3244 setup: worktree: $here/22/.git/wt
3245 setup: cwd: $here/22/.git
3246 setup: prefix: (null)
3248 git config --file="$here/22/.git/config" core.worktree "$here/22/.git/wt" &&
3249 test_repo 22/.git "$here/22/.git"
3252 test_expect_success '#22.1: GIT_DIR(rel), core.worktree=wt in .git/sub' '
3253 cat >22/.git/sub/expected <<EOF &&
3254 setup: git_dir: ..
3255 setup: worktree: $here/22/.git/wt
3256 setup: cwd: $here/22/.git/sub
3257 setup: prefix: (null)
3259 git config --file="$here/22/.git/config" core.worktree "$here/22/.git/wt" &&
3260 test_repo 22/.git/sub ..
3263 test_expect_success '#22.1: GIT_DIR(rel), core.worktree=wt(rel) in .git/sub' '
3264 cat >22/.git/sub/expected <<EOF &&
3265 setup: git_dir: ..
3266 setup: worktree: $here/22/.git/wt
3267 setup: cwd: $here/22/.git/sub
3268 setup: prefix: (null)
3270 git config --file="$here/22/.git/config" core.worktree wt &&
3271 test_repo 22/.git/sub ..
3274 test_expect_success '#22.1: GIT_DIR, core.worktree=wt(rel) in .git/sub' '
3275 cat >22/.git/sub/expected <<EOF &&
3276 setup: git_dir: $here/22/.git
3277 setup: worktree: $here/22/.git/wt
3278 setup: cwd: $here/22/.git/sub
3279 setup: prefix: (null)
3281 git config --file="$here/22/.git/config" core.worktree wt &&
3282 test_repo 22/.git/sub "$here/22/.git"
3285 test_expect_success '#22.1: GIT_DIR, core.worktree=wt in .git/sub' '
3286 cat >22/.git/sub/expected <<EOF &&
3287 setup: git_dir: $here/22/.git
3288 setup: worktree: $here/22/.git/wt
3289 setup: cwd: $here/22/.git/sub
3290 setup: prefix: (null)
3292 git config --file="$here/22/.git/config" core.worktree "$here/22/.git/wt" &&
3293 test_repo 22/.git/sub "$here/22/.git"
3296 test_expect_success '#22.1: GIT_DIR(rel), core.worktree=.. at .git' '
3297 cat >22/.git/expected <<EOF &&
3298 setup: git_dir: $here/22/.git
3299 setup: worktree: $here/22
3300 setup: cwd: $here/22
3301 setup: prefix: .git/
3303 git config --file="$here/22/.git/config" core.worktree "$here/22" &&
3304 test_repo 22/.git .
3307 test_expect_success '#22.1: GIT_DIR(rel), core.worktree=..(rel) at .git' '
3308 cat >22/.git/expected <<EOF &&
3309 setup: git_dir: $here/22/.git
3310 setup: worktree: $here/22
3311 setup: cwd: $here/22
3312 setup: prefix: .git/
3314 git config --file="$here/22/.git/config" core.worktree .. &&
3315 test_repo 22/.git .
3318 test_expect_success '#22.1: GIT_DIR, core.worktree=..(rel) at .git' '
3319 cat >22/.git/expected <<EOF &&
3320 setup: git_dir: $here/22/.git
3321 setup: worktree: $here/22
3322 setup: cwd: $here/22
3323 setup: prefix: .git/
3325 git config --file="$here/22/.git/config" core.worktree .. &&
3326 test_repo 22/.git "$here/22/.git"
3329 test_expect_success '#22.1: GIT_DIR, core.worktree=.. at .git' '
3330 cat >22/.git/expected <<EOF &&
3331 setup: git_dir: $here/22/.git
3332 setup: worktree: $here/22
3333 setup: cwd: $here/22
3334 setup: prefix: .git/
3336 git config --file="$here/22/.git/config" core.worktree "$here/22" &&
3337 test_repo 22/.git "$here/22/.git"
3340 test_expect_success '#22.1: GIT_DIR(rel), core.worktree=.. in .git/sub' '
3341 cat >22/.git/sub/expected <<EOF &&
3342 setup: git_dir: $here/22/.git
3343 setup: worktree: $here/22
3344 setup: cwd: $here/22
3345 setup: prefix: .git/sub/
3347 git config --file="$here/22/.git/config" core.worktree "$here/22" &&
3348 test_repo 22/.git/sub ..
3351 test_expect_success '#22.1: GIT_DIR(rel), core.worktree=..(rel) in .git/sub' '
3352 cat >22/.git/sub/expected <<EOF &&
3353 setup: git_dir: $here/22/.git
3354 setup: worktree: $here/22
3355 setup: cwd: $here/22
3356 setup: prefix: .git/sub/
3358 git config --file="$here/22/.git/config" core.worktree .. &&
3359 test_repo 22/.git/sub ..
3362 test_expect_success '#22.1: GIT_DIR, core.worktree=..(rel) in .git/sub' '
3363 cat >22/.git/sub/expected <<EOF &&
3364 setup: git_dir: $here/22/.git
3365 setup: worktree: $here/22
3366 setup: cwd: $here/22
3367 setup: prefix: .git/sub/
3369 git config --file="$here/22/.git/config" core.worktree .. &&
3370 test_repo 22/.git/sub "$here/22/.git"
3373 test_expect_success '#22.1: GIT_DIR, core.worktree=.. in .git/sub' '
3374 cat >22/.git/sub/expected <<EOF &&
3375 setup: git_dir: $here/22/.git
3376 setup: worktree: $here/22
3377 setup: cwd: $here/22
3378 setup: prefix: .git/sub/
3380 git config --file="$here/22/.git/config" core.worktree "$here/22" &&
3381 test_repo 22/.git/sub "$here/22/.git"
3385 # case #22.2
3387 ############################################################
3389 # Input:
3391 # - GIT_WORK_TREE is not set
3392 # - GIT_DIR is set
3393 # - core.worktree is set
3394 # - .git is a directory
3395 # - core.bare is set
3397 # Output:
3399 # core.worktree and core.bare conflict, won't fly.
3401 test_expect_success '#22.2: setup' '
3402 git config --file="$here/22/.git/config" core.bare true
3405 test_expect_success '#22.2: at .git' '
3407 cd 22/.git &&
3408 GIT_DIR=. &&
3409 export GIT_DIR &&
3410 test_must_fail git symbolic-ref HEAD 2>result &&
3411 grep "core.bare and core.worktree do not make sense" result
3415 test_expect_success '#22.2: at root' '
3417 cd 22 &&
3418 GIT_DIR=.git &&
3419 export GIT_DIR &&
3420 test_must_fail git symbolic-ref HEAD 2>result &&
3421 grep "core.bare and core.worktree do not make sense" result
3426 # case #23
3428 ############################################################
3430 # Input:
3432 # - GIT_WORK_TREE is set
3433 # - GIT_DIR is set
3434 # - core.worktree is set
3435 # - .git is a directory
3436 # - core.bare is set
3438 # Output:
3440 # core.worktree is overridden by GIT_WORK_TREE -> #19
3442 test_expect_success '#23: setup' '
3443 sane_unset GIT_DIR GIT_WORK_TREE &&
3444 mkdir 23 23/sub 23/sub/sub 23.wt 23.wt/sub 23/wt 23/wt/sub &&
3445 cd 23 &&
3446 git init &&
3447 git config core.bare true &&
3448 git config core.worktree non-existent &&
3449 cd ..
3452 test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
3453 cat >23/expected <<EOF &&
3454 setup: git_dir: .git
3455 setup: worktree: $here/23
3456 setup: cwd: $here/23
3457 setup: prefix: (null)
3459 test_repo 23 .git "$here/23"
3462 test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
3463 cat >23/expected <<EOF &&
3464 setup: git_dir: .git
3465 setup: worktree: $here/23
3466 setup: cwd: $here/23
3467 setup: prefix: (null)
3469 test_repo 23 .git .
3472 test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=root at root' '
3473 cat >23/expected <<EOF &&
3474 setup: git_dir: $here/23/.git
3475 setup: worktree: $here/23
3476 setup: cwd: $here/23
3477 setup: prefix: (null)
3479 test_repo 23 "$here/23/.git" "$here/23"
3482 test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
3483 cat >23/expected <<EOF &&
3484 setup: git_dir: $here/23/.git
3485 setup: worktree: $here/23
3486 setup: cwd: $here/23
3487 setup: prefix: (null)
3489 test_repo 23 "$here/23/.git" .
3492 test_expect_success '#23: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
3493 cat >23/sub/sub/expected <<EOF &&
3494 setup: git_dir: $here/23/.git
3495 setup: worktree: $here/23
3496 setup: cwd: $here/23
3497 setup: prefix: sub/sub/
3499 test_repo 23/sub/sub ../../.git "$here/23"
3502 test_expect_success '#23: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
3503 cat >23/sub/sub/expected <<EOF &&
3504 setup: git_dir: $here/23/.git
3505 setup: worktree: $here/23
3506 setup: cwd: $here/23
3507 setup: prefix: sub/sub/
3509 test_repo 23/sub/sub ../../.git ../..
3512 test_expect_success '#23: GIT_DIR, GIT_WORKTREE=root in subdir' '
3513 cat >23/sub/expected <<EOF &&
3514 setup: git_dir: $here/23/.git
3515 setup: worktree: $here/23
3516 setup: cwd: $here/23
3517 setup: prefix: sub/
3519 test_repo 23/sub "$here/23/.git" "$here/23"
3522 test_expect_success '#23: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
3523 cat >23/sub/sub/expected <<EOF &&
3524 setup: git_dir: $here/23/.git
3525 setup: worktree: $here/23
3526 setup: cwd: $here/23
3527 setup: prefix: sub/sub/
3529 test_repo 23/sub/sub "$here/23/.git" ../..
3532 test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
3533 cat >23/expected <<EOF &&
3534 setup: git_dir: .git
3535 setup: worktree: $here/23/wt
3536 setup: cwd: $here/23
3537 setup: prefix: (null)
3539 test_repo 23 .git "$here/23/wt"
3542 test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
3543 cat >23/expected <<EOF &&
3544 setup: git_dir: .git
3545 setup: worktree: $here/23/wt
3546 setup: cwd: $here/23
3547 setup: prefix: (null)
3549 test_repo 23 .git wt
3552 test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
3553 cat >23/expected <<EOF &&
3554 setup: git_dir: $here/23/.git
3555 setup: worktree: $here/23/wt
3556 setup: cwd: $here/23
3557 setup: prefix: (null)
3559 test_repo 23 "$here/23/.git" wt
3562 test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt at root' '
3563 cat >23/expected <<EOF &&
3564 setup: git_dir: $here/23/.git
3565 setup: worktree: $here/23/wt
3566 setup: cwd: $here/23
3567 setup: prefix: (null)
3569 test_repo 23 "$here/23/.git" "$here/23/wt"
3572 test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
3573 cat >23/sub/sub/expected <<EOF &&
3574 setup: git_dir: ../../.git
3575 setup: worktree: $here/23/wt
3576 setup: cwd: $here/23/sub/sub
3577 setup: prefix: (null)
3579 test_repo 23/sub/sub ../../.git "$here/23/wt"
3582 test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
3583 cat >23/sub/sub/expected <<EOF &&
3584 setup: git_dir: ../../.git
3585 setup: worktree: $here/23/wt
3586 setup: cwd: $here/23/sub/sub
3587 setup: prefix: (null)
3589 test_repo 23/sub/sub ../../.git ../../wt
3592 test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
3593 cat >23/sub/sub/expected <<EOF &&
3594 setup: git_dir: $here/23/.git
3595 setup: worktree: $here/23/wt
3596 setup: cwd: $here/23/sub/sub
3597 setup: prefix: (null)
3599 test_repo 23/sub/sub "$here/23/.git" ../../wt
3602 test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
3603 cat >23/sub/sub/expected <<EOF &&
3604 setup: git_dir: $here/23/.git
3605 setup: worktree: $here/23/wt
3606 setup: cwd: $here/23/sub/sub
3607 setup: prefix: (null)
3609 test_repo 23/sub/sub "$here/23/.git" "$here/23/wt"
3612 test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
3613 cat >23/expected <<EOF &&
3614 setup: git_dir: $here/23/.git
3615 setup: worktree: $here
3616 setup: cwd: $here
3617 setup: prefix: 23/
3619 test_repo 23 .git "$here"
3622 test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
3623 cat >23/expected <<EOF &&
3624 setup: git_dir: $here/23/.git
3625 setup: worktree: $here
3626 setup: cwd: $here
3627 setup: prefix: 23/
3629 test_repo 23 .git ..
3632 test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
3633 cat >23/expected <<EOF &&
3634 setup: git_dir: $here/23/.git
3635 setup: worktree: $here
3636 setup: cwd: $here
3637 setup: prefix: 23/
3639 test_repo 23 "$here/23/.git" ..
3642 test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=.. at root' '
3643 cat >23/expected <<EOF &&
3644 setup: git_dir: $here/23/.git
3645 setup: worktree: $here
3646 setup: cwd: $here
3647 setup: prefix: 23/
3649 test_repo 23 "$here/23/.git" "$here"
3652 test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
3653 cat >23/sub/sub/expected <<EOF &&
3654 setup: git_dir: $here/23/.git
3655 setup: worktree: $here
3656 setup: cwd: $here
3657 setup: prefix: 23/sub/sub/
3659 test_repo 23/sub/sub ../../.git "$here"
3662 test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
3663 cat >23/sub/sub/expected <<EOF &&
3664 setup: git_dir: $here/23/.git
3665 setup: worktree: $here
3666 setup: cwd: $here
3667 setup: prefix: 23/sub/sub/
3669 test_repo 23/sub/sub ../../.git ../../..
3672 test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
3673 cat >23/sub/sub/expected <<EOF &&
3674 setup: git_dir: $here/23/.git
3675 setup: worktree: $here
3676 setup: cwd: $here
3677 setup: prefix: 23/sub/sub/
3679 test_repo 23/sub/sub "$here/23/.git" ../../../
3682 test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
3683 cat >23/sub/sub/expected <<EOF &&
3684 setup: git_dir: $here/23/.git
3685 setup: worktree: $here
3686 setup: cwd: $here
3687 setup: prefix: 23/sub/sub/
3689 test_repo 23/sub/sub "$here/23/.git" "$here"
3693 # case #24
3695 ############################################################
3697 # Input:
3699 # - GIT_WORK_TREE is not set
3700 # - GIT_DIR is not set
3701 # - core.worktree is not set
3702 # - .git is a file
3703 # - core.bare is set
3705 # Output:
3707 # #16.2 except git_dir is set according to .git file
3709 test_expect_success '#24: setup' '
3710 sane_unset GIT_DIR GIT_WORK_TREE &&
3711 mkdir 24 24/sub &&
3712 cd 24 &&
3713 git init &&
3714 git config core.bare true &&
3715 mv .git ../24.git &&
3716 echo gitdir: ../24.git >.git &&
3717 cd ..
3720 test_expect_success '#24: at root' '
3721 cat >24/expected <<EOF &&
3722 setup: git_dir: $here/24.git
3723 setup: worktree: (null)
3724 setup: cwd: $here/24
3725 setup: prefix: (null)
3727 test_repo 24
3730 test_expect_success '#24: in subdir' '
3731 cat >24/sub/expected <<EOF &&
3732 setup: git_dir: $here/24.git
3733 setup: worktree: (null)
3734 setup: cwd: $here/24/sub
3735 setup: prefix: (null)
3737 test_repo 24/sub
3741 # case #25
3743 ############################################################
3745 # Input:
3747 # - GIT_WORK_TREE is set
3748 # - GIT_DIR is not set
3749 # - core.worktree is not set
3750 # - .git is a file
3751 # - core.bare is set
3753 # Output:
3755 # #17.2 except git_dir is set according to .git file
3757 test_expect_success '#25: setup' '
3758 sane_unset GIT_DIR GIT_WORK_TREE &&
3759 mkdir 25 25/sub &&
3760 cd 25 &&
3761 git init &&
3762 git config core.bare true &&
3763 GIT_WORK_TREE=non-existent &&
3764 export GIT_WORK_TREE &&
3765 mv .git ../25.git &&
3766 echo gitdir: ../25.git >.git &&
3767 cd ..
3770 test_expect_success '#25: at root' '
3771 cat >25/expected <<EOF &&
3772 setup: git_dir: $here/25.git
3773 setup: worktree: (null)
3774 setup: cwd: $here/25
3775 setup: prefix: (null)
3777 test_repo 25
3780 test_expect_success '#25: in subdir' '
3781 cat >25/sub/expected <<EOF &&
3782 setup: git_dir: $here/25.git
3783 setup: worktree: (null)
3784 setup: cwd: $here/25/sub
3785 setup: prefix: (null)
3787 test_repo 25/sub
3791 # case #26
3793 ############################################################
3795 # Input:
3797 # - GIT_WORK_TREE is not set
3798 # - GIT_DIR is set
3799 # - core.worktree is not set
3800 # - .git is a file
3801 # - core.bare is set
3803 # Output:
3805 # #18 except git_dir is set according to .git file
3807 test_expect_success '#26: setup' '
3808 sane_unset GIT_DIR GIT_WORK_TREE &&
3809 mkdir 26 26/sub &&
3810 cd 26 &&
3811 git init &&
3812 git config core.bare true &&
3813 mv .git ../26.git &&
3814 echo gitdir: ../26.git >.git &&
3815 cd ..
3818 test_expect_success '#26: (rel) at root' '
3819 cat >26/expected <<EOF &&
3820 setup: git_dir: $here/26.git
3821 setup: worktree: (null)
3822 setup: cwd: $here/26
3823 setup: prefix: (null)
3825 test_repo 26 .git
3828 test_expect_success '#26: at root' '
3829 cat >26/expected <<EOF &&
3830 setup: git_dir: $here/26.git
3831 setup: worktree: (null)
3832 setup: cwd: $here/26
3833 setup: prefix: (null)
3835 test_repo 26 "$here/26/.git"
3838 test_expect_success '#26: (rel) in subdir' '
3839 cat >26/sub/expected <<EOF &&
3840 setup: git_dir: $here/26.git
3841 setup: worktree: (null)
3842 setup: cwd: $here/26/sub
3843 setup: prefix: (null)
3845 test_repo 26/sub ../.git
3848 test_expect_success '#26: in subdir' '
3849 cat >26/sub/expected <<EOF &&
3850 setup: git_dir: $here/26.git
3851 setup: worktree: (null)
3852 setup: cwd: $here/26/sub
3853 setup: prefix: (null)
3855 test_repo 26/sub "$here/26/.git"
3859 # case #27
3861 ############################################################
3863 # Input:
3865 # - GIT_WORK_TREE is set
3866 # - GIT_DIR is set
3867 # - .git is a file
3868 # - core.worktree is not set
3869 # - core.bare is set
3871 # Output:
3873 # #19 except git_dir is set according to .git file
3875 test_expect_success '#27: setup' '
3876 sane_unset GIT_DIR GIT_WORK_TREE &&
3877 mkdir 27 27/sub 27/sub/sub 27.wt 27.wt/sub 27/wt 27/wt/sub &&
3878 cd 27 &&
3879 git init &&
3880 git config core.bare true &&
3881 mv .git ../27.git &&
3882 echo gitdir: ../27.git >.git &&
3883 cd ..
3886 test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
3887 cat >27/expected <<EOF &&
3888 setup: git_dir: $here/27.git
3889 setup: worktree: $here/27
3890 setup: cwd: $here/27
3891 setup: prefix: (null)
3893 test_repo 27 .git "$here/27"
3896 test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
3897 cat >27/expected <<EOF &&
3898 setup: git_dir: $here/27.git
3899 setup: worktree: $here/27
3900 setup: cwd: $here/27
3901 setup: prefix: (null)
3903 test_repo 27 .git .
3906 test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=root at root' '
3907 cat >27/expected <<EOF &&
3908 setup: git_dir: $here/27.git
3909 setup: worktree: $here/27
3910 setup: cwd: $here/27
3911 setup: prefix: (null)
3913 test_repo 27 "$here/27/.git" "$here/27"
3916 test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
3917 cat >27/expected <<EOF &&
3918 setup: git_dir: $here/27.git
3919 setup: worktree: $here/27
3920 setup: cwd: $here/27
3921 setup: prefix: (null)
3923 test_repo 27 "$here/27/.git" .
3926 test_expect_success '#27: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
3927 cat >27/sub/sub/expected <<EOF &&
3928 setup: git_dir: $here/27.git
3929 setup: worktree: $here/27
3930 setup: cwd: $here/27
3931 setup: prefix: sub/sub/
3933 test_repo 27/sub/sub ../../.git "$here/27"
3936 test_expect_success '#27: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
3937 cat >27/sub/sub/expected <<EOF &&
3938 setup: git_dir: $here/27.git
3939 setup: worktree: $here/27
3940 setup: cwd: $here/27
3941 setup: prefix: sub/sub/
3943 test_repo 27/sub/sub ../../.git ../..
3946 test_expect_success '#27: GIT_DIR, GIT_WORKTREE=root in subdir' '
3947 cat >27/sub/expected <<EOF &&
3948 setup: git_dir: $here/27.git
3949 setup: worktree: $here/27
3950 setup: cwd: $here/27
3951 setup: prefix: sub/
3953 test_repo 27/sub "$here/27/.git" "$here/27"
3956 test_expect_success '#27: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
3957 cat >27/sub/sub/expected <<EOF &&
3958 setup: git_dir: $here/27.git
3959 setup: worktree: $here/27
3960 setup: cwd: $here/27
3961 setup: prefix: sub/sub/
3963 test_repo 27/sub/sub "$here/27/.git" ../..
3966 test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
3967 cat >27/expected <<EOF &&
3968 setup: git_dir: $here/27.git
3969 setup: worktree: $here/27/wt
3970 setup: cwd: $here/27
3971 setup: prefix: (null)
3973 test_repo 27 .git "$here/27/wt"
3976 test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
3977 cat >27/expected <<EOF &&
3978 setup: git_dir: $here/27.git
3979 setup: worktree: $here/27/wt
3980 setup: cwd: $here/27
3981 setup: prefix: (null)
3983 test_repo 27 .git wt
3986 test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
3987 cat >27/expected <<EOF &&
3988 setup: git_dir: $here/27.git
3989 setup: worktree: $here/27/wt
3990 setup: cwd: $here/27
3991 setup: prefix: (null)
3993 test_repo 27 "$here/27/.git" wt
3996 test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=wt at root' '
3997 cat >27/expected <<EOF &&
3998 setup: git_dir: $here/27.git
3999 setup: worktree: $here/27/wt
4000 setup: cwd: $here/27
4001 setup: prefix: (null)
4003 test_repo 27 "$here/27/.git" "$here/27/wt"
4006 test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
4007 cat >27/sub/sub/expected <<EOF &&
4008 setup: git_dir: $here/27.git
4009 setup: worktree: $here/27/wt
4010 setup: cwd: $here/27/sub/sub
4011 setup: prefix: (null)
4013 test_repo 27/sub/sub ../../.git "$here/27/wt"
4016 test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
4017 cat >27/sub/sub/expected <<EOF &&
4018 setup: git_dir: $here/27.git
4019 setup: worktree: $here/27/wt
4020 setup: cwd: $here/27/sub/sub
4021 setup: prefix: (null)
4023 test_repo 27/sub/sub ../../.git ../../wt
4026 test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
4027 cat >27/sub/sub/expected <<EOF &&
4028 setup: git_dir: $here/27.git
4029 setup: worktree: $here/27/wt
4030 setup: cwd: $here/27/sub/sub
4031 setup: prefix: (null)
4033 test_repo 27/sub/sub "$here/27/.git" ../../wt
4036 test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
4037 cat >27/sub/sub/expected <<EOF &&
4038 setup: git_dir: $here/27.git
4039 setup: worktree: $here/27/wt
4040 setup: cwd: $here/27/sub/sub
4041 setup: prefix: (null)
4043 test_repo 27/sub/sub "$here/27/.git" "$here/27/wt"
4046 test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
4047 cat >27/expected <<EOF &&
4048 setup: git_dir: $here/27.git
4049 setup: worktree: $here
4050 setup: cwd: $here
4051 setup: prefix: 27/
4053 test_repo 27 .git "$here"
4056 test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
4057 cat >27/expected <<EOF &&
4058 setup: git_dir: $here/27.git
4059 setup: worktree: $here
4060 setup: cwd: $here
4061 setup: prefix: 27/
4063 test_repo 27 .git ..
4066 test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
4067 cat >27/expected <<EOF &&
4068 setup: git_dir: $here/27.git
4069 setup: worktree: $here
4070 setup: cwd: $here
4071 setup: prefix: 27/
4073 test_repo 27 "$here/27/.git" ..
4076 test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=.. at root' '
4077 cat >27/expected <<EOF &&
4078 setup: git_dir: $here/27.git
4079 setup: worktree: $here
4080 setup: cwd: $here
4081 setup: prefix: 27/
4083 test_repo 27 "$here/27/.git" "$here"
4086 test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
4087 cat >27/sub/sub/expected <<EOF &&
4088 setup: git_dir: $here/27.git
4089 setup: worktree: $here
4090 setup: cwd: $here
4091 setup: prefix: 27/sub/sub/
4093 test_repo 27/sub/sub ../../.git "$here"
4096 test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
4097 cat >27/sub/sub/expected <<EOF &&
4098 setup: git_dir: $here/27.git
4099 setup: worktree: $here
4100 setup: cwd: $here
4101 setup: prefix: 27/sub/sub/
4103 test_repo 27/sub/sub ../../.git ../../..
4106 test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
4107 cat >27/sub/sub/expected <<EOF &&
4108 setup: git_dir: $here/27.git
4109 setup: worktree: $here
4110 setup: cwd: $here
4111 setup: prefix: 27/sub/sub/
4113 test_repo 27/sub/sub "$here/27/.git" ../../../
4116 test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
4117 cat >27/sub/sub/expected <<EOF &&
4118 setup: git_dir: $here/27.git
4119 setup: worktree: $here
4120 setup: cwd: $here
4121 setup: prefix: 27/sub/sub/
4123 test_repo 27/sub/sub "$here/27/.git" "$here"
4127 # case #28
4129 ############################################################
4131 # Input:
4133 # - GIT_WORK_TREE is not set
4134 # - GIT_DIR is not set
4135 # - core.worktree is set
4136 # - .git is a file
4137 # - core.bare is set
4139 # Output:
4141 # core.worktree is ignored -> #24
4143 test_expect_success '#28: setup' '
4144 sane_unset GIT_DIR GIT_WORK_TREE &&
4145 mkdir 28 28/sub &&
4146 cd 28 &&
4147 git init &&
4148 git config core.bare true &&
4149 git config core.worktree non-existent &&
4150 mv .git ../28.git &&
4151 echo gitdir: ../28.git >.git &&
4152 cd ..
4155 test_expect_success '#28: at root' '
4156 cat >28/expected <<EOF &&
4157 setup: git_dir: $here/28.git
4158 setup: worktree: (null)
4159 setup: cwd: $here/28
4160 setup: prefix: (null)
4162 test_repo 28
4165 test_expect_success '#28: in subdir' '
4166 cat >28/sub/expected <<EOF &&
4167 setup: git_dir: $here/28.git
4168 setup: worktree: (null)
4169 setup: cwd: $here/28/sub
4170 setup: prefix: (null)
4172 test_repo 28/sub
4176 # case #29
4178 ############################################################
4180 # Input:
4182 # - GIT_WORK_TREE is set
4183 # - GIT_DIR is not set
4184 # - core.worktree is set
4185 # - .git is a file
4186 # - core.bare is set
4188 # Output:
4190 # GIT_WORK_TREE/core.worktree are ignored -> #28
4192 test_expect_success '#29: setup' '
4193 sane_unset GIT_DIR GIT_WORK_TREE &&
4194 mkdir 29 29/sub &&
4195 cd 29 &&
4196 git init &&
4197 git config core.bare true &&
4198 GIT_WORK_TREE=non-existent &&
4199 export GIT_WORK_TREE &&
4200 mv .git ../29.git &&
4201 echo gitdir: ../29.git >.git &&
4202 cd ..
4205 test_expect_success '#29: at root' '
4206 cat >29/expected <<EOF &&
4207 setup: git_dir: $here/29.git
4208 setup: worktree: (null)
4209 setup: cwd: $here/29
4210 setup: prefix: (null)
4212 test_repo 29
4215 test_expect_success '#29: in subdir' '
4216 cat >29/sub/expected <<EOF &&
4217 setup: git_dir: $here/29.git
4218 setup: worktree: (null)
4219 setup: cwd: $here/29/sub
4220 setup: prefix: (null)
4222 test_repo 29/sub
4226 # case #30
4228 ############################################################
4230 # Input:
4232 # - GIT_WORK_TREE is not set
4233 # - GIT_DIR is set
4234 # - core.worktree is set
4235 # - .git is a file
4236 # - core.bare is set
4238 # Output:
4240 # core.worktree and core.bare conflict, won't fly.
4242 test_expect_success '#30: setup' '
4243 sane_unset GIT_DIR GIT_WORK_TREE &&
4244 mkdir 30 &&
4245 cd 30 &&
4246 git init &&
4247 git config core.bare true &&
4248 git config core.worktree non-existent &&
4249 mv .git ../30.git &&
4250 echo gitdir: ../30.git >.git &&
4251 cd ..
4254 test_expect_success '#30: at root' '
4256 cd 30 &&
4257 GIT_DIR=.git &&
4258 export GIT_DIR &&
4259 test_must_fail git symbolic-ref HEAD 2>result &&
4260 grep "core.bare and core.worktree do not make sense" result
4265 # case #31
4267 ############################################################
4269 # Input:
4271 # - GIT_WORK_TREE is set
4272 # - GIT_DIR is set
4273 # - core.worktree is set
4274 # - .git is a file
4275 # - core.bare is set
4277 # Output:
4279 # #23 except git_dir is set according to .git file
4281 test_expect_success '#31: setup' '
4282 sane_unset GIT_DIR GIT_WORK_TREE &&
4283 mkdir 31 31/sub 31/sub/sub 31.wt 31.wt/sub 31/wt 31/wt/sub &&
4284 cd 31 &&
4285 git init &&
4286 git config core.bare true &&
4287 git config core.worktree non-existent &&
4288 mv .git ../31.git &&
4289 echo gitdir: ../31.git >.git &&
4290 cd ..
4293 test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
4294 cat >31/expected <<EOF &&
4295 setup: git_dir: $here/31.git
4296 setup: worktree: $here/31
4297 setup: cwd: $here/31
4298 setup: prefix: (null)
4300 test_repo 31 .git "$here/31"
4303 test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
4304 cat >31/expected <<EOF &&
4305 setup: git_dir: $here/31.git
4306 setup: worktree: $here/31
4307 setup: cwd: $here/31
4308 setup: prefix: (null)
4310 test_repo 31 .git .
4313 test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=root at root' '
4314 cat >31/expected <<EOF &&
4315 setup: git_dir: $here/31.git
4316 setup: worktree: $here/31
4317 setup: cwd: $here/31
4318 setup: prefix: (null)
4320 test_repo 31 "$here/31/.git" "$here/31"
4323 test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
4324 cat >31/expected <<EOF &&
4325 setup: git_dir: $here/31.git
4326 setup: worktree: $here/31
4327 setup: cwd: $here/31
4328 setup: prefix: (null)
4330 test_repo 31 "$here/31/.git" .
4333 test_expect_success '#31: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
4334 cat >31/sub/sub/expected <<EOF &&
4335 setup: git_dir: $here/31.git
4336 setup: worktree: $here/31
4337 setup: cwd: $here/31
4338 setup: prefix: sub/sub/
4340 test_repo 31/sub/sub ../../.git "$here/31"
4343 test_expect_success '#31: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
4344 cat >31/sub/sub/expected <<EOF &&
4345 setup: git_dir: $here/31.git
4346 setup: worktree: $here/31
4347 setup: cwd: $here/31
4348 setup: prefix: sub/sub/
4350 test_repo 31/sub/sub ../../.git ../..
4353 test_expect_success '#31: GIT_DIR, GIT_WORKTREE=root in subdir' '
4354 cat >31/sub/expected <<EOF &&
4355 setup: git_dir: $here/31.git
4356 setup: worktree: $here/31
4357 setup: cwd: $here/31
4358 setup: prefix: sub/
4360 test_repo 31/sub "$here/31/.git" "$here/31"
4363 test_expect_success '#31: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
4364 cat >31/sub/sub/expected <<EOF &&
4365 setup: git_dir: $here/31.git
4366 setup: worktree: $here/31
4367 setup: cwd: $here/31
4368 setup: prefix: sub/sub/
4370 test_repo 31/sub/sub "$here/31/.git" ../..
4373 test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
4374 cat >31/expected <<EOF &&
4375 setup: git_dir: $here/31.git
4376 setup: worktree: $here/31/wt
4377 setup: cwd: $here/31
4378 setup: prefix: (null)
4380 test_repo 31 .git "$here/31/wt"
4383 test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
4384 cat >31/expected <<EOF &&
4385 setup: git_dir: $here/31.git
4386 setup: worktree: $here/31/wt
4387 setup: cwd: $here/31
4388 setup: prefix: (null)
4390 test_repo 31 .git wt
4393 test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
4394 cat >31/expected <<EOF &&
4395 setup: git_dir: $here/31.git
4396 setup: worktree: $here/31/wt
4397 setup: cwd: $here/31
4398 setup: prefix: (null)
4400 test_repo 31 "$here/31/.git" wt
4403 test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=wt at root' '
4404 cat >31/expected <<EOF &&
4405 setup: git_dir: $here/31.git
4406 setup: worktree: $here/31/wt
4407 setup: cwd: $here/31
4408 setup: prefix: (null)
4410 test_repo 31 "$here/31/.git" "$here/31/wt"
4413 test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
4414 cat >31/sub/sub/expected <<EOF &&
4415 setup: git_dir: $here/31.git
4416 setup: worktree: $here/31/wt
4417 setup: cwd: $here/31/sub/sub
4418 setup: prefix: (null)
4420 test_repo 31/sub/sub ../../.git "$here/31/wt"
4423 test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
4424 cat >31/sub/sub/expected <<EOF &&
4425 setup: git_dir: $here/31.git
4426 setup: worktree: $here/31/wt
4427 setup: cwd: $here/31/sub/sub
4428 setup: prefix: (null)
4430 test_repo 31/sub/sub ../../.git ../../wt
4433 test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
4434 cat >31/sub/sub/expected <<EOF &&
4435 setup: git_dir: $here/31.git
4436 setup: worktree: $here/31/wt
4437 setup: cwd: $here/31/sub/sub
4438 setup: prefix: (null)
4440 test_repo 31/sub/sub "$here/31/.git" ../../wt
4443 test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
4444 cat >31/sub/sub/expected <<EOF &&
4445 setup: git_dir: $here/31.git
4446 setup: worktree: $here/31/wt
4447 setup: cwd: $here/31/sub/sub
4448 setup: prefix: (null)
4450 test_repo 31/sub/sub "$here/31/.git" "$here/31/wt"
4453 test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
4454 cat >31/expected <<EOF &&
4455 setup: git_dir: $here/31.git
4456 setup: worktree: $here
4457 setup: cwd: $here
4458 setup: prefix: 31/
4460 test_repo 31 .git "$here"
4463 test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
4464 cat >31/expected <<EOF &&
4465 setup: git_dir: $here/31.git
4466 setup: worktree: $here
4467 setup: cwd: $here
4468 setup: prefix: 31/
4470 test_repo 31 .git ..
4473 test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
4474 cat >31/expected <<EOF &&
4475 setup: git_dir: $here/31.git
4476 setup: worktree: $here
4477 setup: cwd: $here
4478 setup: prefix: 31/
4480 test_repo 31 "$here/31/.git" ..
4483 test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=.. at root' '
4484 cat >31/expected <<EOF &&
4485 setup: git_dir: $here/31.git
4486 setup: worktree: $here
4487 setup: cwd: $here
4488 setup: prefix: 31/
4490 test_repo 31 "$here/31/.git" "$here"
4493 test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
4494 cat >31/sub/sub/expected <<EOF &&
4495 setup: git_dir: $here/31.git
4496 setup: worktree: $here
4497 setup: cwd: $here
4498 setup: prefix: 31/sub/sub/
4500 test_repo 31/sub/sub ../../.git "$here"
4503 test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
4504 cat >31/sub/sub/expected <<EOF &&
4505 setup: git_dir: $here/31.git
4506 setup: worktree: $here
4507 setup: cwd: $here
4508 setup: prefix: 31/sub/sub/
4510 test_repo 31/sub/sub ../../.git ../../..
4513 test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
4514 cat >31/sub/sub/expected <<EOF &&
4515 setup: git_dir: $here/31.git
4516 setup: worktree: $here
4517 setup: cwd: $here
4518 setup: prefix: 31/sub/sub/
4520 test_repo 31/sub/sub "$here/31/.git" ../../../
4523 test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
4524 cat >31/sub/sub/expected <<EOF &&
4525 setup: git_dir: $here/31.git
4526 setup: worktree: $here
4527 setup: cwd: $here
4528 setup: prefix: 31/sub/sub/
4530 test_repo 31/sub/sub "$here/31/.git" "$here"
4533 test_done