3 test_description='Tests of cwd/prefix/worktree/gitdir setup in all cases'
8 # A few rules for repo setup:
10 # 1. GIT_DIR is relative to user's cwd. --git-dir is equivalent to
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
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
38 # 11. When user's cwd is outside worktree, cwd remains unchanged,
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 &&
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
56 # Bit 2 = core.worktree
57 # Bit 3 = .git is a file
59 # Case# = encoding of the above 5 bits
64 ############################################################
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
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 unset GIT_DIR GIT_WORK_TREE &&
85 cd 0 && git init && cd ..
88 test_expect_success '#0: at root' '
89 cat >0/expected <<EOF &&
91 setup: worktree: $TRASH_DIRECTORY/0
92 setup: cwd: $TRASH_DIRECTORY/0
98 test_expect_success '#0: in subdir' '
99 cat >0/sub/expected <<EOF &&
101 setup: worktree: $TRASH_DIRECTORY/0
102 setup: cwd: $TRASH_DIRECTORY/0
111 ############################################################
115 # - GIT_WORK_TREE is set
116 # - GIT_DIR is not set
117 # - core.worktree is not set
118 # - .git is a directory
119 # - core.bare is not set, cwd is outside .git
123 # GIT_WORK_TREE is ignored -> #0
125 test_expect_success '#1: setup' '
126 unset GIT_DIR GIT_WORK_TREE &&
127 mkdir 1 1/sub 1.wt 1.wt/sub 1/wt 1/wt/sub &&
130 GIT_WORK_TREE=non-existent &&
131 export GIT_WORK_TREE &&
135 test_expect_failure '#1: at root' '
136 cat >1/expected <<EOF &&
138 setup: worktree: $TRASH_DIRECTORY/1
139 setup: cwd: $TRASH_DIRECTORY/1
140 setup: prefix: (null)
145 test_expect_failure '#1: in subdir' '
146 cat >1/sub/expected <<EOF &&
148 setup: worktree: $TRASH_DIRECTORY/1
149 setup: cwd: $TRASH_DIRECTORY/1
158 ############################################################
162 # - GIT_WORK_TREE is not set
164 # - core.worktree is not set
165 # - .git is a directory
166 # - core.bare is not set, cwd is outside .git
170 # - worktree is at original cwd
173 # - git_dir is set to $GIT_DIR
174 # - cwd can't be outside worktree
176 test_expect_success '#2: setup' '
177 unset GIT_DIR GIT_WORK_TREE &&
179 cd 2 && git init && cd ..
182 test_expect_success '#2: at root' '
183 cat >2/expected <<EOF &&
184 setup: git_dir: $TRASH_DIRECTORY/2/.git
185 setup: worktree: $TRASH_DIRECTORY/2
186 setup: cwd: $TRASH_DIRECTORY/2
187 setup: prefix: (null)
189 test_repo 2 "$TRASH_DIRECTORY/2/.git"
192 test_expect_success '#2: in subdir' '
193 cat >2/sub/expected <<EOF &&
194 setup: git_dir: $TRASH_DIRECTORY/2/.git
195 setup: worktree: $TRASH_DIRECTORY/2/sub
196 setup: cwd: $TRASH_DIRECTORY/2/sub
197 setup: prefix: (null)
199 test_repo 2/sub "$TRASH_DIRECTORY/2/.git"
202 test_expect_success '#2: relative GIT_DIR at root' '
203 cat >2/expected <<EOF &&
205 setup: worktree: $TRASH_DIRECTORY/2
206 setup: cwd: $TRASH_DIRECTORY/2
207 setup: prefix: (null)
212 test_expect_success '#2: relative GIT_DIR in subdir' '
213 cat >2/sub/expected <<EOF &&
214 setup: git_dir: ../.git
215 setup: worktree: $TRASH_DIRECTORY/2/sub
216 setup: cwd: $TRASH_DIRECTORY/2/sub
217 setup: prefix: (null)
219 test_repo 2/sub ../.git
225 ############################################################
229 # - GIT_WORK_TREE is set
231 # - core.worktree is not set
232 # - .git is a directory
233 # - core.bare is not set, cwd is outside .git
237 # - worktree is set to $GIT_WORK_TREE
238 # - cwd is at worktree root
239 # - prefix is calculated
240 # - git_dir is set to $GIT_DIR
241 # - cwd can be outside worktree
243 test_expect_success '#3: setup' '
244 unset GIT_DIR GIT_WORK_TREE &&
245 mkdir 3 3/sub 3/sub/sub 3.wt 3.wt/sub 3/wt 3/wt/sub &&
246 cd 3 && git init && cd ..
249 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
250 cat >3/expected <<EOF &&
252 setup: worktree: $TRASH_DIRECTORY/3
253 setup: cwd: $TRASH_DIRECTORY/3
254 setup: prefix: (null)
256 test_repo 3 .git "$TRASH_DIRECTORY/3"
259 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
260 cat >3/expected <<EOF &&
262 setup: worktree: $TRASH_DIRECTORY/3
263 setup: cwd: $TRASH_DIRECTORY/3
264 setup: prefix: (null)
269 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=root at root' '
270 cat >3/expected <<EOF &&
271 setup: git_dir: $TRASH_DIRECTORY/3/.git
272 setup: worktree: $TRASH_DIRECTORY/3
273 setup: cwd: $TRASH_DIRECTORY/3
274 setup: prefix: (null)
276 test_repo 3 "$TRASH_DIRECTORY/3/.git" "$TRASH_DIRECTORY/3"
279 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
280 cat >3/expected <<EOF &&
281 setup: git_dir: $TRASH_DIRECTORY/3/.git
282 setup: worktree: $TRASH_DIRECTORY/3
283 setup: cwd: $TRASH_DIRECTORY/3
284 setup: prefix: (null)
286 test_repo 3 "$TRASH_DIRECTORY/3/.git" .
289 test_expect_success '#3: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
290 cat >3/sub/sub/expected <<EOF &&
291 setup: git_dir: $TRASH_DIRECTORY/3/.git
292 setup: worktree: $TRASH_DIRECTORY/3
293 setup: cwd: $TRASH_DIRECTORY/3
294 setup: prefix: sub/sub/
296 test_repo 3/sub/sub ../../.git "$TRASH_DIRECTORY/3"
299 test_expect_success '#3: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
300 cat >3/sub/sub/expected <<EOF &&
301 setup: git_dir: $TRASH_DIRECTORY/3/.git
302 setup: worktree: $TRASH_DIRECTORY/3
303 setup: cwd: $TRASH_DIRECTORY/3
304 setup: prefix: sub/sub/
306 test_repo 3/sub/sub ../../.git ../..
309 test_expect_success '#3: GIT_DIR, GIT_WORKTREE=root in subdir' '
310 cat >3/sub/expected <<EOF &&
311 setup: git_dir: $TRASH_DIRECTORY/3/.git
312 setup: worktree: $TRASH_DIRECTORY/3
313 setup: cwd: $TRASH_DIRECTORY/3
316 test_repo 3/sub "$TRASH_DIRECTORY/3/.git" "$TRASH_DIRECTORY/3"
319 test_expect_success '#3: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
320 cat >3/sub/sub/expected <<EOF &&
321 setup: git_dir: $TRASH_DIRECTORY/3/.git
322 setup: worktree: $TRASH_DIRECTORY/3
323 setup: cwd: $TRASH_DIRECTORY/3
324 setup: prefix: sub/sub/
326 test_repo 3/sub/sub "$TRASH_DIRECTORY/3/.git" ../..
329 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
330 cat >3/expected <<EOF &&
332 setup: worktree: $TRASH_DIRECTORY/3/wt
333 setup: cwd: $TRASH_DIRECTORY/3
334 setup: prefix: (null)
336 test_repo 3 .git "$TRASH_DIRECTORY/3/wt"
339 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
340 cat >3/expected <<EOF &&
342 setup: worktree: $TRASH_DIRECTORY/3/wt
343 setup: cwd: $TRASH_DIRECTORY/3
344 setup: prefix: (null)
349 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
350 cat >3/expected <<EOF &&
351 setup: git_dir: $TRASH_DIRECTORY/3/.git
352 setup: worktree: $TRASH_DIRECTORY/3/wt
353 setup: cwd: $TRASH_DIRECTORY/3
354 setup: prefix: (null)
356 test_repo 3 "$TRASH_DIRECTORY/3/.git" wt
359 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=wt at root' '
360 cat >3/expected <<EOF &&
361 setup: git_dir: $TRASH_DIRECTORY/3/.git
362 setup: worktree: $TRASH_DIRECTORY/3/wt
363 setup: cwd: $TRASH_DIRECTORY/3
364 setup: prefix: (null)
366 test_repo 3 "$TRASH_DIRECTORY/3/.git" "$TRASH_DIRECTORY/3/wt"
369 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
370 cat >3/sub/sub/expected <<EOF &&
371 setup: git_dir: ../../.git
372 setup: worktree: $TRASH_DIRECTORY/3/wt
373 setup: cwd: $TRASH_DIRECTORY/3/sub/sub
374 setup: prefix: (null)
376 test_repo 3/sub/sub ../../.git "$TRASH_DIRECTORY/3/wt"
379 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
380 cat >3/sub/sub/expected <<EOF &&
381 setup: git_dir: ../../.git
382 setup: worktree: $TRASH_DIRECTORY/3/wt
383 setup: cwd: $TRASH_DIRECTORY/3/sub/sub
384 setup: prefix: (null)
386 test_repo 3/sub/sub ../../.git ../../wt
389 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
390 cat >3/sub/sub/expected <<EOF &&
391 setup: git_dir: $TRASH_DIRECTORY/3/.git
392 setup: worktree: $TRASH_DIRECTORY/3/wt
393 setup: cwd: $TRASH_DIRECTORY/3/sub/sub
394 setup: prefix: (null)
396 test_repo 3/sub/sub "$TRASH_DIRECTORY/3/.git" ../../wt
399 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
400 cat >3/sub/sub/expected <<EOF &&
401 setup: git_dir: $TRASH_DIRECTORY/3/.git
402 setup: worktree: $TRASH_DIRECTORY/3/wt
403 setup: cwd: $TRASH_DIRECTORY/3/sub/sub
404 setup: prefix: (null)
406 test_repo 3/sub/sub "$TRASH_DIRECTORY/3/.git" "$TRASH_DIRECTORY/3/wt"
409 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
410 cat >3/expected <<EOF &&
411 setup: git_dir: $TRASH_DIRECTORY/3/.git
412 setup: worktree: $TRASH_DIRECTORY
413 setup: cwd: $TRASH_DIRECTORY
416 test_repo 3 .git "$TRASH_DIRECTORY"
419 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
420 cat >3/expected <<EOF &&
421 setup: git_dir: $TRASH_DIRECTORY/3/.git
422 setup: worktree: $TRASH_DIRECTORY
423 setup: cwd: $TRASH_DIRECTORY
429 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
430 cat >3/expected <<EOF &&
431 setup: git_dir: $TRASH_DIRECTORY/3/.git
432 setup: worktree: $TRASH_DIRECTORY
433 setup: cwd: $TRASH_DIRECTORY
436 test_repo 3 "$TRASH_DIRECTORY/3/.git" ..
439 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=.. at root' '
440 cat >3/expected <<EOF &&
441 setup: git_dir: $TRASH_DIRECTORY/3/.git
442 setup: worktree: $TRASH_DIRECTORY
443 setup: cwd: $TRASH_DIRECTORY
446 test_repo 3 "$TRASH_DIRECTORY/3/.git" "$TRASH_DIRECTORY"
449 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
450 cat >3/sub/sub/expected <<EOF &&
451 setup: git_dir: $TRASH_DIRECTORY/3/.git
452 setup: worktree: $TRASH_DIRECTORY
453 setup: cwd: $TRASH_DIRECTORY
454 setup: prefix: 3/sub/sub/
456 test_repo 3/sub/sub ../../.git "$TRASH_DIRECTORY"
459 test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
460 cat >3/sub/sub/expected <<EOF &&
461 setup: git_dir: $TRASH_DIRECTORY/3/.git
462 setup: worktree: $TRASH_DIRECTORY
463 setup: cwd: $TRASH_DIRECTORY
464 setup: prefix: 3/sub/sub/
466 test_repo 3/sub/sub ../../.git ../../..
469 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
470 cat >3/sub/sub/expected <<EOF &&
471 setup: git_dir: $TRASH_DIRECTORY/3/.git
472 setup: worktree: $TRASH_DIRECTORY
473 setup: cwd: $TRASH_DIRECTORY
474 setup: prefix: 3/sub/sub/
476 test_repo 3/sub/sub "$TRASH_DIRECTORY/3/.git" ../../../
479 test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
480 cat >3/sub/sub/expected <<EOF &&
481 setup: git_dir: $TRASH_DIRECTORY/3/.git
482 setup: worktree: $TRASH_DIRECTORY
483 setup: cwd: $TRASH_DIRECTORY
484 setup: prefix: 3/sub/sub/
486 test_repo 3/sub/sub "$TRASH_DIRECTORY/3/.git" "$TRASH_DIRECTORY"
492 ############################################################
496 # - GIT_WORK_TREE is not set
497 # - GIT_DIR is not set
498 # - core.worktree is set
499 # - .git is a directory
500 # - core.bare is not set, cwd is outside .git
504 # core.worktree is ignored -> #0
506 test_expect_success '#4: setup' '
507 unset GIT_DIR GIT_WORK_TREE &&
511 git config core.worktree non-existent &&
515 test_expect_failure '#4: at root' '
516 cat >4/expected <<EOF &&
518 setup: worktree: $TRASH_DIRECTORY/4
519 setup: cwd: $TRASH_DIRECTORY/4
520 setup: prefix: (null)
525 test_expect_failure '#4: in subdir' '
526 cat >4/sub/expected <<EOF &&
528 setup: worktree: $TRASH_DIRECTORY/4
529 setup: cwd: $TRASH_DIRECTORY/4
538 ############################################################
542 # - GIT_WORK_TREE is set
543 # - GIT_DIR is not set
544 # - core.worktree is set
545 # - .git is a directory
546 # - core.bare is not set, cwd is outside .git
550 # GIT_WORK_TREE/core.worktree are ignored -> #0
552 test_expect_success '#5: setup' '
553 unset GIT_DIR GIT_WORK_TREE &&
557 git config core.worktree non-existent &&
558 GIT_WORK_TREE=non-existent-too &&
559 export GIT_WORK_TREE &&
563 test_expect_failure '#5: at root' '
564 cat >5/expected <<EOF &&
566 setup: worktree: $TRASH_DIRECTORY/5
567 setup: cwd: $TRASH_DIRECTORY/5
568 setup: prefix: (null)
573 test_expect_failure '#5: in subdir' '
574 cat >5/sub/expected <<EOF &&
576 setup: worktree: $TRASH_DIRECTORY/5
577 setup: cwd: $TRASH_DIRECTORY/5
586 ############################################################
590 # - GIT_WORK_TREE is not set
592 # - core.worktree is set
593 # - .git is a directory
594 # - core.bare is not set, cwd is outside .git
598 # - worktree is at core.worktree
599 # - cwd is at worktree root
600 # - prefix is calculated
601 # - git_dir is at $GIT_DIR
602 # - cwd can be outside worktree
604 test_expect_success '#6: setup' '
605 unset GIT_DIR GIT_WORK_TREE &&
606 mkdir 6 6/sub 6/sub/sub 6.wt 6.wt/sub 6/wt 6/wt/sub &&
607 cd 6 && git init && cd ..
610 test_expect_success '#6: GIT_DIR(rel), core.worktree=.. at root' '
611 cat >6/expected <<EOF &&
613 setup: worktree: $TRASH_DIRECTORY/6
614 setup: cwd: $TRASH_DIRECTORY/6
615 setup: prefix: (null)
617 git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6" &&
621 test_expect_success '#6: GIT_DIR(rel), core.worktree=..(rel) at root' '
622 cat >6/expected <<EOF &&
624 setup: worktree: $TRASH_DIRECTORY/6
625 setup: cwd: $TRASH_DIRECTORY/6
626 setup: prefix: (null)
628 git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree .. &&
632 test_expect_success '#6: GIT_DIR, core.worktree=.. at root' '
633 cat >6/expected <<EOF &&
634 setup: git_dir: $TRASH_DIRECTORY/6/.git
635 setup: worktree: $TRASH_DIRECTORY/6
636 setup: cwd: $TRASH_DIRECTORY/6
637 setup: prefix: (null)
639 git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6" &&
640 test_repo 6 "$TRASH_DIRECTORY/6/.git"
643 test_expect_success '#6: GIT_DIR, core.worktree=..(rel) at root' '
644 cat >6/expected <<EOF &&
645 setup: git_dir: $TRASH_DIRECTORY/6/.git
646 setup: worktree: $TRASH_DIRECTORY/6
647 setup: cwd: $TRASH_DIRECTORY/6
648 setup: prefix: (null)
650 git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree .. &&
651 test_repo 6 "$TRASH_DIRECTORY/6/.git"
654 test_expect_failure '#6: GIT_DIR(rel), core.worktree=.. in subdir' '
655 cat >6/sub/sub/expected <<EOF &&
656 setup: git_dir: $TRASH_DIRECTORY/6/.git
657 setup: worktree: $TRASH_DIRECTORY/6
658 setup: cwd: $TRASH_DIRECTORY/6
659 setup: prefix: sub/sub/
661 git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6" &&
662 test_repo 6/sub/sub ../../.git
665 test_expect_failure '#6: GIT_DIR(rel), core.worktree=..(rel) in subdir' '
666 cat >6/sub/sub/expected <<EOF &&
667 setup: git_dir: $TRASH_DIRECTORY/6/.git
668 setup: worktree: $TRASH_DIRECTORY/6
669 setup: cwd: $TRASH_DIRECTORY/6
670 setup: prefix: sub/sub/
672 git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree .. &&
673 test_repo 6/sub/sub ../../.git
676 test_expect_success '#6: GIT_DIR, core.worktree=.. in subdir' '
677 cat >6/sub/expected <<EOF &&
678 setup: git_dir: $TRASH_DIRECTORY/6/.git
679 setup: worktree: $TRASH_DIRECTORY/6
680 setup: cwd: $TRASH_DIRECTORY/6
683 git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6" &&
684 test_repo 6/sub "$TRASH_DIRECTORY/6/.git"
687 test_expect_success '#6: GIT_DIR, core.worktree=..(rel) in subdir' '
688 cat >6/sub/sub/expected <<EOF &&
689 setup: git_dir: $TRASH_DIRECTORY/6/.git
690 setup: worktree: $TRASH_DIRECTORY/6
691 setup: cwd: $TRASH_DIRECTORY/6
692 setup: prefix: sub/sub/
694 git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree .. &&
695 test_repo 6/sub/sub "$TRASH_DIRECTORY/6/.git"
698 test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt at root' '
699 cat >6/expected <<EOF &&
701 setup: worktree: $TRASH_DIRECTORY/6/wt
702 setup: cwd: $TRASH_DIRECTORY/6
703 setup: prefix: (null)
705 git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6/wt" &&
709 test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt(rel) at root' '
710 cat >6/expected <<EOF &&
712 setup: worktree: $TRASH_DIRECTORY/6/wt
713 setup: cwd: $TRASH_DIRECTORY/6
714 setup: prefix: (null)
716 git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../wt &&
720 test_expect_success '#6: GIT_DIR, core.worktree=../wt(rel) at root' '
721 cat >6/expected <<EOF &&
722 setup: git_dir: $TRASH_DIRECTORY/6/.git
723 setup: worktree: $TRASH_DIRECTORY/6/wt
724 setup: cwd: $TRASH_DIRECTORY/6
725 setup: prefix: (null)
727 git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../wt &&
728 test_repo 6 "$TRASH_DIRECTORY/6/.git"
731 test_expect_success '#6: GIT_DIR, core.worktree=../wt at root' '
732 cat >6/expected <<EOF &&
733 setup: git_dir: $TRASH_DIRECTORY/6/.git
734 setup: worktree: $TRASH_DIRECTORY/6/wt
735 setup: cwd: $TRASH_DIRECTORY/6
736 setup: prefix: (null)
738 git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6/wt" &&
739 test_repo 6 "$TRASH_DIRECTORY/6/.git"
742 test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt in subdir' '
743 cat >6/sub/sub/expected <<EOF &&
744 setup: git_dir: ../../.git
745 setup: worktree: $TRASH_DIRECTORY/6/wt
746 setup: cwd: $TRASH_DIRECTORY/6/sub/sub
747 setup: prefix: (null)
749 git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6/wt" &&
750 test_repo 6/sub/sub ../../.git
753 test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt(rel) in subdir' '
754 cat >6/sub/sub/expected <<EOF &&
755 setup: git_dir: ../../.git
756 setup: worktree: $TRASH_DIRECTORY/6/wt
757 setup: cwd: $TRASH_DIRECTORY/6/sub/sub
758 setup: prefix: (null)
760 git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../wt &&
761 test_repo 6/sub/sub ../../.git
764 test_expect_success '#6: GIT_DIR, core.worktree=../wt(rel) in subdir' '
765 cat >6/sub/sub/expected <<EOF &&
766 setup: git_dir: $TRASH_DIRECTORY/6/.git
767 setup: worktree: $TRASH_DIRECTORY/6/wt
768 setup: cwd: $TRASH_DIRECTORY/6/sub/sub
769 setup: prefix: (null)
771 git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../wt &&
772 test_repo 6/sub/sub "$TRASH_DIRECTORY/6/.git"
775 test_expect_success '#6: GIT_DIR, core.worktree=../wt in subdir' '
776 cat >6/sub/sub/expected <<EOF &&
777 setup: git_dir: $TRASH_DIRECTORY/6/.git
778 setup: worktree: $TRASH_DIRECTORY/6/wt
779 setup: cwd: $TRASH_DIRECTORY/6/sub/sub
780 setup: prefix: (null)
782 git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY/6/wt" &&
783 test_repo 6/sub/sub "$TRASH_DIRECTORY/6/.git"
786 test_expect_failure '#6: GIT_DIR(rel), core.worktree=../.. at root' '
787 cat >6/expected <<EOF &&
788 setup: git_dir: $TRASH_DIRECTORY/6/.git
789 setup: worktree: $TRASH_DIRECTORY
790 setup: cwd: $TRASH_DIRECTORY
793 git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY" &&
797 test_expect_failure '#6: GIT_DIR(rel), core.worktree=../..(rel) at root' '
798 cat >6/expected <<EOF &&
799 setup: git_dir: $TRASH_DIRECTORY/6/.git
800 setup: worktree: $TRASH_DIRECTORY
801 setup: cwd: $TRASH_DIRECTORY
804 git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../../ &&
808 test_expect_success '#6: GIT_DIR, core.worktree=../..(rel) at root' '
809 cat >6/expected <<EOF &&
810 setup: git_dir: $TRASH_DIRECTORY/6/.git
811 setup: worktree: $TRASH_DIRECTORY
812 setup: cwd: $TRASH_DIRECTORY
815 git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../../ &&
816 test_repo 6 "$TRASH_DIRECTORY/6/.git"
819 test_expect_success '#6: GIT_DIR, core.worktree=../.. at root' '
820 cat >6/expected <<EOF &&
821 setup: git_dir: $TRASH_DIRECTORY/6/.git
822 setup: worktree: $TRASH_DIRECTORY
823 setup: cwd: $TRASH_DIRECTORY
826 git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY" &&
827 test_repo 6 "$TRASH_DIRECTORY/6/.git"
830 test_expect_failure '#6: GIT_DIR(rel), core.worktree=../.. in subdir' '
831 cat >6/sub/sub/expected <<EOF &&
832 setup: git_dir: $TRASH_DIRECTORY/6/.git
833 setup: worktree: $TRASH_DIRECTORY
834 setup: cwd: $TRASH_DIRECTORY
835 setup: prefix: 6/sub/sub/
837 git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY" &&
838 test_repo 6/sub/sub ../../.git
841 test_expect_failure '#6: GIT_DIR(rel), core.worktree=../..(rel) in subdir' '
842 cat >6/sub/sub/expected <<EOF &&
843 setup: git_dir: $TRASH_DIRECTORY/6/.git
844 setup: worktree: $TRASH_DIRECTORY
845 setup: cwd: $TRASH_DIRECTORY
846 setup: prefix: 6/sub/sub/
848 git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../.. &&
849 test_repo 6/sub/sub ../../.git
852 test_expect_success '#6: GIT_DIR, core.worktree=../..(rel) in subdir' '
853 cat >6/sub/sub/expected <<EOF &&
854 setup: git_dir: $TRASH_DIRECTORY/6/.git
855 setup: worktree: $TRASH_DIRECTORY
856 setup: cwd: $TRASH_DIRECTORY
857 setup: prefix: 6/sub/sub/
859 git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree ../.. &&
860 test_repo 6/sub/sub "$TRASH_DIRECTORY/6/.git"
863 test_expect_success '#6: GIT_DIR, core.worktree=../.. in subdir' '
864 cat >6/sub/sub/expected <<EOF &&
865 setup: git_dir: $TRASH_DIRECTORY/6/.git
866 setup: worktree: $TRASH_DIRECTORY
867 setup: cwd: $TRASH_DIRECTORY
868 setup: prefix: 6/sub/sub/
870 git config --file="$TRASH_DIRECTORY/6/.git/config" core.worktree "$TRASH_DIRECTORY" &&
871 test_repo 6/sub/sub "$TRASH_DIRECTORY/6/.git"
877 ############################################################
881 # - GIT_WORK_TREE is set
883 # - core.worktree is set
884 # - .git is a directory
885 # - core.bare is not set, cwd is outside .git
889 # core.worktree is overridden by GIT_WORK_TREE -> #3
891 test_expect_success '#7: setup' '
892 unset GIT_DIR GIT_WORK_TREE &&
893 mkdir 7 7/sub 7/sub/sub 7.wt 7.wt/sub 7/wt 7/wt/sub &&
896 git config core.worktree non-existent &&
900 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
901 cat >7/expected <<EOF &&
903 setup: worktree: $TRASH_DIRECTORY/7
904 setup: cwd: $TRASH_DIRECTORY/7
905 setup: prefix: (null)
907 test_repo 7 .git "$TRASH_DIRECTORY/7"
910 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
911 cat >7/expected <<EOF &&
913 setup: worktree: $TRASH_DIRECTORY/7
914 setup: cwd: $TRASH_DIRECTORY/7
915 setup: prefix: (null)
920 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=root at root' '
921 cat >7/expected <<EOF &&
922 setup: git_dir: $TRASH_DIRECTORY/7/.git
923 setup: worktree: $TRASH_DIRECTORY/7
924 setup: cwd: $TRASH_DIRECTORY/7
925 setup: prefix: (null)
927 test_repo 7 "$TRASH_DIRECTORY/7/.git" "$TRASH_DIRECTORY/7"
930 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
931 cat >7/expected <<EOF &&
932 setup: git_dir: $TRASH_DIRECTORY/7/.git
933 setup: worktree: $TRASH_DIRECTORY/7
934 setup: cwd: $TRASH_DIRECTORY/7
935 setup: prefix: (null)
937 test_repo 7 "$TRASH_DIRECTORY/7/.git" .
940 test_expect_success '#7: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
941 cat >7/sub/sub/expected <<EOF &&
942 setup: git_dir: $TRASH_DIRECTORY/7/.git
943 setup: worktree: $TRASH_DIRECTORY/7
944 setup: cwd: $TRASH_DIRECTORY/7
945 setup: prefix: sub/sub/
947 test_repo 7/sub/sub ../../.git "$TRASH_DIRECTORY/7"
950 test_expect_success '#7: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
951 cat >7/sub/sub/expected <<EOF &&
952 setup: git_dir: $TRASH_DIRECTORY/7/.git
953 setup: worktree: $TRASH_DIRECTORY/7
954 setup: cwd: $TRASH_DIRECTORY/7
955 setup: prefix: sub/sub/
957 test_repo 7/sub/sub ../../.git ../..
960 test_expect_success '#7: GIT_DIR, GIT_WORKTREE=root in subdir' '
961 cat >7/sub/expected <<EOF &&
962 setup: git_dir: $TRASH_DIRECTORY/7/.git
963 setup: worktree: $TRASH_DIRECTORY/7
964 setup: cwd: $TRASH_DIRECTORY/7
967 test_repo 7/sub "$TRASH_DIRECTORY/7/.git" "$TRASH_DIRECTORY/7"
970 test_expect_success '#7: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
971 cat >7/sub/sub/expected <<EOF &&
972 setup: git_dir: $TRASH_DIRECTORY/7/.git
973 setup: worktree: $TRASH_DIRECTORY/7
974 setup: cwd: $TRASH_DIRECTORY/7
975 setup: prefix: sub/sub/
977 test_repo 7/sub/sub "$TRASH_DIRECTORY/7/.git" ../..
980 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
981 cat >7/expected <<EOF &&
983 setup: worktree: $TRASH_DIRECTORY/7/wt
984 setup: cwd: $TRASH_DIRECTORY/7
985 setup: prefix: (null)
987 test_repo 7 .git "$TRASH_DIRECTORY/7/wt"
990 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
991 cat >7/expected <<EOF &&
993 setup: worktree: $TRASH_DIRECTORY/7/wt
994 setup: cwd: $TRASH_DIRECTORY/7
995 setup: prefix: (null)
1000 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
1001 cat >7/expected <<EOF &&
1002 setup: git_dir: $TRASH_DIRECTORY/7/.git
1003 setup: worktree: $TRASH_DIRECTORY/7/wt
1004 setup: cwd: $TRASH_DIRECTORY/7
1005 setup: prefix: (null)
1007 test_repo 7 "$TRASH_DIRECTORY/7/.git" wt
1010 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=wt at root' '
1011 cat >7/expected <<EOF &&
1012 setup: git_dir: $TRASH_DIRECTORY/7/.git
1013 setup: worktree: $TRASH_DIRECTORY/7/wt
1014 setup: cwd: $TRASH_DIRECTORY/7
1015 setup: prefix: (null)
1017 test_repo 7 "$TRASH_DIRECTORY/7/.git" "$TRASH_DIRECTORY/7/wt"
1020 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
1021 cat >7/sub/sub/expected <<EOF &&
1022 setup: git_dir: ../../.git
1023 setup: worktree: $TRASH_DIRECTORY/7/wt
1024 setup: cwd: $TRASH_DIRECTORY/7/sub/sub
1025 setup: prefix: (null)
1027 test_repo 7/sub/sub ../../.git "$TRASH_DIRECTORY/7/wt"
1030 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
1031 cat >7/sub/sub/expected <<EOF &&
1032 setup: git_dir: ../../.git
1033 setup: worktree: $TRASH_DIRECTORY/7/wt
1034 setup: cwd: $TRASH_DIRECTORY/7/sub/sub
1035 setup: prefix: (null)
1037 test_repo 7/sub/sub ../../.git ../../wt
1040 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
1041 cat >7/sub/sub/expected <<EOF &&
1042 setup: git_dir: $TRASH_DIRECTORY/7/.git
1043 setup: worktree: $TRASH_DIRECTORY/7/wt
1044 setup: cwd: $TRASH_DIRECTORY/7/sub/sub
1045 setup: prefix: (null)
1047 test_repo 7/sub/sub "$TRASH_DIRECTORY/7/.git" ../../wt
1050 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
1051 cat >7/sub/sub/expected <<EOF &&
1052 setup: git_dir: $TRASH_DIRECTORY/7/.git
1053 setup: worktree: $TRASH_DIRECTORY/7/wt
1054 setup: cwd: $TRASH_DIRECTORY/7/sub/sub
1055 setup: prefix: (null)
1057 test_repo 7/sub/sub "$TRASH_DIRECTORY/7/.git" "$TRASH_DIRECTORY/7/wt"
1060 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
1061 cat >7/expected <<EOF &&
1062 setup: git_dir: $TRASH_DIRECTORY/7/.git
1063 setup: worktree: $TRASH_DIRECTORY
1064 setup: cwd: $TRASH_DIRECTORY
1067 test_repo 7 .git "$TRASH_DIRECTORY"
1070 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
1071 cat >7/expected <<EOF &&
1072 setup: git_dir: $TRASH_DIRECTORY/7/.git
1073 setup: worktree: $TRASH_DIRECTORY
1074 setup: cwd: $TRASH_DIRECTORY
1080 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
1081 cat >7/expected <<EOF &&
1082 setup: git_dir: $TRASH_DIRECTORY/7/.git
1083 setup: worktree: $TRASH_DIRECTORY
1084 setup: cwd: $TRASH_DIRECTORY
1087 test_repo 7 "$TRASH_DIRECTORY/7/.git" ..
1090 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=.. at root' '
1091 cat >7/expected <<EOF &&
1092 setup: git_dir: $TRASH_DIRECTORY/7/.git
1093 setup: worktree: $TRASH_DIRECTORY
1094 setup: cwd: $TRASH_DIRECTORY
1097 test_repo 7 "$TRASH_DIRECTORY/7/.git" "$TRASH_DIRECTORY"
1100 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
1101 cat >7/sub/sub/expected <<EOF &&
1102 setup: git_dir: $TRASH_DIRECTORY/7/.git
1103 setup: worktree: $TRASH_DIRECTORY
1104 setup: cwd: $TRASH_DIRECTORY
1105 setup: prefix: 7/sub/sub/
1107 test_repo 7/sub/sub ../../.git "$TRASH_DIRECTORY"
1110 test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
1111 cat >7/sub/sub/expected <<EOF &&
1112 setup: git_dir: $TRASH_DIRECTORY/7/.git
1113 setup: worktree: $TRASH_DIRECTORY
1114 setup: cwd: $TRASH_DIRECTORY
1115 setup: prefix: 7/sub/sub/
1117 test_repo 7/sub/sub ../../.git ../../..
1120 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
1121 cat >7/sub/sub/expected <<EOF &&
1122 setup: git_dir: $TRASH_DIRECTORY/7/.git
1123 setup: worktree: $TRASH_DIRECTORY
1124 setup: cwd: $TRASH_DIRECTORY
1125 setup: prefix: 7/sub/sub/
1127 test_repo 7/sub/sub "$TRASH_DIRECTORY/7/.git" ../../../
1130 test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
1131 cat >7/sub/sub/expected <<EOF &&
1132 setup: git_dir: $TRASH_DIRECTORY/7/.git
1133 setup: worktree: $TRASH_DIRECTORY
1134 setup: cwd: $TRASH_DIRECTORY
1135 setup: prefix: 7/sub/sub/
1137 test_repo 7/sub/sub "$TRASH_DIRECTORY/7/.git" "$TRASH_DIRECTORY"
1143 ############################################################
1147 # - GIT_WORK_TREE is not set
1148 # - GIT_DIR is not set
1149 # - core.worktree is not set
1151 # - core.bare is not set, cwd is outside .git
1155 # #0 except that git_dir is set by .git file
1157 test_expect_success '#8: setup' '
1158 unset GIT_DIR GIT_WORK_TREE &&
1163 echo gitdir: ../8.git >.git &&
1167 test_expect_success '#8: at root' '
1168 cat >8/expected <<EOF &&
1169 setup: git_dir: $TRASH_DIRECTORY/8.git
1170 setup: worktree: $TRASH_DIRECTORY/8
1171 setup: cwd: $TRASH_DIRECTORY/8
1172 setup: prefix: (null)
1177 test_expect_success '#8: in subdir' '
1178 cat >8/sub/expected <<EOF &&
1179 setup: git_dir: $TRASH_DIRECTORY/8.git
1180 setup: worktree: $TRASH_DIRECTORY/8
1181 setup: cwd: $TRASH_DIRECTORY/8
1190 ############################################################
1194 # - GIT_WORK_TREE is set
1195 # - GIT_DIR is not set
1196 # - core.worktree is not set
1198 # - core.bare is not set, cwd is outside .git
1202 # #1 except that git_dir is set by .git file
1204 test_expect_success '#9: setup' '
1205 unset GIT_DIR GIT_WORK_TREE &&
1206 mkdir 9 9/sub 9.wt 9.wt/sub 9/wt 9/wt/sub &&
1210 echo gitdir: ../9.git >.git &&
1211 GIT_WORK_TREE=non-existent &&
1212 export GIT_WORK_TREE &&
1216 test_expect_failure '#9: at root' '
1217 cat >9/expected <<EOF &&
1218 setup: git_dir: $TRASH_DIRECTORY/9.git
1219 setup: worktree: $TRASH_DIRECTORY/9
1220 setup: cwd: $TRASH_DIRECTORY/9
1221 setup: prefix: (null)
1226 test_expect_failure '#9: in subdir' '
1227 cat >9/sub/expected <<EOF &&
1228 setup: git_dir: $TRASH_DIRECTORY/9.git
1229 setup: worktree: $TRASH_DIRECTORY/9
1230 setup: cwd: $TRASH_DIRECTORY/9
1239 ############################################################
1243 # - GIT_WORK_TREE is not set
1245 # - core.worktree is not set
1247 # - core.bare is not set, cwd is outside .git
1251 # #2 except that git_dir is set by .git file
1253 test_expect_success '#10: setup' '
1254 unset GIT_DIR GIT_WORK_TREE &&
1258 mv .git ../10.git &&
1259 echo gitdir: ../10.git >.git &&
1263 test_expect_failure '#10: at root' '
1264 cat >10/expected <<EOF &&
1265 setup: git_dir: $TRASH_DIRECTORY/10.git
1266 setup: worktree: $TRASH_DIRECTORY/10
1267 setup: cwd: $TRASH_DIRECTORY/10
1268 setup: prefix: (null)
1270 test_repo 10 "$TRASH_DIRECTORY/10/.git"
1273 test_expect_failure '#10: in subdir' '
1274 cat >10/sub/expected <<EOF &&
1275 setup: git_dir: $TRASH_DIRECTORY/10.git
1276 setup: worktree: $TRASH_DIRECTORY/10/sub
1277 setup: cwd: $TRASH_DIRECTORY/10/sub
1278 setup: prefix: (null)
1280 test_repo 10/sub "$TRASH_DIRECTORY/10/.git"
1283 test_expect_failure '#10: relative GIT_DIR at root' '
1284 cat >10/expected <<EOF &&
1285 setup: git_dir: $TRASH_DIRECTORY/10.git
1286 setup: worktree: $TRASH_DIRECTORY/10
1287 setup: cwd: $TRASH_DIRECTORY/10
1288 setup: prefix: (null)
1293 test_expect_failure '#10: relative GIT_DIR in subdir' '
1294 cat >10/sub/expected <<EOF &&
1295 setup: git_dir: $TRASH_DIRECTORY/10.git
1296 setup: worktree: $TRASH_DIRECTORY/10/sub
1297 setup: cwd: $TRASH_DIRECTORY/10/sub
1298 setup: prefix: (null)
1300 test_repo 10/sub ../.git
1306 ############################################################
1310 # - GIT_WORK_TREE is set
1312 # - core.worktree is not set
1314 # - core.bare is not set, cwd is outside .git
1318 # #3 except that git_dir is set by .git file
1320 test_expect_success '#11: setup' '
1321 unset GIT_DIR GIT_WORK_TREE &&
1322 mkdir 11 11/sub 11/sub/sub 11.wt 11.wt/sub 11/wt 11/wt/sub &&
1325 mv .git ../11.git &&
1326 echo gitdir: ../11.git >.git &&
1330 test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
1331 cat >11/expected <<EOF &&
1332 setup: git_dir: $TRASH_DIRECTORY/11.git
1333 setup: worktree: $TRASH_DIRECTORY/11
1334 setup: cwd: $TRASH_DIRECTORY/11
1335 setup: prefix: (null)
1337 test_repo 11 .git "$TRASH_DIRECTORY/11"
1340 test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
1341 cat >11/expected <<EOF &&
1342 setup: git_dir: $TRASH_DIRECTORY/11.git
1343 setup: worktree: $TRASH_DIRECTORY/11
1344 setup: cwd: $TRASH_DIRECTORY/11
1345 setup: prefix: (null)
1350 test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=root at root' '
1351 cat >11/expected <<EOF &&
1352 setup: git_dir: $TRASH_DIRECTORY/11.git
1353 setup: worktree: $TRASH_DIRECTORY/11
1354 setup: cwd: $TRASH_DIRECTORY/11
1355 setup: prefix: (null)
1357 test_repo 11 "$TRASH_DIRECTORY/11/.git" "$TRASH_DIRECTORY/11"
1360 test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
1361 cat >11/expected <<EOF &&
1362 setup: git_dir: $TRASH_DIRECTORY/11.git
1363 setup: worktree: $TRASH_DIRECTORY/11
1364 setup: cwd: $TRASH_DIRECTORY/11
1365 setup: prefix: (null)
1367 test_repo 11 "$TRASH_DIRECTORY/11/.git" .
1370 test_expect_failure '#11: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
1371 cat >11/sub/sub/expected <<EOF &&
1372 setup: git_dir: $TRASH_DIRECTORY/11.git
1373 setup: worktree: $TRASH_DIRECTORY/11
1374 setup: cwd: $TRASH_DIRECTORY/11
1375 setup: prefix: sub/sub/
1377 test_repo 11/sub/sub ../../.git "$TRASH_DIRECTORY/11"
1380 test_expect_failure '#11: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
1381 cat >11/sub/sub/expected <<EOF &&
1382 setup: git_dir: $TRASH_DIRECTORY/11.git
1383 setup: worktree: $TRASH_DIRECTORY/11
1384 setup: cwd: $TRASH_DIRECTORY/11
1385 setup: prefix: sub/sub/
1387 test_repo 11/sub/sub ../../.git ../..
1390 test_expect_failure '#11: GIT_DIR, GIT_WORKTREE=root in subdir' '
1391 cat >11/sub/expected <<EOF &&
1392 setup: git_dir: $TRASH_DIRECTORY/11.git
1393 setup: worktree: $TRASH_DIRECTORY/11
1394 setup: cwd: $TRASH_DIRECTORY/11
1397 test_repo 11/sub "$TRASH_DIRECTORY/11/.git" "$TRASH_DIRECTORY/11"
1400 test_expect_failure '#11: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
1401 cat >11/sub/sub/expected <<EOF &&
1402 setup: git_dir: $TRASH_DIRECTORY/11.git
1403 setup: worktree: $TRASH_DIRECTORY/11
1404 setup: cwd: $TRASH_DIRECTORY/11
1405 setup: prefix: sub/sub/
1407 test_repo 11/sub/sub "$TRASH_DIRECTORY/11/.git" ../..
1410 test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
1411 cat >11/expected <<EOF &&
1412 setup: git_dir: $TRASH_DIRECTORY/11.git
1413 setup: worktree: $TRASH_DIRECTORY/11/wt
1414 setup: cwd: $TRASH_DIRECTORY/11
1415 setup: prefix: (null)
1417 test_repo 11 .git "$TRASH_DIRECTORY/11/wt"
1420 test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
1421 cat >11/expected <<EOF &&
1422 setup: git_dir: $TRASH_DIRECTORY/11.git
1423 setup: worktree: $TRASH_DIRECTORY/11/wt
1424 setup: cwd: $TRASH_DIRECTORY/11
1425 setup: prefix: (null)
1427 test_repo 11 .git wt
1430 test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
1431 cat >11/expected <<EOF &&
1432 setup: git_dir: $TRASH_DIRECTORY/11.git
1433 setup: worktree: $TRASH_DIRECTORY/11/wt
1434 setup: cwd: $TRASH_DIRECTORY/11
1435 setup: prefix: (null)
1437 test_repo 11 "$TRASH_DIRECTORY/11/.git" wt
1440 test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=wt at root' '
1441 cat >11/expected <<EOF &&
1442 setup: git_dir: $TRASH_DIRECTORY/11.git
1443 setup: worktree: $TRASH_DIRECTORY/11/wt
1444 setup: cwd: $TRASH_DIRECTORY/11
1445 setup: prefix: (null)
1447 test_repo 11 "$TRASH_DIRECTORY/11/.git" "$TRASH_DIRECTORY/11/wt"
1450 test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
1451 cat >11/sub/sub/expected <<EOF &&
1452 setup: git_dir: $TRASH_DIRECTORY/11.git
1453 setup: worktree: $TRASH_DIRECTORY/11/wt
1454 setup: cwd: $TRASH_DIRECTORY/11/sub/sub
1455 setup: prefix: (null)
1457 test_repo 11/sub/sub ../../.git "$TRASH_DIRECTORY/11/wt"
1460 test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
1461 cat >11/sub/sub/expected <<EOF &&
1462 setup: git_dir: $TRASH_DIRECTORY/11.git
1463 setup: worktree: $TRASH_DIRECTORY/11/wt
1464 setup: cwd: $TRASH_DIRECTORY/11/sub/sub
1465 setup: prefix: (null)
1467 test_repo 11/sub/sub ../../.git ../../wt
1470 test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
1471 cat >11/sub/sub/expected <<EOF &&
1472 setup: git_dir: $TRASH_DIRECTORY/11.git
1473 setup: worktree: $TRASH_DIRECTORY/11/wt
1474 setup: cwd: $TRASH_DIRECTORY/11/sub/sub
1475 setup: prefix: (null)
1477 test_repo 11/sub/sub "$TRASH_DIRECTORY/11/.git" ../../wt
1480 test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
1481 cat >11/sub/sub/expected <<EOF &&
1482 setup: git_dir: $TRASH_DIRECTORY/11.git
1483 setup: worktree: $TRASH_DIRECTORY/11/wt
1484 setup: cwd: $TRASH_DIRECTORY/11/sub/sub
1485 setup: prefix: (null)
1487 test_repo 11/sub/sub "$TRASH_DIRECTORY/11/.git" "$TRASH_DIRECTORY/11/wt"
1490 test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
1491 cat >11/expected <<EOF &&
1492 setup: git_dir: $TRASH_DIRECTORY/11.git
1493 setup: worktree: $TRASH_DIRECTORY
1494 setup: cwd: $TRASH_DIRECTORY
1497 test_repo 11 .git "$TRASH_DIRECTORY"
1500 test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
1501 cat >11/expected <<EOF &&
1502 setup: git_dir: $TRASH_DIRECTORY/11.git
1503 setup: worktree: $TRASH_DIRECTORY
1504 setup: cwd: $TRASH_DIRECTORY
1507 test_repo 11 .git ..
1510 test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
1511 cat >11/expected <<EOF &&
1512 setup: git_dir: $TRASH_DIRECTORY/11.git
1513 setup: worktree: $TRASH_DIRECTORY
1514 setup: cwd: $TRASH_DIRECTORY
1517 test_repo 11 "$TRASH_DIRECTORY/11/.git" ..
1520 test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=.. at root' '
1521 cat >11/expected <<EOF &&
1522 setup: git_dir: $TRASH_DIRECTORY/11.git
1523 setup: worktree: $TRASH_DIRECTORY
1524 setup: cwd: $TRASH_DIRECTORY
1527 test_repo 11 "$TRASH_DIRECTORY/11/.git" "$TRASH_DIRECTORY"
1530 test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
1531 cat >11/sub/sub/expected <<EOF &&
1532 setup: git_dir: $TRASH_DIRECTORY/11.git
1533 setup: worktree: $TRASH_DIRECTORY
1534 setup: cwd: $TRASH_DIRECTORY
1535 setup: prefix: 11/sub/sub/
1537 test_repo 11/sub/sub ../../.git "$TRASH_DIRECTORY"
1540 test_expect_failure '#11: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
1541 cat >11/sub/sub/expected <<EOF &&
1542 setup: git_dir: $TRASH_DIRECTORY/11.git
1543 setup: worktree: $TRASH_DIRECTORY
1544 setup: cwd: $TRASH_DIRECTORY
1545 setup: prefix: 11/sub/sub/
1547 test_repo 11/sub/sub ../../.git ../../..
1550 test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
1551 cat >11/sub/sub/expected <<EOF &&
1552 setup: git_dir: $TRASH_DIRECTORY/11.git
1553 setup: worktree: $TRASH_DIRECTORY
1554 setup: cwd: $TRASH_DIRECTORY
1555 setup: prefix: 11/sub/sub/
1557 test_repo 11/sub/sub "$TRASH_DIRECTORY/11/.git" ../../../
1560 test_expect_failure '#11: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
1561 cat >11/sub/sub/expected <<EOF &&
1562 setup: git_dir: $TRASH_DIRECTORY/11.git
1563 setup: worktree: $TRASH_DIRECTORY
1564 setup: cwd: $TRASH_DIRECTORY
1565 setup: prefix: 11/sub/sub/
1567 test_repo 11/sub/sub "$TRASH_DIRECTORY/11/.git" "$TRASH_DIRECTORY"
1573 ############################################################
1577 # - GIT_WORK_TREE is not set
1578 # - GIT_DIR is not set
1579 # - core.worktree is set
1581 # - core.bare is not set, cwd is outside .git
1585 # #4 except that git_dir is set by .git file
1588 test_expect_success '#12: setup' '
1589 unset GIT_DIR GIT_WORK_TREE &&
1590 mkdir 12 12/sub 12/sub/sub 12.wt 12.wt/sub 12/wt 12/wt/sub &&
1593 git config core.worktree non-existent &&
1594 mv .git ../12.git &&
1595 echo gitdir: ../12.git >.git &&
1599 test_expect_failure '#12: at root' '
1600 cat >12/expected <<EOF &&
1601 setup: git_dir: $TRASH_DIRECTORY/12.git
1602 setup: worktree: $TRASH_DIRECTORY/12
1603 setup: cwd: $TRASH_DIRECTORY/12
1604 setup: prefix: (null)
1609 test_expect_failure '#12: in subdir' '
1610 cat >12/sub/expected <<EOF &&
1611 setup: git_dir: $TRASH_DIRECTORY/12.git
1612 setup: worktree: $TRASH_DIRECTORY/12
1613 setup: cwd: $TRASH_DIRECTORY/12
1622 ############################################################
1626 # - GIT_WORK_TREE is set
1627 # - GIT_DIR is not set
1628 # - core.worktree is set
1630 # - core.bare is not set, cwd is outside .git
1634 # #5 except that git_dir is set by .git file
1636 test_expect_success '#13: setup' '
1637 unset GIT_DIR GIT_WORK_TREE &&
1638 mkdir 13 13/sub 13/sub/sub 13.wt 13.wt/sub 13/wt 13/wt/sub &&
1641 git config core.worktree non-existent &&
1642 GIT_WORK_TREE=non-existent-too &&
1643 export GIT_WORK_TREE &&
1644 mv .git ../13.git &&
1645 echo gitdir: ../13.git >.git &&
1649 test_expect_failure '#13: at root' '
1650 cat >13/expected <<EOF &&
1651 setup: git_dir: $TRASH_DIRECTORY/13.git
1652 setup: worktree: $TRASH_DIRECTORY/13
1653 setup: cwd: $TRASH_DIRECTORY/13
1654 setup: prefix: (null)
1659 test_expect_failure '#13: in subdir' '
1660 cat >13/sub/expected <<EOF &&
1661 setup: git_dir: $TRASH_DIRECTORY/13.git
1662 setup: worktree: $TRASH_DIRECTORY/13
1663 setup: cwd: $TRASH_DIRECTORY/13
1672 ############################################################
1676 # - GIT_WORK_TREE is not set
1678 # - core.worktree is set
1680 # - core.bare is not set, cwd is outside .git
1684 # #6 except that git_dir is set by .git file
1686 test_expect_success '#14: setup' '
1687 unset GIT_DIR GIT_WORK_TREE &&
1688 mkdir 14 14/sub 14/sub/sub 14.wt 14.wt/sub 14/wt 14/wt/sub &&
1691 mv .git ../14.git &&
1692 echo gitdir: ../14.git >.git &&
1696 test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14 at root' '
1697 cat >14/expected <<EOF &&
1698 setup: git_dir: $TRASH_DIRECTORY/14.git
1699 setup: worktree: $TRASH_DIRECTORY/14
1700 setup: cwd: $TRASH_DIRECTORY/14
1701 setup: prefix: (null)
1703 git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14" &&
1707 test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14(rel) at root' '
1708 cat >14/expected <<EOF &&
1709 setup: git_dir: $TRASH_DIRECTORY/14.git
1710 setup: worktree: $TRASH_DIRECTORY/14
1711 setup: cwd: $TRASH_DIRECTORY/14
1712 setup: prefix: (null)
1714 git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14 &&
1718 test_expect_failure '#14: GIT_DIR, core.worktree=../14 at root' '
1719 cat >14/expected <<EOF &&
1720 setup: git_dir: $TRASH_DIRECTORY/14.git
1721 setup: worktree: $TRASH_DIRECTORY/14
1722 setup: cwd: $TRASH_DIRECTORY/14
1723 setup: prefix: (null)
1725 git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14" &&
1726 test_repo 14 "$TRASH_DIRECTORY/14/.git"
1729 test_expect_failure '#14: GIT_DIR, core.worktree=../14(rel) at root' '
1730 cat >14/expected <<EOF &&
1731 setup: git_dir: $TRASH_DIRECTORY/14.git
1732 setup: worktree: $TRASH_DIRECTORY/14
1733 setup: cwd: $TRASH_DIRECTORY/14
1734 setup: prefix: (null)
1736 git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14 &&
1737 test_repo 14 "$TRASH_DIRECTORY/14/.git"
1740 test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14 in subdir' '
1741 cat >14/sub/sub/expected <<EOF &&
1742 setup: git_dir: $TRASH_DIRECTORY/14.git
1743 setup: worktree: $TRASH_DIRECTORY/14
1744 setup: cwd: $TRASH_DIRECTORY/14
1745 setup: prefix: sub/sub/
1747 git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14" &&
1748 test_repo 14/sub/sub ../../.git
1751 test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14(rel) in subdir' '
1752 cat >14/sub/sub/expected <<EOF &&
1753 setup: git_dir: $TRASH_DIRECTORY/14.git
1754 setup: worktree: $TRASH_DIRECTORY/14
1755 setup: cwd: $TRASH_DIRECTORY/14
1756 setup: prefix: sub/sub/
1758 git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14 &&
1759 test_repo 14/sub/sub ../../.git
1762 test_expect_failure '#14: GIT_DIR, core.worktree=../14 in subdir' '
1763 cat >14/sub/expected <<EOF &&
1764 setup: git_dir: $TRASH_DIRECTORY/14.git
1765 setup: worktree: $TRASH_DIRECTORY/14
1766 setup: cwd: $TRASH_DIRECTORY/14
1769 git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14" &&
1770 test_repo 14/sub "$TRASH_DIRECTORY/14/.git"
1773 test_expect_failure '#14: GIT_DIR, core.worktree=../14(rel) in subdir' '
1774 cat >14/sub/sub/expected <<EOF &&
1775 setup: git_dir: $TRASH_DIRECTORY/14.git
1776 setup: worktree: $TRASH_DIRECTORY/14
1777 setup: cwd: $TRASH_DIRECTORY/14
1778 setup: prefix: sub/sub/
1780 git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14 &&
1781 test_repo 14/sub/sub "$TRASH_DIRECTORY/14/.git"
1784 test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14/wt at root' '
1785 cat >14/expected <<EOF &&
1786 setup: git_dir: $TRASH_DIRECTORY/14.git
1787 setup: worktree: $TRASH_DIRECTORY/14/wt
1788 setup: cwd: $TRASH_DIRECTORY/14
1789 setup: prefix: (null)
1791 git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14/wt" &&
1795 test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14/wt(rel) at root' '
1796 cat >14/expected <<EOF &&
1797 setup: git_dir: $TRASH_DIRECTORY/14.git
1798 setup: worktree: $TRASH_DIRECTORY/14/wt
1799 setup: cwd: $TRASH_DIRECTORY/14
1800 setup: prefix: (null)
1802 git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14/wt &&
1806 test_expect_failure '#14: GIT_DIR, core.worktree=../14/wt(rel) at root' '
1807 cat >14/expected <<EOF &&
1808 setup: git_dir: $TRASH_DIRECTORY/14.git
1809 setup: worktree: $TRASH_DIRECTORY/14/wt
1810 setup: cwd: $TRASH_DIRECTORY/14
1811 setup: prefix: (null)
1813 git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14/wt &&
1814 test_repo 14 "$TRASH_DIRECTORY/14/.git"
1817 test_expect_failure '#14: GIT_DIR, core.worktree=../14/wt at root' '
1818 cat >14/expected <<EOF &&
1819 setup: git_dir: $TRASH_DIRECTORY/14.git
1820 setup: worktree: $TRASH_DIRECTORY/14/wt
1821 setup: cwd: $TRASH_DIRECTORY/14
1822 setup: prefix: (null)
1824 git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14/wt" &&
1825 test_repo 14 "$TRASH_DIRECTORY/14/.git"
1828 test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14/wt in subdir' '
1829 cat >14/sub/sub/expected <<EOF &&
1830 setup: git_dir: $TRASH_DIRECTORY/14.git
1831 setup: worktree: $TRASH_DIRECTORY/14/wt
1832 setup: cwd: $TRASH_DIRECTORY/14/sub/sub
1833 setup: prefix: (null)
1835 git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14/wt" &&
1836 test_repo 14/sub/sub ../../.git
1839 test_expect_failure '#14: GIT_DIR(rel), core.worktree=../14/wt(rel) in subdir' '
1840 cat >14/sub/sub/expected <<EOF &&
1841 setup: git_dir: $TRASH_DIRECTORY/14.git
1842 setup: worktree: $TRASH_DIRECTORY/14/wt
1843 setup: cwd: $TRASH_DIRECTORY/14/sub/sub
1844 setup: prefix: (null)
1846 git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14/wt &&
1847 test_repo 14/sub/sub ../../.git
1850 test_expect_failure '#14: GIT_DIR, core.worktree=../14/wt(rel) in subdir' '
1851 cat >14/sub/sub/expected <<EOF &&
1852 setup: git_dir: $TRASH_DIRECTORY/14.git
1853 setup: worktree: $TRASH_DIRECTORY/14/wt
1854 setup: cwd: $TRASH_DIRECTORY/14/sub/sub
1855 setup: prefix: (null)
1857 git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree ../14/wt &&
1858 test_repo 14/sub/sub "$TRASH_DIRECTORY/14/.git"
1861 test_expect_failure '#14: GIT_DIR, core.worktree=../14/wt in subdir' '
1862 cat >14/sub/sub/expected <<EOF &&
1863 setup: git_dir: $TRASH_DIRECTORY/14.git
1864 setup: worktree: $TRASH_DIRECTORY/14/wt
1865 setup: cwd: $TRASH_DIRECTORY/14/sub/sub
1866 setup: prefix: (null)
1868 git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY/14/wt" &&
1869 test_repo 14/sub/sub "$TRASH_DIRECTORY/14/.git"
1872 test_expect_failure '#14: GIT_DIR(rel), core.worktree=.. at root' '
1873 cat >14/expected <<EOF &&
1874 setup: git_dir: $TRASH_DIRECTORY/14.git
1875 setup: worktree: $TRASH_DIRECTORY
1876 setup: cwd: $TRASH_DIRECTORY
1879 git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY" &&
1883 test_expect_failure '#14: GIT_DIR(rel), core.worktree=..(rel) at root' '
1884 cat >14/expected <<EOF &&
1885 setup: git_dir: $TRASH_DIRECTORY/14.git
1886 setup: worktree: $TRASH_DIRECTORY
1887 setup: cwd: $TRASH_DIRECTORY
1890 git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree .. &&
1894 test_expect_failure '#14: GIT_DIR, core.worktree=..(rel) at root' '
1895 cat >14/expected <<EOF &&
1896 setup: git_dir: $TRASH_DIRECTORY/14.git
1897 setup: worktree: $TRASH_DIRECTORY
1898 setup: cwd: $TRASH_DIRECTORY
1901 git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree .. &&
1902 test_repo 14 "$TRASH_DIRECTORY/14/.git"
1905 test_expect_failure '#14: GIT_DIR, core.worktree=.. at root' '
1906 cat >14/expected <<EOF &&
1907 setup: git_dir: $TRASH_DIRECTORY/14.git
1908 setup: worktree: $TRASH_DIRECTORY
1909 setup: cwd: $TRASH_DIRECTORY
1912 git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY" &&
1913 test_repo 14 "$TRASH_DIRECTORY/14/.git"
1916 test_expect_failure '#14: GIT_DIR(rel), core.worktree=.. in subdir' '
1917 cat >14/sub/sub/expected <<EOF &&
1918 setup: git_dir: $TRASH_DIRECTORY/14.git
1919 setup: worktree: $TRASH_DIRECTORY
1920 setup: cwd: $TRASH_DIRECTORY
1921 setup: prefix: 14/sub/sub/
1923 git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY" &&
1924 test_repo 14/sub/sub ../../.git
1927 test_expect_failure '#14: GIT_DIR(rel), core.worktree=..(rel) in subdir' '
1928 cat >14/sub/sub/expected <<EOF &&
1929 setup: git_dir: $TRASH_DIRECTORY/14.git
1930 setup: worktree: $TRASH_DIRECTORY
1931 setup: cwd: $TRASH_DIRECTORY
1932 setup: prefix: 14/sub/sub/
1934 git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree .. &&
1935 test_repo 14/sub/sub ../../.git
1938 test_expect_failure '#14: GIT_DIR, core.worktree=..(rel) in subdir' '
1939 cat >14/sub/sub/expected <<EOF &&
1940 setup: git_dir: $TRASH_DIRECTORY/14.git
1941 setup: worktree: $TRASH_DIRECTORY
1942 setup: cwd: $TRASH_DIRECTORY
1943 setup: prefix: 14/sub/sub/
1945 git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree .. &&
1946 test_repo 14/sub/sub "$TRASH_DIRECTORY/14/.git"
1949 test_expect_failure '#14: GIT_DIR, core.worktree=.. in subdir' '
1950 cat >14/sub/sub/expected <<EOF &&
1951 setup: git_dir: $TRASH_DIRECTORY/14.git
1952 setup: worktree: $TRASH_DIRECTORY
1953 setup: cwd: $TRASH_DIRECTORY
1954 setup: prefix: 14/sub/sub/
1956 git config --file="$TRASH_DIRECTORY/14.git/config" core.worktree "$TRASH_DIRECTORY" &&
1957 test_repo 14/sub/sub "$TRASH_DIRECTORY/14/.git"
1963 ############################################################
1967 # - GIT_WORK_TREE is set
1969 # - core.worktree is set
1971 # - core.bare is not set, cwd is outside .git
1975 # #7 except that git_dir is set by .git file
1977 test_expect_success '#15: setup' '
1978 unset GIT_DIR GIT_WORK_TREE &&
1979 mkdir 15 15/sub 15/sub/sub 15.wt 15.wt/sub 15/wt 15/wt/sub &&
1982 git config core.worktree non-existent &&
1983 mv .git ../15.git &&
1984 echo gitdir: ../15.git >.git &&
1988 test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
1989 cat >15/expected <<EOF &&
1990 setup: git_dir: $TRASH_DIRECTORY/15.git
1991 setup: worktree: $TRASH_DIRECTORY/15
1992 setup: cwd: $TRASH_DIRECTORY/15
1993 setup: prefix: (null)
1995 test_repo 15 .git "$TRASH_DIRECTORY/15"
1998 test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
1999 cat >15/expected <<EOF &&
2000 setup: git_dir: $TRASH_DIRECTORY/15.git
2001 setup: worktree: $TRASH_DIRECTORY/15
2002 setup: cwd: $TRASH_DIRECTORY/15
2003 setup: prefix: (null)
2008 test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=root at root' '
2009 cat >15/expected <<EOF &&
2010 setup: git_dir: $TRASH_DIRECTORY/15.git
2011 setup: worktree: $TRASH_DIRECTORY/15
2012 setup: cwd: $TRASH_DIRECTORY/15
2013 setup: prefix: (null)
2015 test_repo 15 "$TRASH_DIRECTORY/15/.git" "$TRASH_DIRECTORY/15"
2018 test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
2019 cat >15/expected <<EOF &&
2020 setup: git_dir: $TRASH_DIRECTORY/15.git
2021 setup: worktree: $TRASH_DIRECTORY/15
2022 setup: cwd: $TRASH_DIRECTORY/15
2023 setup: prefix: (null)
2025 test_repo 15 "$TRASH_DIRECTORY/15/.git" .
2028 test_expect_failure '#15: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
2029 cat >15/sub/sub/expected <<EOF &&
2030 setup: git_dir: $TRASH_DIRECTORY/15.git
2031 setup: worktree: $TRASH_DIRECTORY/15
2032 setup: cwd: $TRASH_DIRECTORY/15
2033 setup: prefix: sub/sub/
2035 test_repo 15/sub/sub ../../.git "$TRASH_DIRECTORY/15"
2038 test_expect_failure '#15: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
2039 cat >15/sub/sub/expected <<EOF &&
2040 setup: git_dir: $TRASH_DIRECTORY/15.git
2041 setup: worktree: $TRASH_DIRECTORY/15
2042 setup: cwd: $TRASH_DIRECTORY/15
2043 setup: prefix: sub/sub/
2045 test_repo 15/sub/sub ../../.git ../..
2048 test_expect_failure '#15: GIT_DIR, GIT_WORKTREE=root in subdir' '
2049 cat >15/sub/expected <<EOF &&
2050 setup: git_dir: $TRASH_DIRECTORY/15.git
2051 setup: worktree: $TRASH_DIRECTORY/15
2052 setup: cwd: $TRASH_DIRECTORY/15
2055 test_repo 15/sub "$TRASH_DIRECTORY/15/.git" "$TRASH_DIRECTORY/15"
2058 test_expect_failure '#15: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
2059 cat >15/sub/sub/expected <<EOF &&
2060 setup: git_dir: $TRASH_DIRECTORY/15.git
2061 setup: worktree: $TRASH_DIRECTORY/15
2062 setup: cwd: $TRASH_DIRECTORY/15
2063 setup: prefix: sub/sub/
2065 test_repo 15/sub/sub "$TRASH_DIRECTORY/15/.git" ../..
2068 test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
2069 cat >15/expected <<EOF &&
2070 setup: git_dir: $TRASH_DIRECTORY/15.git
2071 setup: worktree: $TRASH_DIRECTORY/15/wt
2072 setup: cwd: $TRASH_DIRECTORY/15
2073 setup: prefix: (null)
2075 test_repo 15 .git "$TRASH_DIRECTORY/15/wt"
2078 test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
2079 cat >15/expected <<EOF &&
2080 setup: git_dir: $TRASH_DIRECTORY/15.git
2081 setup: worktree: $TRASH_DIRECTORY/15/wt
2082 setup: cwd: $TRASH_DIRECTORY/15
2083 setup: prefix: (null)
2085 test_repo 15 .git wt
2088 test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
2089 cat >15/expected <<EOF &&
2090 setup: git_dir: $TRASH_DIRECTORY/15.git
2091 setup: worktree: $TRASH_DIRECTORY/15/wt
2092 setup: cwd: $TRASH_DIRECTORY/15
2093 setup: prefix: (null)
2095 test_repo 15 "$TRASH_DIRECTORY/15/.git" wt
2098 test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=wt at root' '
2099 cat >15/expected <<EOF &&
2100 setup: git_dir: $TRASH_DIRECTORY/15.git
2101 setup: worktree: $TRASH_DIRECTORY/15/wt
2102 setup: cwd: $TRASH_DIRECTORY/15
2103 setup: prefix: (null)
2105 test_repo 15 "$TRASH_DIRECTORY/15/.git" "$TRASH_DIRECTORY/15/wt"
2108 test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
2109 cat >15/sub/sub/expected <<EOF &&
2110 setup: git_dir: $TRASH_DIRECTORY/15.git
2111 setup: worktree: $TRASH_DIRECTORY/15/wt
2112 setup: cwd: $TRASH_DIRECTORY/15/sub/sub
2113 setup: prefix: (null)
2115 test_repo 15/sub/sub ../../.git "$TRASH_DIRECTORY/15/wt"
2118 test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
2119 cat >15/sub/sub/expected <<EOF &&
2120 setup: git_dir: $TRASH_DIRECTORY/15.git
2121 setup: worktree: $TRASH_DIRECTORY/15/wt
2122 setup: cwd: $TRASH_DIRECTORY/15/sub/sub
2123 setup: prefix: (null)
2125 test_repo 15/sub/sub ../../.git ../../wt
2128 test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
2129 cat >15/sub/sub/expected <<EOF &&
2130 setup: git_dir: $TRASH_DIRECTORY/15.git
2131 setup: worktree: $TRASH_DIRECTORY/15/wt
2132 setup: cwd: $TRASH_DIRECTORY/15/sub/sub
2133 setup: prefix: (null)
2135 test_repo 15/sub/sub "$TRASH_DIRECTORY/15/.git" ../../wt
2138 test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
2139 cat >15/sub/sub/expected <<EOF &&
2140 setup: git_dir: $TRASH_DIRECTORY/15.git
2141 setup: worktree: $TRASH_DIRECTORY/15/wt
2142 setup: cwd: $TRASH_DIRECTORY/15/sub/sub
2143 setup: prefix: (null)
2145 test_repo 15/sub/sub "$TRASH_DIRECTORY/15/.git" "$TRASH_DIRECTORY/15/wt"
2148 test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
2149 cat >15/expected <<EOF &&
2150 setup: git_dir: $TRASH_DIRECTORY/15.git
2151 setup: worktree: $TRASH_DIRECTORY
2152 setup: cwd: $TRASH_DIRECTORY
2155 test_repo 15 .git "$TRASH_DIRECTORY"
2158 test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
2159 cat >15/expected <<EOF &&
2160 setup: git_dir: $TRASH_DIRECTORY/15.git
2161 setup: worktree: $TRASH_DIRECTORY
2162 setup: cwd: $TRASH_DIRECTORY
2165 test_repo 15 .git ..
2168 test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
2169 cat >15/expected <<EOF &&
2170 setup: git_dir: $TRASH_DIRECTORY/15.git
2171 setup: worktree: $TRASH_DIRECTORY
2172 setup: cwd: $TRASH_DIRECTORY
2175 test_repo 15 "$TRASH_DIRECTORY/15/.git" ..
2178 test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=.. at root' '
2179 cat >15/expected <<EOF &&
2180 setup: git_dir: $TRASH_DIRECTORY/15.git
2181 setup: worktree: $TRASH_DIRECTORY
2182 setup: cwd: $TRASH_DIRECTORY
2185 test_repo 15 "$TRASH_DIRECTORY/15/.git" "$TRASH_DIRECTORY"
2188 test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
2189 cat >15/sub/sub/expected <<EOF &&
2190 setup: git_dir: $TRASH_DIRECTORY/15.git
2191 setup: worktree: $TRASH_DIRECTORY
2192 setup: cwd: $TRASH_DIRECTORY
2193 setup: prefix: 15/sub/sub/
2195 test_repo 15/sub/sub ../../.git "$TRASH_DIRECTORY"
2198 test_expect_failure '#15: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
2199 cat >15/sub/sub/expected <<EOF &&
2200 setup: git_dir: $TRASH_DIRECTORY/15.git
2201 setup: worktree: $TRASH_DIRECTORY
2202 setup: cwd: $TRASH_DIRECTORY
2203 setup: prefix: 15/sub/sub/
2205 test_repo 15/sub/sub ../../.git ../../..
2208 test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
2209 cat >15/sub/sub/expected <<EOF &&
2210 setup: git_dir: $TRASH_DIRECTORY/15.git
2211 setup: worktree: $TRASH_DIRECTORY
2212 setup: cwd: $TRASH_DIRECTORY
2213 setup: prefix: 15/sub/sub/
2215 test_repo 15/sub/sub "$TRASH_DIRECTORY/15/.git" ../../../
2218 test_expect_failure '#15: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
2219 cat >15/sub/sub/expected <<EOF &&
2220 setup: git_dir: $TRASH_DIRECTORY/15.git
2221 setup: worktree: $TRASH_DIRECTORY
2222 setup: cwd: $TRASH_DIRECTORY
2223 setup: prefix: 15/sub/sub/
2225 test_repo 15/sub/sub "$TRASH_DIRECTORY/15/.git" "$TRASH_DIRECTORY"