]> git.ipfire.org Git - thirdparty/git.git/blame - t/t1510-repo-setup.sh
tests: cosmetic improvements to the repo-setup test
[thirdparty/git.git] / t / t1510-repo-setup.sh
CommitLineData
03a2b6ef
NTND
1#!/bin/sh
2
91c031df 3test_description="Tests of cwd/prefix/worktree/gitdir setup in all cases
03a2b6ef 4
91c031df 5A few rules for repo setup:
03a2b6ef 6
91c031df
JN
71. GIT_DIR is relative to user's cwd. --git-dir is equivalent to
8 GIT_DIR.
9
102. .git file is relative to parent directory. .git file is basically
11 symlink in disguise. The directory where .git file points to will
12 become new git_dir.
13
143. core.worktree is relative to git_dir.
15
164. GIT_WORK_TREE is relative to user's cwd. --work-tree is
17 equivalent to GIT_WORK_TREE.
18
195. GIT_WORK_TREE/core.worktree is only effective if GIT_DIR is set
20 Uneffective worktree settings should be warned.
21
226. Effective GIT_WORK_TREE overrides core.worktree and core.bare
23
247. Effective core.worktree conflicts with core.bare
25
268. If GIT_DIR is set but neither worktree nor bare setting is given,
27 original cwd becomes worktree.
28
299. If .git discovery is done inside a repo, the repo becomes a bare
30 repo. .git discovery is performed if GIT_DIR is not set.
31
3210. If no worktree is available, cwd remains unchanged, prefix is
33 NULL.
34
3511. When user's cwd is outside worktree, cwd remains unchanged,
36 prefix is NULL.
37"
38. ./test-lib.sh
03a2b6ef 39
91c031df 40test_repo () {
03a2b6ef 41 (
91c031df
JN
42 cd "$1" &&
43 if test -n "$2"
44 then
45 GIT_DIR="$2" &&
46 export GIT_DIR
47 fi &&
48 if test -n "$3"
49 then
50 GIT_WORK_TREE="$3" &&
51 export GIT_WORK_TREE
52 fi &&
53 rm -f trace &&
54 GIT_TRACE="$(pwd)/trace" git symbolic-ref HEAD >/dev/null &&
55 grep '^setup: ' trace >result &&
56 test_cmp expected result
03a2b6ef
NTND
57 )
58}
59
60# Bit 0 = GIT_WORK_TREE
61# Bit 1 = GIT_DIR
62# Bit 2 = core.worktree
63# Bit 3 = .git is a file
64# Bit 4 = bare repo
65# Case# = encoding of the above 5 bits
66
fc4045ee
NTND
67#
68# Case #0
69#
70############################################################
71#
72# Input:
73#
74# - GIT_WORK_TREE is not set
75# - GIT_DIR is not set
76# - core.worktree is not set
77# - .git is a directory
78# - core.bare is not set, cwd is outside .git
79#
80# Output:
81#
82# - worktree is .git's parent directory
83# - cwd is at worktree root dir
84# - prefix is calculated
85# - git_dir is set to ".git"
86# - cwd can't be outside worktree
87
88test_expect_success '#0: setup' '
ed40ec55 89 sane_unset GIT_DIR GIT_WORK_TREE &&
fc4045ee 90 mkdir 0 0/sub &&
e6ec2b6a
JS
91 (cd 0 && git init) &&
92 here=$(pwd)
fc4045ee
NTND
93'
94
95test_expect_success '#0: at root' '
96 cat >0/expected <<EOF &&
97setup: git_dir: .git
e6ec2b6a
JS
98setup: worktree: $here/0
99setup: cwd: $here/0
fc4045ee
NTND
100setup: prefix: (null)
101EOF
102 test_repo 0
103'
104
105test_expect_success '#0: in subdir' '
106 cat >0/sub/expected <<EOF &&
107setup: git_dir: .git
e6ec2b6a
JS
108setup: worktree: $here/0
109setup: cwd: $here/0
fc4045ee
NTND
110setup: prefix: sub/
111EOF
112 test_repo 0/sub
113'
114
8fbee484
NTND
115#
116# case #1
117#
118############################################################
119#
120# Input:
121#
122# - GIT_WORK_TREE is set
123# - GIT_DIR is not set
124# - core.worktree is not set
125# - .git is a directory
126# - core.bare is not set, cwd is outside .git
127#
128# Output:
129#
130# GIT_WORK_TREE is ignored -> #0
131
132test_expect_success '#1: setup' '
ed40ec55 133 sane_unset GIT_DIR GIT_WORK_TREE &&
8fbee484
NTND
134 mkdir 1 1/sub 1.wt 1.wt/sub 1/wt 1/wt/sub &&
135 cd 1 &&
136 git init &&
137 GIT_WORK_TREE=non-existent &&
138 export GIT_WORK_TREE &&
139 cd ..
140'
141
e6aea2db 142test_expect_success '#1: at root' '
8fbee484
NTND
143 cat >1/expected <<EOF &&
144setup: git_dir: .git
e6ec2b6a
JS
145setup: worktree: $here/1
146setup: cwd: $here/1
8fbee484
NTND
147setup: prefix: (null)
148EOF
149 test_repo 1
150'
151
e6aea2db 152test_expect_success '#1: in subdir' '
8fbee484
NTND
153 cat >1/sub/expected <<EOF &&
154setup: git_dir: .git
e6ec2b6a
JS
155setup: worktree: $here/1
156setup: cwd: $here/1
8fbee484
NTND
157setup: prefix: sub/
158EOF
159 test_repo 1/sub
160'
161
71946602
NTND
162#
163# case #2
164#
165############################################################
166#
167# Input:
168#
169# - GIT_WORK_TREE is not set
170# - GIT_DIR is set
171# - core.worktree is not set
172# - .git is a directory
173# - core.bare is not set, cwd is outside .git
174#
175# Output:
176#
177# - worktree is at original cwd
178# - cwd is unchanged
179# - prefix is NULL
180# - git_dir is set to $GIT_DIR
181# - cwd can't be outside worktree
182
183test_expect_success '#2: setup' '
ed40ec55 184 sane_unset GIT_DIR GIT_WORK_TREE &&
71946602
NTND
185 mkdir 2 2/sub &&
186 cd 2 && git init && cd ..
187'
188
189test_expect_success '#2: at root' '
190 cat >2/expected <<EOF &&
e6ec2b6a
JS
191setup: git_dir: $here/2/.git
192setup: worktree: $here/2
193setup: cwd: $here/2
71946602
NTND
194setup: prefix: (null)
195EOF
e6ec2b6a 196 test_repo 2 "$here/2/.git"
71946602
NTND
197'
198
199test_expect_success '#2: in subdir' '
200 cat >2/sub/expected <<EOF &&
e6ec2b6a
JS
201setup: git_dir: $here/2/.git
202setup: worktree: $here/2/sub
203setup: cwd: $here/2/sub
71946602
NTND
204setup: prefix: (null)
205EOF
e6ec2b6a 206 test_repo 2/sub "$here/2/.git"
71946602
NTND
207'
208
209test_expect_success '#2: relative GIT_DIR at root' '
210 cat >2/expected <<EOF &&
211setup: git_dir: .git
e6ec2b6a
JS
212setup: worktree: $here/2
213setup: cwd: $here/2
71946602
NTND
214setup: prefix: (null)
215EOF
216 test_repo 2 .git
217'
218
219test_expect_success '#2: relative GIT_DIR in subdir' '
220 cat >2/sub/expected <<EOF &&
221setup: git_dir: ../.git
e6ec2b6a
JS
222setup: worktree: $here/2/sub
223setup: cwd: $here/2/sub
71946602
NTND
224setup: prefix: (null)
225EOF
226 test_repo 2/sub ../.git
227'
228
8718ed61
NTND
229#
230# case #3
231#
232############################################################
233#
234# Input:
235#
236# - GIT_WORK_TREE is set
237# - GIT_DIR is set
238# - core.worktree is not set
239# - .git is a directory
240# - core.bare is not set, cwd is outside .git
241#
242# Output:
243#
244# - worktree is set to $GIT_WORK_TREE
245# - cwd is at worktree root
246# - prefix is calculated
247# - git_dir is set to $GIT_DIR
248# - cwd can be outside worktree
249
250test_expect_success '#3: setup' '
ed40ec55 251 sane_unset GIT_DIR GIT_WORK_TREE &&
8718ed61
NTND
252 mkdir 3 3/sub 3/sub/sub 3.wt 3.wt/sub 3/wt 3/wt/sub &&
253 cd 3 && git init && cd ..
254'
255
256test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
257 cat >3/expected <<EOF &&
258setup: git_dir: .git
e6ec2b6a
JS
259setup: worktree: $here/3
260setup: cwd: $here/3
8718ed61
NTND
261setup: prefix: (null)
262EOF
e6ec2b6a 263 test_repo 3 .git "$here/3"
8718ed61
NTND
264'
265
266test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
267 cat >3/expected <<EOF &&
268setup: git_dir: .git
e6ec2b6a
JS
269setup: worktree: $here/3
270setup: cwd: $here/3
8718ed61
NTND
271setup: prefix: (null)
272EOF
273 test_repo 3 .git .
274'
275
276test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=root at root' '
277 cat >3/expected <<EOF &&
e6ec2b6a
JS
278setup: git_dir: $here/3/.git
279setup: worktree: $here/3
280setup: cwd: $here/3
8718ed61
NTND
281setup: prefix: (null)
282EOF
e6ec2b6a 283 test_repo 3 "$here/3/.git" "$here/3"
8718ed61
NTND
284'
285
286test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
287 cat >3/expected <<EOF &&
e6ec2b6a
JS
288setup: git_dir: $here/3/.git
289setup: worktree: $here/3
290setup: cwd: $here/3
8718ed61
NTND
291setup: prefix: (null)
292EOF
e6ec2b6a 293 test_repo 3 "$here/3/.git" .
8718ed61
NTND
294'
295
296test_expect_success '#3: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
297 cat >3/sub/sub/expected <<EOF &&
e6ec2b6a
JS
298setup: git_dir: $here/3/.git
299setup: worktree: $here/3
300setup: cwd: $here/3
8718ed61
NTND
301setup: prefix: sub/sub/
302EOF
e6ec2b6a 303 test_repo 3/sub/sub ../../.git "$here/3"
8718ed61
NTND
304'
305
306test_expect_success '#3: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
307 cat >3/sub/sub/expected <<EOF &&
e6ec2b6a
JS
308setup: git_dir: $here/3/.git
309setup: worktree: $here/3
310setup: cwd: $here/3
8718ed61
NTND
311setup: prefix: sub/sub/
312EOF
313 test_repo 3/sub/sub ../../.git ../..
314'
315
316test_expect_success '#3: GIT_DIR, GIT_WORKTREE=root in subdir' '
317 cat >3/sub/expected <<EOF &&
e6ec2b6a
JS
318setup: git_dir: $here/3/.git
319setup: worktree: $here/3
320setup: cwd: $here/3
8718ed61
NTND
321setup: prefix: sub/
322EOF
e6ec2b6a 323 test_repo 3/sub "$here/3/.git" "$here/3"
8718ed61
NTND
324'
325
326test_expect_success '#3: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
327 cat >3/sub/sub/expected <<EOF &&
e6ec2b6a
JS
328setup: git_dir: $here/3/.git
329setup: worktree: $here/3
330setup: cwd: $here/3
8718ed61
NTND
331setup: prefix: sub/sub/
332EOF
e6ec2b6a 333 test_repo 3/sub/sub "$here/3/.git" ../..
8718ed61
NTND
334'
335
336test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
337 cat >3/expected <<EOF &&
338setup: git_dir: .git
e6ec2b6a
JS
339setup: worktree: $here/3/wt
340setup: cwd: $here/3
8718ed61
NTND
341setup: prefix: (null)
342EOF
e6ec2b6a 343 test_repo 3 .git "$here/3/wt"
8718ed61
NTND
344'
345
346test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
347 cat >3/expected <<EOF &&
348setup: git_dir: .git
e6ec2b6a
JS
349setup: worktree: $here/3/wt
350setup: cwd: $here/3
8718ed61
NTND
351setup: prefix: (null)
352EOF
353 test_repo 3 .git wt
354'
355
356test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
357 cat >3/expected <<EOF &&
e6ec2b6a
JS
358setup: git_dir: $here/3/.git
359setup: worktree: $here/3/wt
360setup: cwd: $here/3
8718ed61
NTND
361setup: prefix: (null)
362EOF
e6ec2b6a 363 test_repo 3 "$here/3/.git" wt
8718ed61
NTND
364'
365
366test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=wt at root' '
367 cat >3/expected <<EOF &&
e6ec2b6a
JS
368setup: git_dir: $here/3/.git
369setup: worktree: $here/3/wt
370setup: cwd: $here/3
8718ed61
NTND
371setup: prefix: (null)
372EOF
e6ec2b6a 373 test_repo 3 "$here/3/.git" "$here/3/wt"
8718ed61
NTND
374'
375
376test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
377 cat >3/sub/sub/expected <<EOF &&
378setup: git_dir: ../../.git
e6ec2b6a
JS
379setup: worktree: $here/3/wt
380setup: cwd: $here/3/sub/sub
8718ed61
NTND
381setup: prefix: (null)
382EOF
e6ec2b6a 383 test_repo 3/sub/sub ../../.git "$here/3/wt"
8718ed61
NTND
384'
385
386test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
387 cat >3/sub/sub/expected <<EOF &&
388setup: git_dir: ../../.git
e6ec2b6a
JS
389setup: worktree: $here/3/wt
390setup: cwd: $here/3/sub/sub
8718ed61
NTND
391setup: prefix: (null)
392EOF
393 test_repo 3/sub/sub ../../.git ../../wt
394'
395
396test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
397 cat >3/sub/sub/expected <<EOF &&
e6ec2b6a
JS
398setup: git_dir: $here/3/.git
399setup: worktree: $here/3/wt
400setup: cwd: $here/3/sub/sub
8718ed61
NTND
401setup: prefix: (null)
402EOF
e6ec2b6a 403 test_repo 3/sub/sub "$here/3/.git" ../../wt
8718ed61
NTND
404'
405
406test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
407 cat >3/sub/sub/expected <<EOF &&
e6ec2b6a
JS
408setup: git_dir: $here/3/.git
409setup: worktree: $here/3/wt
410setup: cwd: $here/3/sub/sub
8718ed61
NTND
411setup: prefix: (null)
412EOF
e6ec2b6a 413 test_repo 3/sub/sub "$here/3/.git" "$here/3/wt"
8718ed61
NTND
414'
415
416test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
417 cat >3/expected <<EOF &&
e6ec2b6a
JS
418setup: git_dir: $here/3/.git
419setup: worktree: $here
420setup: cwd: $here
8718ed61
NTND
421setup: prefix: 3/
422EOF
e6ec2b6a 423 test_repo 3 .git "$here"
8718ed61
NTND
424'
425
426test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
427 cat >3/expected <<EOF &&
e6ec2b6a
JS
428setup: git_dir: $here/3/.git
429setup: worktree: $here
430setup: cwd: $here
8718ed61
NTND
431setup: prefix: 3/
432EOF
433 test_repo 3 .git ..
434'
435
436test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
437 cat >3/expected <<EOF &&
e6ec2b6a
JS
438setup: git_dir: $here/3/.git
439setup: worktree: $here
440setup: cwd: $here
8718ed61
NTND
441setup: prefix: 3/
442EOF
e6ec2b6a 443 test_repo 3 "$here/3/.git" ..
8718ed61
NTND
444'
445
446test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=.. at root' '
447 cat >3/expected <<EOF &&
e6ec2b6a
JS
448setup: git_dir: $here/3/.git
449setup: worktree: $here
450setup: cwd: $here
8718ed61
NTND
451setup: prefix: 3/
452EOF
e6ec2b6a 453 test_repo 3 "$here/3/.git" "$here"
8718ed61
NTND
454'
455
456test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
457 cat >3/sub/sub/expected <<EOF &&
e6ec2b6a
JS
458setup: git_dir: $here/3/.git
459setup: worktree: $here
460setup: cwd: $here
8718ed61
NTND
461setup: prefix: 3/sub/sub/
462EOF
e6ec2b6a 463 test_repo 3/sub/sub ../../.git "$here"
8718ed61
NTND
464'
465
466test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
467 cat >3/sub/sub/expected <<EOF &&
e6ec2b6a
JS
468setup: git_dir: $here/3/.git
469setup: worktree: $here
470setup: cwd: $here
8718ed61
NTND
471setup: prefix: 3/sub/sub/
472EOF
473 test_repo 3/sub/sub ../../.git ../../..
474'
475
476test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
477 cat >3/sub/sub/expected <<EOF &&
e6ec2b6a
JS
478setup: git_dir: $here/3/.git
479setup: worktree: $here
480setup: cwd: $here
8718ed61
NTND
481setup: prefix: 3/sub/sub/
482EOF
e6ec2b6a 483 test_repo 3/sub/sub "$here/3/.git" ../../../
8718ed61
NTND
484'
485
486test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
487 cat >3/sub/sub/expected <<EOF &&
e6ec2b6a
JS
488setup: git_dir: $here/3/.git
489setup: worktree: $here
490setup: cwd: $here
8718ed61
NTND
491setup: prefix: 3/sub/sub/
492EOF
e6ec2b6a 493 test_repo 3/sub/sub "$here/3/.git" "$here"
8718ed61
NTND
494'
495
351fa1dc
NTND
496#
497# case #4
498#
499############################################################
500#
501# Input:
502#
503# - GIT_WORK_TREE is not set
504# - GIT_DIR is not set
505# - core.worktree is set
506# - .git is a directory
507# - core.bare is not set, cwd is outside .git
508#
509# Output:
510#
511# core.worktree is ignored -> #0
512
513test_expect_success '#4: setup' '
ed40ec55 514 sane_unset GIT_DIR GIT_WORK_TREE &&
351fa1dc
NTND
515 mkdir 4 4/sub &&
516 cd 4 &&
517 git init &&
518 git config core.worktree non-existent &&
519 cd ..
520'
521
e6aea2db 522test_expect_success '#4: at root' '
351fa1dc
NTND
523 cat >4/expected <<EOF &&
524setup: git_dir: .git
e6ec2b6a
JS
525setup: worktree: $here/4
526setup: cwd: $here/4
351fa1dc
NTND
527setup: prefix: (null)
528EOF
529 test_repo 4
530'
531
e6aea2db 532test_expect_success '#4: in subdir' '
351fa1dc
NTND
533 cat >4/sub/expected <<EOF &&
534setup: git_dir: .git
e6ec2b6a
JS
535setup: worktree: $here/4
536setup: cwd: $here/4
351fa1dc
NTND
537setup: prefix: sub/
538EOF
539 test_repo 4/sub
540'
541
3f388c17
NTND
542#
543# case #5
544#
545############################################################
546#
547# Input:
548#
549# - GIT_WORK_TREE is set
550# - GIT_DIR is not set
551# - core.worktree is set
552# - .git is a directory
553# - core.bare is not set, cwd is outside .git
554#
555# Output:
556#
557# GIT_WORK_TREE/core.worktree are ignored -> #0
558
559test_expect_success '#5: setup' '
ed40ec55 560 sane_unset GIT_DIR GIT_WORK_TREE &&
3f388c17
NTND
561 mkdir 5 5/sub &&
562 cd 5 &&
563 git init &&
564 git config core.worktree non-existent &&
565 GIT_WORK_TREE=non-existent-too &&
566 export GIT_WORK_TREE &&
567 cd ..
568'
569
e6aea2db 570test_expect_success '#5: at root' '
3f388c17
NTND
571 cat >5/expected <<EOF &&
572setup: git_dir: .git
e6ec2b6a
JS
573setup: worktree: $here/5
574setup: cwd: $here/5
3f388c17
NTND
575setup: prefix: (null)
576EOF
577 test_repo 5
578'
579
e6aea2db 580test_expect_success '#5: in subdir' '
3f388c17
NTND
581 cat >5/sub/expected <<EOF &&
582setup: git_dir: .git
e6ec2b6a
JS
583setup: worktree: $here/5
584setup: cwd: $here/5
3f388c17
NTND
585setup: prefix: sub/
586EOF
587 test_repo 5/sub
588'
589
555b96ab
NTND
590#
591# case #6
592#
593############################################################
594#
595# Input:
596#
597# - GIT_WORK_TREE is not set
598# - GIT_DIR is set
599# - core.worktree is set
600# - .git is a directory
601# - core.bare is not set, cwd is outside .git
602#
603# Output:
604#
605# - worktree is at core.worktree
606# - cwd is at worktree root
607# - prefix is calculated
608# - git_dir is at $GIT_DIR
609# - cwd can be outside worktree
610
611test_expect_success '#6: setup' '
ed40ec55 612 sane_unset GIT_DIR GIT_WORK_TREE &&
555b96ab
NTND
613 mkdir 6 6/sub 6/sub/sub 6.wt 6.wt/sub 6/wt 6/wt/sub &&
614 cd 6 && git init && cd ..
615'
616
617test_expect_success '#6: GIT_DIR(rel), core.worktree=.. at root' '
618 cat >6/expected <<EOF &&
619setup: git_dir: .git
e6ec2b6a
JS
620setup: worktree: $here/6
621setup: cwd: $here/6
555b96ab
NTND
622setup: prefix: (null)
623EOF
e6ec2b6a 624 git config --file="$here/6/.git/config" core.worktree "$here/6" &&
555b96ab
NTND
625 test_repo 6 .git
626'
627
628test_expect_success '#6: GIT_DIR(rel), core.worktree=..(rel) at root' '
629 cat >6/expected <<EOF &&
630setup: git_dir: .git
e6ec2b6a
JS
631setup: worktree: $here/6
632setup: cwd: $here/6
555b96ab
NTND
633setup: prefix: (null)
634EOF
e6ec2b6a 635 git config --file="$here/6/.git/config" core.worktree .. &&
555b96ab
NTND
636 test_repo 6 .git
637'
638
639test_expect_success '#6: GIT_DIR, core.worktree=.. at root' '
640 cat >6/expected <<EOF &&
e6ec2b6a
JS
641setup: git_dir: $here/6/.git
642setup: worktree: $here/6
643setup: cwd: $here/6
555b96ab
NTND
644setup: prefix: (null)
645EOF
e6ec2b6a
JS
646 git config --file="$here/6/.git/config" core.worktree "$here/6" &&
647 test_repo 6 "$here/6/.git"
555b96ab
NTND
648'
649
650test_expect_success '#6: GIT_DIR, core.worktree=..(rel) at root' '
651 cat >6/expected <<EOF &&
e6ec2b6a
JS
652setup: git_dir: $here/6/.git
653setup: worktree: $here/6
654setup: cwd: $here/6
555b96ab
NTND
655setup: prefix: (null)
656EOF
e6ec2b6a
JS
657 git config --file="$here/6/.git/config" core.worktree .. &&
658 test_repo 6 "$here/6/.git"
555b96ab
NTND
659'
660
b3f66fd3 661test_expect_success '#6: GIT_DIR(rel), core.worktree=.. in subdir' '
555b96ab 662 cat >6/sub/sub/expected <<EOF &&
e6ec2b6a
JS
663setup: git_dir: $here/6/.git
664setup: worktree: $here/6
665setup: cwd: $here/6
555b96ab
NTND
666setup: prefix: sub/sub/
667EOF
e6ec2b6a 668 git config --file="$here/6/.git/config" core.worktree "$here/6" &&
555b96ab
NTND
669 test_repo 6/sub/sub ../../.git
670'
671
b3f66fd3 672test_expect_success '#6: GIT_DIR(rel), core.worktree=..(rel) in subdir' '
555b96ab 673 cat >6/sub/sub/expected <<EOF &&
e6ec2b6a
JS
674setup: git_dir: $here/6/.git
675setup: worktree: $here/6
676setup: cwd: $here/6
555b96ab
NTND
677setup: prefix: sub/sub/
678EOF
e6ec2b6a 679 git config --file="$here/6/.git/config" core.worktree .. &&
555b96ab
NTND
680 test_repo 6/sub/sub ../../.git
681'
682
683test_expect_success '#6: GIT_DIR, core.worktree=.. in subdir' '
684 cat >6/sub/expected <<EOF &&
e6ec2b6a
JS
685setup: git_dir: $here/6/.git
686setup: worktree: $here/6
687setup: cwd: $here/6
555b96ab
NTND
688setup: prefix: sub/
689EOF
e6ec2b6a
JS
690 git config --file="$here/6/.git/config" core.worktree "$here/6" &&
691 test_repo 6/sub "$here/6/.git"
555b96ab
NTND
692'
693
694test_expect_success '#6: GIT_DIR, core.worktree=..(rel) in subdir' '
695 cat >6/sub/sub/expected <<EOF &&
e6ec2b6a
JS
696setup: git_dir: $here/6/.git
697setup: worktree: $here/6
698setup: cwd: $here/6
555b96ab
NTND
699setup: prefix: sub/sub/
700EOF
e6ec2b6a
JS
701 git config --file="$here/6/.git/config" core.worktree .. &&
702 test_repo 6/sub/sub "$here/6/.git"
555b96ab
NTND
703'
704
705test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt at root' '
706 cat >6/expected <<EOF &&
707setup: git_dir: .git
e6ec2b6a
JS
708setup: worktree: $here/6/wt
709setup: cwd: $here/6
555b96ab
NTND
710setup: prefix: (null)
711EOF
e6ec2b6a 712 git config --file="$here/6/.git/config" core.worktree "$here/6/wt" &&
555b96ab
NTND
713 test_repo 6 .git
714'
715
716test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt(rel) at root' '
717 cat >6/expected <<EOF &&
718setup: git_dir: .git
e6ec2b6a
JS
719setup: worktree: $here/6/wt
720setup: cwd: $here/6
555b96ab
NTND
721setup: prefix: (null)
722EOF
e6ec2b6a 723 git config --file="$here/6/.git/config" core.worktree ../wt &&
555b96ab
NTND
724 test_repo 6 .git
725'
726
727test_expect_success '#6: GIT_DIR, core.worktree=../wt(rel) at root' '
728 cat >6/expected <<EOF &&
e6ec2b6a
JS
729setup: git_dir: $here/6/.git
730setup: worktree: $here/6/wt
731setup: cwd: $here/6
555b96ab
NTND
732setup: prefix: (null)
733EOF
e6ec2b6a
JS
734 git config --file="$here/6/.git/config" core.worktree ../wt &&
735 test_repo 6 "$here/6/.git"
555b96ab
NTND
736'
737
738test_expect_success '#6: GIT_DIR, core.worktree=../wt at root' '
739 cat >6/expected <<EOF &&
e6ec2b6a
JS
740setup: git_dir: $here/6/.git
741setup: worktree: $here/6/wt
742setup: cwd: $here/6
555b96ab
NTND
743setup: prefix: (null)
744EOF
e6ec2b6a
JS
745 git config --file="$here/6/.git/config" core.worktree "$here/6/wt" &&
746 test_repo 6 "$here/6/.git"
555b96ab
NTND
747'
748
749test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt in subdir' '
750 cat >6/sub/sub/expected <<EOF &&
751setup: git_dir: ../../.git
e6ec2b6a
JS
752setup: worktree: $here/6/wt
753setup: cwd: $here/6/sub/sub
555b96ab
NTND
754setup: prefix: (null)
755EOF
e6ec2b6a 756 git config --file="$here/6/.git/config" core.worktree "$here/6/wt" &&
555b96ab
NTND
757 test_repo 6/sub/sub ../../.git
758'
759
760test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt(rel) in subdir' '
761 cat >6/sub/sub/expected <<EOF &&
762setup: git_dir: ../../.git
e6ec2b6a
JS
763setup: worktree: $here/6/wt
764setup: cwd: $here/6/sub/sub
555b96ab
NTND
765setup: prefix: (null)
766EOF
e6ec2b6a 767 git config --file="$here/6/.git/config" core.worktree ../wt &&
555b96ab
NTND
768 test_repo 6/sub/sub ../../.git
769'
770
771test_expect_success '#6: GIT_DIR, core.worktree=../wt(rel) in subdir' '
772 cat >6/sub/sub/expected <<EOF &&
e6ec2b6a
JS
773setup: git_dir: $here/6/.git
774setup: worktree: $here/6/wt
775setup: cwd: $here/6/sub/sub
555b96ab
NTND
776setup: prefix: (null)
777EOF
e6ec2b6a
JS
778 git config --file="$here/6/.git/config" core.worktree ../wt &&
779 test_repo 6/sub/sub "$here/6/.git"
555b96ab
NTND
780'
781
782test_expect_success '#6: GIT_DIR, core.worktree=../wt in subdir' '
783 cat >6/sub/sub/expected <<EOF &&
e6ec2b6a
JS
784setup: git_dir: $here/6/.git
785setup: worktree: $here/6/wt
786setup: cwd: $here/6/sub/sub
555b96ab
NTND
787setup: prefix: (null)
788EOF
e6ec2b6a
JS
789 git config --file="$here/6/.git/config" core.worktree "$here/6/wt" &&
790 test_repo 6/sub/sub "$here/6/.git"
555b96ab
NTND
791'
792
b3f66fd3 793test_expect_success '#6: GIT_DIR(rel), core.worktree=../.. at root' '
555b96ab 794 cat >6/expected <<EOF &&
e6ec2b6a
JS
795setup: git_dir: $here/6/.git
796setup: worktree: $here
797setup: cwd: $here
555b96ab
NTND
798setup: prefix: 6/
799EOF
e6ec2b6a 800 git config --file="$here/6/.git/config" core.worktree "$here" &&
555b96ab
NTND
801 test_repo 6 .git
802'
803
b3f66fd3 804test_expect_success '#6: GIT_DIR(rel), core.worktree=../..(rel) at root' '
555b96ab 805 cat >6/expected <<EOF &&
e6ec2b6a
JS
806setup: git_dir: $here/6/.git
807setup: worktree: $here
808setup: cwd: $here
555b96ab
NTND
809setup: prefix: 6/
810EOF
e6ec2b6a 811 git config --file="$here/6/.git/config" core.worktree ../../ &&
555b96ab
NTND
812 test_repo 6 .git
813'
814
815test_expect_success '#6: GIT_DIR, core.worktree=../..(rel) at root' '
816 cat >6/expected <<EOF &&
e6ec2b6a
JS
817setup: git_dir: $here/6/.git
818setup: worktree: $here
819setup: cwd: $here
555b96ab
NTND
820setup: prefix: 6/
821EOF
e6ec2b6a
JS
822 git config --file="$here/6/.git/config" core.worktree ../../ &&
823 test_repo 6 "$here/6/.git"
555b96ab
NTND
824'
825
826test_expect_success '#6: GIT_DIR, core.worktree=../.. at root' '
827 cat >6/expected <<EOF &&
e6ec2b6a
JS
828setup: git_dir: $here/6/.git
829setup: worktree: $here
830setup: cwd: $here
555b96ab
NTND
831setup: prefix: 6/
832EOF
e6ec2b6a
JS
833 git config --file="$here/6/.git/config" core.worktree "$here" &&
834 test_repo 6 "$here/6/.git"
555b96ab
NTND
835'
836
b3f66fd3 837test_expect_success '#6: GIT_DIR(rel), core.worktree=../.. in subdir' '
555b96ab 838 cat >6/sub/sub/expected <<EOF &&
e6ec2b6a
JS
839setup: git_dir: $here/6/.git
840setup: worktree: $here
841setup: cwd: $here
555b96ab
NTND
842setup: prefix: 6/sub/sub/
843EOF
e6ec2b6a 844 git config --file="$here/6/.git/config" core.worktree "$here" &&
555b96ab
NTND
845 test_repo 6/sub/sub ../../.git
846'
847
b3f66fd3 848test_expect_success '#6: GIT_DIR(rel), core.worktree=../..(rel) in subdir' '
555b96ab 849 cat >6/sub/sub/expected <<EOF &&
e6ec2b6a
JS
850setup: git_dir: $here/6/.git
851setup: worktree: $here
852setup: cwd: $here
555b96ab
NTND
853setup: prefix: 6/sub/sub/
854EOF
e6ec2b6a 855 git config --file="$here/6/.git/config" core.worktree ../.. &&
555b96ab
NTND
856 test_repo 6/sub/sub ../../.git
857'
858
859test_expect_success '#6: GIT_DIR, core.worktree=../..(rel) in subdir' '
860 cat >6/sub/sub/expected <<EOF &&
e6ec2b6a
JS
861setup: git_dir: $here/6/.git
862setup: worktree: $here
863setup: cwd: $here
555b96ab
NTND
864setup: prefix: 6/sub/sub/
865EOF
e6ec2b6a
JS
866 git config --file="$here/6/.git/config" core.worktree ../.. &&
867 test_repo 6/sub/sub "$here/6/.git"
555b96ab
NTND
868'
869
870test_expect_success '#6: GIT_DIR, core.worktree=../.. in subdir' '
871 cat >6/sub/sub/expected <<EOF &&
e6ec2b6a
JS
872setup: git_dir: $here/6/.git
873setup: worktree: $here
874setup: cwd: $here
555b96ab
NTND
875setup: prefix: 6/sub/sub/
876EOF
e6ec2b6a
JS
877 git config --file="$here/6/.git/config" core.worktree "$here" &&
878 test_repo 6/sub/sub "$here/6/.git"
555b96ab
NTND
879'
880
561a7e66
NTND
881#
882# case #7
883#
884############################################################
885#
886# Input:
887#
888# - GIT_WORK_TREE is set
889# - GIT_DIR is set
890# - core.worktree is set
891# - .git is a directory
892# - core.bare is not set, cwd is outside .git
893#
894# Output:
895#
896# core.worktree is overridden by GIT_WORK_TREE -> #3
897
898test_expect_success '#7: setup' '
ed40ec55 899 sane_unset GIT_DIR GIT_WORK_TREE &&
561a7e66
NTND
900 mkdir 7 7/sub 7/sub/sub 7.wt 7.wt/sub 7/wt 7/wt/sub &&
901 cd 7 &&
902 git init &&
903 git config core.worktree non-existent &&
904 cd ..
905'
906
907test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
908 cat >7/expected <<EOF &&
909setup: git_dir: .git
e6ec2b6a
JS
910setup: worktree: $here/7
911setup: cwd: $here/7
561a7e66
NTND
912setup: prefix: (null)
913EOF
e6ec2b6a 914 test_repo 7 .git "$here/7"
561a7e66
NTND
915'
916
917test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
918 cat >7/expected <<EOF &&
919setup: git_dir: .git
e6ec2b6a
JS
920setup: worktree: $here/7
921setup: cwd: $here/7
561a7e66
NTND
922setup: prefix: (null)
923EOF
924 test_repo 7 .git .
925'
926
927test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=root at root' '
928 cat >7/expected <<EOF &&
e6ec2b6a
JS
929setup: git_dir: $here/7/.git
930setup: worktree: $here/7
931setup: cwd: $here/7
561a7e66
NTND
932setup: prefix: (null)
933EOF
e6ec2b6a 934 test_repo 7 "$here/7/.git" "$here/7"
561a7e66
NTND
935'
936
937test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
938 cat >7/expected <<EOF &&
e6ec2b6a
JS
939setup: git_dir: $here/7/.git
940setup: worktree: $here/7
941setup: cwd: $here/7
561a7e66
NTND
942setup: prefix: (null)
943EOF
e6ec2b6a 944 test_repo 7 "$here/7/.git" .
561a7e66
NTND
945'
946
947test_expect_success '#7: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
948 cat >7/sub/sub/expected <<EOF &&
e6ec2b6a
JS
949setup: git_dir: $here/7/.git
950setup: worktree: $here/7
951setup: cwd: $here/7
561a7e66
NTND
952setup: prefix: sub/sub/
953EOF
e6ec2b6a 954 test_repo 7/sub/sub ../../.git "$here/7"
561a7e66
NTND
955'
956
957test_expect_success '#7: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
958 cat >7/sub/sub/expected <<EOF &&
e6ec2b6a
JS
959setup: git_dir: $here/7/.git
960setup: worktree: $here/7
961setup: cwd: $here/7
561a7e66
NTND
962setup: prefix: sub/sub/
963EOF
964 test_repo 7/sub/sub ../../.git ../..
965'
966
967test_expect_success '#7: GIT_DIR, GIT_WORKTREE=root in subdir' '
968 cat >7/sub/expected <<EOF &&
e6ec2b6a
JS
969setup: git_dir: $here/7/.git
970setup: worktree: $here/7
971setup: cwd: $here/7
561a7e66
NTND
972setup: prefix: sub/
973EOF
e6ec2b6a 974 test_repo 7/sub "$here/7/.git" "$here/7"
561a7e66
NTND
975'
976
977test_expect_success '#7: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
978 cat >7/sub/sub/expected <<EOF &&
e6ec2b6a
JS
979setup: git_dir: $here/7/.git
980setup: worktree: $here/7
981setup: cwd: $here/7
561a7e66
NTND
982setup: prefix: sub/sub/
983EOF
e6ec2b6a 984 test_repo 7/sub/sub "$here/7/.git" ../..
561a7e66
NTND
985'
986
987test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
988 cat >7/expected <<EOF &&
989setup: git_dir: .git
e6ec2b6a
JS
990setup: worktree: $here/7/wt
991setup: cwd: $here/7
561a7e66
NTND
992setup: prefix: (null)
993EOF
e6ec2b6a 994 test_repo 7 .git "$here/7/wt"
561a7e66
NTND
995'
996
997test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
998 cat >7/expected <<EOF &&
999setup: git_dir: .git
e6ec2b6a
JS
1000setup: worktree: $here/7/wt
1001setup: cwd: $here/7
561a7e66
NTND
1002setup: prefix: (null)
1003EOF
1004 test_repo 7 .git wt
1005'
1006
1007test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
1008 cat >7/expected <<EOF &&
e6ec2b6a
JS
1009setup: git_dir: $here/7/.git
1010setup: worktree: $here/7/wt
1011setup: cwd: $here/7
561a7e66
NTND
1012setup: prefix: (null)
1013EOF
e6ec2b6a 1014 test_repo 7 "$here/7/.git" wt
561a7e66
NTND
1015'
1016
1017test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=wt at root' '
1018 cat >7/expected <<EOF &&
e6ec2b6a
JS
1019setup: git_dir: $here/7/.git
1020setup: worktree: $here/7/wt
1021setup: cwd: $here/7
561a7e66
NTND
1022setup: prefix: (null)
1023EOF
e6ec2b6a 1024 test_repo 7 "$here/7/.git" "$here/7/wt"
561a7e66
NTND
1025'
1026
1027test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
1028 cat >7/sub/sub/expected <<EOF &&
1029setup: git_dir: ../../.git
e6ec2b6a
JS
1030setup: worktree: $here/7/wt
1031setup: cwd: $here/7/sub/sub
561a7e66
NTND
1032setup: prefix: (null)
1033EOF
e6ec2b6a 1034 test_repo 7/sub/sub ../../.git "$here/7/wt"
561a7e66
NTND
1035'
1036
1037test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
1038 cat >7/sub/sub/expected <<EOF &&
1039setup: git_dir: ../../.git
e6ec2b6a
JS
1040setup: worktree: $here/7/wt
1041setup: cwd: $here/7/sub/sub
561a7e66
NTND
1042setup: prefix: (null)
1043EOF
1044 test_repo 7/sub/sub ../../.git ../../wt
1045'
1046
1047test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
1048 cat >7/sub/sub/expected <<EOF &&
e6ec2b6a
JS
1049setup: git_dir: $here/7/.git
1050setup: worktree: $here/7/wt
1051setup: cwd: $here/7/sub/sub
561a7e66
NTND
1052setup: prefix: (null)
1053EOF
e6ec2b6a 1054 test_repo 7/sub/sub "$here/7/.git" ../../wt
561a7e66
NTND
1055'
1056
1057test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
1058 cat >7/sub/sub/expected <<EOF &&
e6ec2b6a
JS
1059setup: git_dir: $here/7/.git
1060setup: worktree: $here/7/wt
1061setup: cwd: $here/7/sub/sub
561a7e66
NTND
1062setup: prefix: (null)
1063EOF
e6ec2b6a 1064 test_repo 7/sub/sub "$here/7/.git" "$here/7/wt"
561a7e66
NTND
1065'
1066
1067test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
1068 cat >7/expected <<EOF &&
e6ec2b6a
JS
1069setup: git_dir: $here/7/.git
1070setup: worktree: $here
1071setup: cwd: $here
561a7e66
NTND
1072setup: prefix: 7/
1073EOF
e6ec2b6a 1074 test_repo 7 .git "$here"
561a7e66
NTND
1075'
1076
1077test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
1078 cat >7/expected <<EOF &&
e6ec2b6a
JS
1079setup: git_dir: $here/7/.git
1080setup: worktree: $here
1081setup: cwd: $here
561a7e66
NTND
1082setup: prefix: 7/
1083EOF
1084 test_repo 7 .git ..
1085'
1086
1087test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
1088 cat >7/expected <<EOF &&
e6ec2b6a
JS
1089setup: git_dir: $here/7/.git
1090setup: worktree: $here
1091setup: cwd: $here
561a7e66
NTND
1092setup: prefix: 7/
1093EOF
e6ec2b6a 1094 test_repo 7 "$here/7/.git" ..
561a7e66
NTND
1095'
1096
1097test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=.. at root' '
1098 cat >7/expected <<EOF &&
e6ec2b6a
JS
1099setup: git_dir: $here/7/.git
1100setup: worktree: $here
1101setup: cwd: $here
561a7e66
NTND
1102setup: prefix: 7/
1103EOF
e6ec2b6a 1104 test_repo 7 "$here/7/.git" "$here"
561a7e66
NTND
1105'
1106
1107test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
1108 cat >7/sub/sub/expected <<EOF &&
e6ec2b6a
JS
1109setup: git_dir: $here/7/.git
1110setup: worktree: $here
1111setup: cwd: $here
561a7e66
NTND
1112setup: prefix: 7/sub/sub/
1113EOF
e6ec2b6a 1114 test_repo 7/sub/sub ../../.git "$here"
561a7e66
NTND
1115'
1116
1117test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
1118 cat >7/sub/sub/expected <<EOF &&
e6ec2b6a
JS
1119setup: git_dir: $here/7/.git
1120setup: worktree: $here
1121setup: cwd: $here
561a7e66
NTND
1122setup: prefix: 7/sub/sub/
1123EOF
1124 test_repo 7/sub/sub ../../.git ../../..
1125'
1126
1127test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
1128 cat >7/sub/sub/expected <<EOF &&
e6ec2b6a
JS
1129setup: git_dir: $here/7/.git
1130setup: worktree: $here
1131setup: cwd: $here
561a7e66
NTND
1132setup: prefix: 7/sub/sub/
1133EOF
e6ec2b6a 1134 test_repo 7/sub/sub "$here/7/.git" ../../../
561a7e66
NTND
1135'
1136
1137test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
1138 cat >7/sub/sub/expected <<EOF &&
e6ec2b6a
JS
1139setup: git_dir: $here/7/.git
1140setup: worktree: $here
1141setup: cwd: $here
561a7e66
NTND
1142setup: prefix: 7/sub/sub/
1143EOF
e6ec2b6a 1144 test_repo 7/sub/sub "$here/7/.git" "$here"
561a7e66
NTND
1145'
1146
9a5976cd
NTND
1147#
1148# case #8
1149#
1150############################################################
1151#
1152# Input:
1153#
1154# - GIT_WORK_TREE is not set
1155# - GIT_DIR is not set
1156# - core.worktree is not set
1157# - .git is a file
1158# - core.bare is not set, cwd is outside .git
1159#
1160# Output:
1161#
1162# #0 except that git_dir is set by .git file
1163
1164test_expect_success '#8: setup' '
ed40ec55 1165 sane_unset GIT_DIR GIT_WORK_TREE &&
9a5976cd
NTND
1166 mkdir 8 8/sub &&
1167 cd 8 &&
1168 git init &&
1169 mv .git ../8.git &&
1170 echo gitdir: ../8.git >.git &&
1171 cd ..
1172'
1173
1174test_expect_success '#8: at root' '
1175 cat >8/expected <<EOF &&
e6ec2b6a
JS
1176setup: git_dir: $here/8.git
1177setup: worktree: $here/8
1178setup: cwd: $here/8
9a5976cd
NTND
1179setup: prefix: (null)
1180EOF
1181 test_repo 8
1182'
1183
1184test_expect_success '#8: in subdir' '
1185 cat >8/sub/expected <<EOF &&
e6ec2b6a
JS
1186setup: git_dir: $here/8.git
1187setup: worktree: $here/8
1188setup: cwd: $here/8
9a5976cd
NTND
1189setup: prefix: sub/
1190EOF
1191 test_repo 8/sub
1192'
1193
bc25c103
NTND
1194#
1195# case #9
1196#
1197############################################################
1198#
1199# Input:
1200#
1201# - GIT_WORK_TREE is set
1202# - GIT_DIR is not set
1203# - core.worktree is not set
1204# - .git is a file
1205# - core.bare is not set, cwd is outside .git
1206#
1207# Output:
1208#
1209# #1 except that git_dir is set by .git file
1210
1211test_expect_success '#9: setup' '
ed40ec55 1212 sane_unset GIT_DIR GIT_WORK_TREE &&
bc25c103
NTND
1213 mkdir 9 9/sub 9.wt 9.wt/sub 9/wt 9/wt/sub &&
1214 cd 9 &&
1215 git init &&
1216 mv .git ../9.git &&
1217 echo gitdir: ../9.git >.git &&
1218 GIT_WORK_TREE=non-existent &&
1219 export GIT_WORK_TREE &&
1220 cd ..
1221'
1222
e6aea2db 1223test_expect_success '#9: at root' '
bc25c103 1224 cat >9/expected <<EOF &&
e6ec2b6a
JS
1225setup: git_dir: $here/9.git
1226setup: worktree: $here/9
1227setup: cwd: $here/9
bc25c103
NTND
1228setup: prefix: (null)
1229EOF
1230 test_repo 9
1231'
1232
e6aea2db 1233test_expect_success '#9: in subdir' '
bc25c103 1234 cat >9/sub/expected <<EOF &&
e6ec2b6a
JS
1235setup: git_dir: $here/9.git
1236setup: worktree: $here/9
1237setup: cwd: $here/9
bc25c103
NTND
1238setup: prefix: sub/
1239EOF
1240 test_repo 9/sub
1241'
1242
773ec931
NTND
1243#
1244# case #10
1245#
1246############################################################
1247#
1248# Input:
1249#
1250# - GIT_WORK_TREE is not set
1251# - GIT_DIR is set
1252# - core.worktree is not set
1253# - .git is a file
1254# - core.bare is not set, cwd is outside .git
1255#
1256# Output:
1257#
1258# #2 except that git_dir is set by .git file
1259
1260test_expect_success '#10: setup' '
ed40ec55 1261 sane_unset GIT_DIR GIT_WORK_TREE &&
773ec931
NTND
1262 mkdir 10 10/sub &&
1263 cd 10 &&
1264 git init &&
1265 mv .git ../10.git &&
1266 echo gitdir: ../10.git >.git &&
1267 cd ..
1268'
1269
b3f66fd3 1270test_expect_success '#10: at root' '
773ec931 1271 cat >10/expected <<EOF &&
e6ec2b6a
JS
1272setup: git_dir: $here/10.git
1273setup: worktree: $here/10
1274setup: cwd: $here/10
773ec931
NTND
1275setup: prefix: (null)
1276EOF
e6ec2b6a 1277 test_repo 10 "$here/10/.git"
773ec931
NTND
1278'
1279
b3f66fd3 1280test_expect_success '#10: in subdir' '
773ec931 1281 cat >10/sub/expected <<EOF &&
e6ec2b6a
JS
1282setup: git_dir: $here/10.git
1283setup: worktree: $here/10/sub
1284setup: cwd: $here/10/sub
773ec931
NTND
1285setup: prefix: (null)
1286EOF
e6ec2b6a 1287 test_repo 10/sub "$here/10/.git"
773ec931
NTND
1288'
1289
b3f66fd3 1290test_expect_success '#10: relative GIT_DIR at root' '
773ec931 1291 cat >10/expected <<EOF &&
e6ec2b6a
JS
1292setup: git_dir: $here/10.git
1293setup: worktree: $here/10
1294setup: cwd: $here/10
773ec931
NTND
1295setup: prefix: (null)
1296EOF
1297 test_repo 10 .git
1298'
1299
b3f66fd3 1300test_expect_success '#10: relative GIT_DIR in subdir' '
773ec931 1301 cat >10/sub/expected <<EOF &&
e6ec2b6a
JS
1302setup: git_dir: $here/10.git
1303setup: worktree: $here/10/sub
1304setup: cwd: $here/10/sub
773ec931
NTND
1305setup: prefix: (null)
1306EOF
1307 test_repo 10/sub ../.git
1308'
1309
3c3b0a00
NTND
1310#
1311# case #11
1312#
1313############################################################
1314#
1315# Input:
1316#
1317# - GIT_WORK_TREE is set
1318# - GIT_DIR is set
1319# - core.worktree is not set
1320# - .git is a file
1321# - core.bare is not set, cwd is outside .git
1322#
1323# Output:
1324#
1325# #3 except that git_dir is set by .git file
1326
1327test_expect_success '#11: setup' '
ed40ec55 1328 sane_unset GIT_DIR GIT_WORK_TREE &&
3c3b0a00
NTND
1329 mkdir 11 11/sub 11/sub/sub 11.wt 11.wt/sub 11/wt 11/wt/sub &&
1330 cd 11 &&
1331 git init &&
1332 mv .git ../11.git &&
1333 echo gitdir: ../11.git >.git &&
1334 cd ..
1335'
1336
b3f66fd3 1337test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
3c3b0a00 1338 cat >11/expected <<EOF &&
e6ec2b6a
JS
1339setup: git_dir: $here/11.git
1340setup: worktree: $here/11
1341setup: cwd: $here/11
3c3b0a00
NTND
1342setup: prefix: (null)
1343EOF
e6ec2b6a 1344 test_repo 11 .git "$here/11"
3c3b0a00
NTND
1345'
1346
b3f66fd3 1347test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
3c3b0a00 1348 cat >11/expected <<EOF &&
e6ec2b6a
JS
1349setup: git_dir: $here/11.git
1350setup: worktree: $here/11
1351setup: cwd: $here/11
3c3b0a00
NTND
1352setup: prefix: (null)
1353EOF
1354 test_repo 11 .git .
1355'
1356
b3f66fd3 1357test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=root at root' '
3c3b0a00 1358 cat >11/expected <<EOF &&
e6ec2b6a
JS
1359setup: git_dir: $here/11.git
1360setup: worktree: $here/11
1361setup: cwd: $here/11
3c3b0a00
NTND
1362setup: prefix: (null)
1363EOF
e6ec2b6a 1364 test_repo 11 "$here/11/.git" "$here/11"
3c3b0a00
NTND
1365'
1366
b3f66fd3 1367test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
3c3b0a00 1368 cat >11/expected <<EOF &&
e6ec2b6a
JS
1369setup: git_dir: $here/11.git
1370setup: worktree: $here/11
1371setup: cwd: $here/11
3c3b0a00
NTND
1372setup: prefix: (null)
1373EOF
e6ec2b6a 1374 test_repo 11 "$here/11/.git" .
3c3b0a00
NTND
1375'
1376
b3f66fd3 1377test_expect_success '#11: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
3c3b0a00 1378 cat >11/sub/sub/expected <<EOF &&
e6ec2b6a
JS
1379setup: git_dir: $here/11.git
1380setup: worktree: $here/11
1381setup: cwd: $here/11
3c3b0a00
NTND
1382setup: prefix: sub/sub/
1383EOF
e6ec2b6a 1384 test_repo 11/sub/sub ../../.git "$here/11"
3c3b0a00
NTND
1385'
1386
b3f66fd3 1387test_expect_success '#11: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
3c3b0a00 1388 cat >11/sub/sub/expected <<EOF &&
e6ec2b6a
JS
1389setup: git_dir: $here/11.git
1390setup: worktree: $here/11
1391setup: cwd: $here/11
3c3b0a00
NTND
1392setup: prefix: sub/sub/
1393EOF
1394 test_repo 11/sub/sub ../../.git ../..
1395'
1396
b3f66fd3 1397test_expect_success '#11: GIT_DIR, GIT_WORKTREE=root in subdir' '
3c3b0a00 1398 cat >11/sub/expected <<EOF &&
e6ec2b6a
JS
1399setup: git_dir: $here/11.git
1400setup: worktree: $here/11
1401setup: cwd: $here/11
3c3b0a00
NTND
1402setup: prefix: sub/
1403EOF
e6ec2b6a 1404 test_repo 11/sub "$here/11/.git" "$here/11"
3c3b0a00
NTND
1405'
1406
b3f66fd3 1407test_expect_success '#11: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
3c3b0a00 1408 cat >11/sub/sub/expected <<EOF &&
e6ec2b6a
JS
1409setup: git_dir: $here/11.git
1410setup: worktree: $here/11
1411setup: cwd: $here/11
3c3b0a00
NTND
1412setup: prefix: sub/sub/
1413EOF
e6ec2b6a 1414 test_repo 11/sub/sub "$here/11/.git" ../..
3c3b0a00
NTND
1415'
1416
b3f66fd3 1417test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
3c3b0a00 1418 cat >11/expected <<EOF &&
e6ec2b6a
JS
1419setup: git_dir: $here/11.git
1420setup: worktree: $here/11/wt
1421setup: cwd: $here/11
3c3b0a00
NTND
1422setup: prefix: (null)
1423EOF
e6ec2b6a 1424 test_repo 11 .git "$here/11/wt"
3c3b0a00
NTND
1425'
1426
b3f66fd3 1427test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
3c3b0a00 1428 cat >11/expected <<EOF &&
e6ec2b6a
JS
1429setup: git_dir: $here/11.git
1430setup: worktree: $here/11/wt
1431setup: cwd: $here/11
3c3b0a00
NTND
1432setup: prefix: (null)
1433EOF
1434 test_repo 11 .git wt
1435'
1436
b3f66fd3 1437test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
3c3b0a00 1438 cat >11/expected <<EOF &&
e6ec2b6a
JS
1439setup: git_dir: $here/11.git
1440setup: worktree: $here/11/wt
1441setup: cwd: $here/11
3c3b0a00
NTND
1442setup: prefix: (null)
1443EOF
e6ec2b6a 1444 test_repo 11 "$here/11/.git" wt
3c3b0a00
NTND
1445'
1446
b3f66fd3 1447test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=wt at root' '
3c3b0a00 1448 cat >11/expected <<EOF &&
e6ec2b6a
JS
1449setup: git_dir: $here/11.git
1450setup: worktree: $here/11/wt
1451setup: cwd: $here/11
3c3b0a00
NTND
1452setup: prefix: (null)
1453EOF
e6ec2b6a 1454 test_repo 11 "$here/11/.git" "$here/11/wt"
3c3b0a00
NTND
1455'
1456
b3f66fd3 1457test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
3c3b0a00 1458 cat >11/sub/sub/expected <<EOF &&
e6ec2b6a
JS
1459setup: git_dir: $here/11.git
1460setup: worktree: $here/11/wt
1461setup: cwd: $here/11/sub/sub
3c3b0a00
NTND
1462setup: prefix: (null)
1463EOF
e6ec2b6a 1464 test_repo 11/sub/sub ../../.git "$here/11/wt"
3c3b0a00
NTND
1465'
1466
b3f66fd3 1467test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
3c3b0a00 1468 cat >11/sub/sub/expected <<EOF &&
e6ec2b6a
JS
1469setup: git_dir: $here/11.git
1470setup: worktree: $here/11/wt
1471setup: cwd: $here/11/sub/sub
3c3b0a00
NTND
1472setup: prefix: (null)
1473EOF
1474 test_repo 11/sub/sub ../../.git ../../wt
1475'
1476
b3f66fd3 1477test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
3c3b0a00 1478 cat >11/sub/sub/expected <<EOF &&
e6ec2b6a
JS
1479setup: git_dir: $here/11.git
1480setup: worktree: $here/11/wt
1481setup: cwd: $here/11/sub/sub
3c3b0a00
NTND
1482setup: prefix: (null)
1483EOF
e6ec2b6a 1484 test_repo 11/sub/sub "$here/11/.git" ../../wt
3c3b0a00
NTND
1485'
1486
b3f66fd3 1487test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
3c3b0a00 1488 cat >11/sub/sub/expected <<EOF &&
e6ec2b6a
JS
1489setup: git_dir: $here/11.git
1490setup: worktree: $here/11/wt
1491setup: cwd: $here/11/sub/sub
3c3b0a00
NTND
1492setup: prefix: (null)
1493EOF
e6ec2b6a 1494 test_repo 11/sub/sub "$here/11/.git" "$here/11/wt"
3c3b0a00
NTND
1495'
1496
b3f66fd3 1497test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
3c3b0a00 1498 cat >11/expected <<EOF &&
e6ec2b6a
JS
1499setup: git_dir: $here/11.git
1500setup: worktree: $here
1501setup: cwd: $here
3c3b0a00
NTND
1502setup: prefix: 11/
1503EOF
e6ec2b6a 1504 test_repo 11 .git "$here"
3c3b0a00
NTND
1505'
1506
b3f66fd3 1507test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
3c3b0a00 1508 cat >11/expected <<EOF &&
e6ec2b6a
JS
1509setup: git_dir: $here/11.git
1510setup: worktree: $here
1511setup: cwd: $here
3c3b0a00
NTND
1512setup: prefix: 11/
1513EOF
1514 test_repo 11 .git ..
1515'
1516
b3f66fd3 1517test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
3c3b0a00 1518 cat >11/expected <<EOF &&
e6ec2b6a
JS
1519setup: git_dir: $here/11.git
1520setup: worktree: $here
1521setup: cwd: $here
3c3b0a00
NTND
1522setup: prefix: 11/
1523EOF
e6ec2b6a 1524 test_repo 11 "$here/11/.git" ..
3c3b0a00
NTND
1525'
1526
b3f66fd3 1527test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=.. at root' '
3c3b0a00 1528 cat >11/expected <<EOF &&
e6ec2b6a
JS
1529setup: git_dir: $here/11.git
1530setup: worktree: $here
1531setup: cwd: $here
3c3b0a00
NTND
1532setup: prefix: 11/
1533EOF
e6ec2b6a 1534 test_repo 11 "$here/11/.git" "$here"
3c3b0a00
NTND
1535'
1536
b3f66fd3 1537test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
3c3b0a00 1538 cat >11/sub/sub/expected <<EOF &&
e6ec2b6a
JS
1539setup: git_dir: $here/11.git
1540setup: worktree: $here
1541setup: cwd: $here
3c3b0a00
NTND
1542setup: prefix: 11/sub/sub/
1543EOF
e6ec2b6a 1544 test_repo 11/sub/sub ../../.git "$here"
3c3b0a00
NTND
1545'
1546
b3f66fd3 1547test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
3c3b0a00 1548 cat >11/sub/sub/expected <<EOF &&
e6ec2b6a
JS
1549setup: git_dir: $here/11.git
1550setup: worktree: $here
1551setup: cwd: $here
3c3b0a00
NTND
1552setup: prefix: 11/sub/sub/
1553EOF
1554 test_repo 11/sub/sub ../../.git ../../..
1555'
1556
b3f66fd3 1557test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
3c3b0a00 1558 cat >11/sub/sub/expected <<EOF &&
e6ec2b6a
JS
1559setup: git_dir: $here/11.git
1560setup: worktree: $here
1561setup: cwd: $here
3c3b0a00
NTND
1562setup: prefix: 11/sub/sub/
1563EOF
e6ec2b6a 1564 test_repo 11/sub/sub "$here/11/.git" ../../../
3c3b0a00
NTND
1565'
1566
b3f66fd3 1567test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
3c3b0a00 1568 cat >11/sub/sub/expected <<EOF &&
e6ec2b6a
JS
1569setup: git_dir: $here/11.git
1570setup: worktree: $here
1571setup: cwd: $here
3c3b0a00
NTND
1572setup: prefix: 11/sub/sub/
1573EOF
e6ec2b6a 1574 test_repo 11/sub/sub "$here/11/.git" "$here"
3c3b0a00
NTND
1575'
1576
713b3721
NTND
1577#
1578# case #12
1579#
1580############################################################
1581#
1582# Input:
1583#
1584# - GIT_WORK_TREE is not set
1585# - GIT_DIR is not set
1586# - core.worktree is set
1587# - .git is a file
1588# - core.bare is not set, cwd is outside .git
1589#
1590# Output:
1591#
1592# #4 except that git_dir is set by .git file
1593
1594
1595test_expect_success '#12: setup' '
ed40ec55 1596 sane_unset GIT_DIR GIT_WORK_TREE &&
713b3721
NTND
1597 mkdir 12 12/sub 12/sub/sub 12.wt 12.wt/sub 12/wt 12/wt/sub &&
1598 cd 12 &&
1599 git init &&
1600 git config core.worktree non-existent &&
1601 mv .git ../12.git &&
1602 echo gitdir: ../12.git >.git &&
1603 cd ..
1604'
1605
e6aea2db 1606test_expect_success '#12: at root' '
713b3721 1607 cat >12/expected <<EOF &&
e6ec2b6a
JS
1608setup: git_dir: $here/12.git
1609setup: worktree: $here/12
1610setup: cwd: $here/12
713b3721
NTND
1611setup: prefix: (null)
1612EOF
1613 test_repo 12
1614'
1615
e6aea2db 1616test_expect_success '#12: in subdir' '
713b3721 1617 cat >12/sub/expected <<EOF &&
e6ec2b6a
JS
1618setup: git_dir: $here/12.git
1619setup: worktree: $here/12
1620setup: cwd: $here/12
713b3721
NTND
1621setup: prefix: sub/
1622EOF
1623 test_repo 12/sub
1624'
1625
dc1c7834
NTND
1626#
1627# case #13
1628#
1629############################################################
1630#
1631# Input:
1632#
1633# - GIT_WORK_TREE is set
1634# - GIT_DIR is not set
1635# - core.worktree is set
1636# - .git is a file
1637# - core.bare is not set, cwd is outside .git
1638#
1639# Output:
1640#
1641# #5 except that git_dir is set by .git file
1642
1643test_expect_success '#13: setup' '
ed40ec55 1644 sane_unset GIT_DIR GIT_WORK_TREE &&
dc1c7834
NTND
1645 mkdir 13 13/sub 13/sub/sub 13.wt 13.wt/sub 13/wt 13/wt/sub &&
1646 cd 13 &&
1647 git init &&
1648 git config core.worktree non-existent &&
1649 GIT_WORK_TREE=non-existent-too &&
1650 export GIT_WORK_TREE &&
1651 mv .git ../13.git &&
1652 echo gitdir: ../13.git >.git &&
1653 cd ..
1654'
1655
e6aea2db 1656test_expect_success '#13: at root' '
dc1c7834 1657 cat >13/expected <<EOF &&
e6ec2b6a
JS
1658setup: git_dir: $here/13.git
1659setup: worktree: $here/13
1660setup: cwd: $here/13
dc1c7834
NTND
1661setup: prefix: (null)
1662EOF
1663 test_repo 13
1664'
1665
e6aea2db 1666test_expect_success '#13: in subdir' '
dc1c7834 1667 cat >13/sub/expected <<EOF &&
e6ec2b6a
JS
1668setup: git_dir: $here/13.git
1669setup: worktree: $here/13
1670setup: cwd: $here/13
dc1c7834
NTND
1671setup: prefix: sub/
1672EOF
1673 test_repo 13/sub
1674'
1675
69bf2b16
NTND
1676#
1677# case #14
1678#
1679############################################################
1680#
1681# Input:
1682#
1683# - GIT_WORK_TREE is not set
1684# - GIT_DIR is set
1685# - core.worktree is set
1686# - .git is a file
1687# - core.bare is not set, cwd is outside .git
1688#
1689# Output:
1690#
1691# #6 except that git_dir is set by .git file
1692
1693test_expect_success '#14: setup' '
ed40ec55 1694 sane_unset GIT_DIR GIT_WORK_TREE &&
69bf2b16
NTND
1695 mkdir 14 14/sub 14/sub/sub 14.wt 14.wt/sub 14/wt 14/wt/sub &&
1696 cd 14 &&
1697 git init &&
1698 mv .git ../14.git &&
1699 echo gitdir: ../14.git >.git &&
1700 cd ..
1701'
1702
b3f66fd3 1703test_expect_success '#14: GIT_DIR(rel), core.worktree=../14 at root' '
69bf2b16 1704 cat >14/expected <<EOF &&
e6ec2b6a
JS
1705setup: git_dir: $here/14.git
1706setup: worktree: $here/14
1707setup: cwd: $here/14
69bf2b16
NTND
1708setup: prefix: (null)
1709EOF
e6ec2b6a 1710 git config --file="$here/14.git/config" core.worktree "$here/14" &&
69bf2b16
NTND
1711 test_repo 14 .git
1712'
1713
b3f66fd3 1714test_expect_success '#14: GIT_DIR(rel), core.worktree=../14(rel) at root' '
69bf2b16 1715 cat >14/expected <<EOF &&
e6ec2b6a
JS
1716setup: git_dir: $here/14.git
1717setup: worktree: $here/14
1718setup: cwd: $here/14
69bf2b16
NTND
1719setup: prefix: (null)
1720EOF
e6ec2b6a 1721 git config --file="$here/14.git/config" core.worktree ../14 &&
69bf2b16
NTND
1722 test_repo 14 .git
1723'
1724
b3f66fd3 1725test_expect_success '#14: GIT_DIR, core.worktree=../14 at root' '
69bf2b16 1726 cat >14/expected <<EOF &&
e6ec2b6a
JS
1727setup: git_dir: $here/14.git
1728setup: worktree: $here/14
1729setup: cwd: $here/14
69bf2b16
NTND
1730setup: prefix: (null)
1731EOF
e6ec2b6a
JS
1732 git config --file="$here/14.git/config" core.worktree "$here/14" &&
1733 test_repo 14 "$here/14/.git"
69bf2b16
NTND
1734'
1735
b3f66fd3 1736test_expect_success '#14: GIT_DIR, core.worktree=../14(rel) at root' '
69bf2b16 1737 cat >14/expected <<EOF &&
e6ec2b6a
JS
1738setup: git_dir: $here/14.git
1739setup: worktree: $here/14
1740setup: cwd: $here/14
69bf2b16
NTND
1741setup: prefix: (null)
1742EOF
e6ec2b6a
JS
1743 git config --file="$here/14.git/config" core.worktree ../14 &&
1744 test_repo 14 "$here/14/.git"
69bf2b16
NTND
1745'
1746
b3f66fd3 1747test_expect_success '#14: GIT_DIR(rel), core.worktree=../14 in subdir' '
69bf2b16 1748 cat >14/sub/sub/expected <<EOF &&
e6ec2b6a
JS
1749setup: git_dir: $here/14.git
1750setup: worktree: $here/14
1751setup: cwd: $here/14
69bf2b16
NTND
1752setup: prefix: sub/sub/
1753EOF
e6ec2b6a 1754 git config --file="$here/14.git/config" core.worktree "$here/14" &&
69bf2b16
NTND
1755 test_repo 14/sub/sub ../../.git
1756'
1757
b3f66fd3 1758test_expect_success '#14: GIT_DIR(rel), core.worktree=../14(rel) in subdir' '
69bf2b16 1759 cat >14/sub/sub/expected <<EOF &&
e6ec2b6a
JS
1760setup: git_dir: $here/14.git
1761setup: worktree: $here/14
1762setup: cwd: $here/14
69bf2b16
NTND
1763setup: prefix: sub/sub/
1764EOF
e6ec2b6a 1765 git config --file="$here/14.git/config" core.worktree ../14 &&
69bf2b16
NTND
1766 test_repo 14/sub/sub ../../.git
1767'
1768
b3f66fd3 1769test_expect_success '#14: GIT_DIR, core.worktree=../14 in subdir' '
69bf2b16 1770 cat >14/sub/expected <<EOF &&
e6ec2b6a
JS
1771setup: git_dir: $here/14.git
1772setup: worktree: $here/14
1773setup: cwd: $here/14
69bf2b16
NTND
1774setup: prefix: sub/
1775EOF
e6ec2b6a
JS
1776 git config --file="$here/14.git/config" core.worktree "$here/14" &&
1777 test_repo 14/sub "$here/14/.git"
69bf2b16
NTND
1778'
1779
b3f66fd3 1780test_expect_success '#14: GIT_DIR, core.worktree=../14(rel) in subdir' '
69bf2b16 1781 cat >14/sub/sub/expected <<EOF &&
e6ec2b6a
JS
1782setup: git_dir: $here/14.git
1783setup: worktree: $here/14
1784setup: cwd: $here/14
69bf2b16
NTND
1785setup: prefix: sub/sub/
1786EOF
e6ec2b6a
JS
1787 git config --file="$here/14.git/config" core.worktree ../14 &&
1788 test_repo 14/sub/sub "$here/14/.git"
69bf2b16
NTND
1789'
1790
b3f66fd3 1791test_expect_success '#14: GIT_DIR(rel), core.worktree=../14/wt at root' '
69bf2b16 1792 cat >14/expected <<EOF &&
e6ec2b6a
JS
1793setup: git_dir: $here/14.git
1794setup: worktree: $here/14/wt
1795setup: cwd: $here/14
69bf2b16
NTND
1796setup: prefix: (null)
1797EOF
e6ec2b6a 1798 git config --file="$here/14.git/config" core.worktree "$here/14/wt" &&
69bf2b16
NTND
1799 test_repo 14 .git
1800'
1801
b3f66fd3 1802test_expect_success '#14: GIT_DIR(rel), core.worktree=../14/wt(rel) at root' '
69bf2b16 1803 cat >14/expected <<EOF &&
e6ec2b6a
JS
1804setup: git_dir: $here/14.git
1805setup: worktree: $here/14/wt
1806setup: cwd: $here/14
69bf2b16
NTND
1807setup: prefix: (null)
1808EOF
e6ec2b6a 1809 git config --file="$here/14.git/config" core.worktree ../14/wt &&
69bf2b16
NTND
1810 test_repo 14 .git
1811'
1812
b3f66fd3 1813test_expect_success '#14: GIT_DIR, core.worktree=../14/wt(rel) at root' '
69bf2b16 1814 cat >14/expected <<EOF &&
e6ec2b6a
JS
1815setup: git_dir: $here/14.git
1816setup: worktree: $here/14/wt
1817setup: cwd: $here/14
69bf2b16
NTND
1818setup: prefix: (null)
1819EOF
e6ec2b6a
JS
1820 git config --file="$here/14.git/config" core.worktree ../14/wt &&
1821 test_repo 14 "$here/14/.git"
69bf2b16
NTND
1822'
1823
b3f66fd3 1824test_expect_success '#14: GIT_DIR, core.worktree=../14/wt at root' '
69bf2b16 1825 cat >14/expected <<EOF &&
e6ec2b6a
JS
1826setup: git_dir: $here/14.git
1827setup: worktree: $here/14/wt
1828setup: cwd: $here/14
69bf2b16
NTND
1829setup: prefix: (null)
1830EOF
e6ec2b6a
JS
1831 git config --file="$here/14.git/config" core.worktree "$here/14/wt" &&
1832 test_repo 14 "$here/14/.git"
69bf2b16
NTND
1833'
1834
b3f66fd3 1835test_expect_success '#14: GIT_DIR(rel), core.worktree=../14/wt in subdir' '
69bf2b16 1836 cat >14/sub/sub/expected <<EOF &&
e6ec2b6a
JS
1837setup: git_dir: $here/14.git
1838setup: worktree: $here/14/wt
1839setup: cwd: $here/14/sub/sub
69bf2b16
NTND
1840setup: prefix: (null)
1841EOF
e6ec2b6a 1842 git config --file="$here/14.git/config" core.worktree "$here/14/wt" &&
69bf2b16
NTND
1843 test_repo 14/sub/sub ../../.git
1844'
1845
b3f66fd3 1846test_expect_success '#14: GIT_DIR(rel), core.worktree=../14/wt(rel) in subdir' '
69bf2b16 1847 cat >14/sub/sub/expected <<EOF &&
e6ec2b6a
JS
1848setup: git_dir: $here/14.git
1849setup: worktree: $here/14/wt
1850setup: cwd: $here/14/sub/sub
69bf2b16
NTND
1851setup: prefix: (null)
1852EOF
e6ec2b6a 1853 git config --file="$here/14.git/config" core.worktree ../14/wt &&
69bf2b16
NTND
1854 test_repo 14/sub/sub ../../.git
1855'
1856
b3f66fd3 1857test_expect_success '#14: GIT_DIR, core.worktree=../14/wt(rel) in subdir' '
69bf2b16 1858 cat >14/sub/sub/expected <<EOF &&
e6ec2b6a
JS
1859setup: git_dir: $here/14.git
1860setup: worktree: $here/14/wt
1861setup: cwd: $here/14/sub/sub
69bf2b16
NTND
1862setup: prefix: (null)
1863EOF
e6ec2b6a
JS
1864 git config --file="$here/14.git/config" core.worktree ../14/wt &&
1865 test_repo 14/sub/sub "$here/14/.git"
69bf2b16
NTND
1866'
1867
b3f66fd3 1868test_expect_success '#14: GIT_DIR, core.worktree=../14/wt in subdir' '
69bf2b16 1869 cat >14/sub/sub/expected <<EOF &&
e6ec2b6a
JS
1870setup: git_dir: $here/14.git
1871setup: worktree: $here/14/wt
1872setup: cwd: $here/14/sub/sub
69bf2b16
NTND
1873setup: prefix: (null)
1874EOF
e6ec2b6a
JS
1875 git config --file="$here/14.git/config" core.worktree "$here/14/wt" &&
1876 test_repo 14/sub/sub "$here/14/.git"
69bf2b16
NTND
1877'
1878
b3f66fd3 1879test_expect_success '#14: GIT_DIR(rel), core.worktree=.. at root' '
69bf2b16 1880 cat >14/expected <<EOF &&
e6ec2b6a
JS
1881setup: git_dir: $here/14.git
1882setup: worktree: $here
1883setup: cwd: $here
69bf2b16
NTND
1884setup: prefix: 14/
1885EOF
e6ec2b6a 1886 git config --file="$here/14.git/config" core.worktree "$here" &&
69bf2b16
NTND
1887 test_repo 14 .git
1888'
1889
b3f66fd3 1890test_expect_success '#14: GIT_DIR(rel), core.worktree=..(rel) at root' '
69bf2b16 1891 cat >14/expected <<EOF &&
e6ec2b6a
JS
1892setup: git_dir: $here/14.git
1893setup: worktree: $here
1894setup: cwd: $here
69bf2b16
NTND
1895setup: prefix: 14/
1896EOF
e6ec2b6a 1897 git config --file="$here/14.git/config" core.worktree .. &&
69bf2b16
NTND
1898 test_repo 14 .git
1899'
1900
b3f66fd3 1901test_expect_success '#14: GIT_DIR, core.worktree=..(rel) at root' '
69bf2b16 1902 cat >14/expected <<EOF &&
e6ec2b6a
JS
1903setup: git_dir: $here/14.git
1904setup: worktree: $here
1905setup: cwd: $here
69bf2b16
NTND
1906setup: prefix: 14/
1907EOF
e6ec2b6a
JS
1908 git config --file="$here/14.git/config" core.worktree .. &&
1909 test_repo 14 "$here/14/.git"
69bf2b16
NTND
1910'
1911
b3f66fd3 1912test_expect_success '#14: GIT_DIR, core.worktree=.. at root' '
69bf2b16 1913 cat >14/expected <<EOF &&
e6ec2b6a
JS
1914setup: git_dir: $here/14.git
1915setup: worktree: $here
1916setup: cwd: $here
69bf2b16
NTND
1917setup: prefix: 14/
1918EOF
e6ec2b6a
JS
1919 git config --file="$here/14.git/config" core.worktree "$here" &&
1920 test_repo 14 "$here/14/.git"
69bf2b16
NTND
1921'
1922
b3f66fd3 1923test_expect_success '#14: GIT_DIR(rel), core.worktree=.. in subdir' '
69bf2b16 1924 cat >14/sub/sub/expected <<EOF &&
e6ec2b6a
JS
1925setup: git_dir: $here/14.git
1926setup: worktree: $here
1927setup: cwd: $here
69bf2b16
NTND
1928setup: prefix: 14/sub/sub/
1929EOF
e6ec2b6a 1930 git config --file="$here/14.git/config" core.worktree "$here" &&
69bf2b16
NTND
1931 test_repo 14/sub/sub ../../.git
1932'
1933
b3f66fd3 1934test_expect_success '#14: GIT_DIR(rel), core.worktree=..(rel) in subdir' '
69bf2b16 1935 cat >14/sub/sub/expected <<EOF &&
e6ec2b6a
JS
1936setup: git_dir: $here/14.git
1937setup: worktree: $here
1938setup: cwd: $here
69bf2b16
NTND
1939setup: prefix: 14/sub/sub/
1940EOF
e6ec2b6a 1941 git config --file="$here/14.git/config" core.worktree .. &&
69bf2b16
NTND
1942 test_repo 14/sub/sub ../../.git
1943'
1944
b3f66fd3 1945test_expect_success '#14: GIT_DIR, core.worktree=..(rel) in subdir' '
69bf2b16 1946 cat >14/sub/sub/expected <<EOF &&
e6ec2b6a
JS
1947setup: git_dir: $here/14.git
1948setup: worktree: $here
1949setup: cwd: $here
69bf2b16
NTND
1950setup: prefix: 14/sub/sub/
1951EOF
e6ec2b6a
JS
1952 git config --file="$here/14.git/config" core.worktree .. &&
1953 test_repo 14/sub/sub "$here/14/.git"
69bf2b16
NTND
1954'
1955
b3f66fd3 1956test_expect_success '#14: GIT_DIR, core.worktree=.. in subdir' '
69bf2b16 1957 cat >14/sub/sub/expected <<EOF &&
e6ec2b6a
JS
1958setup: git_dir: $here/14.git
1959setup: worktree: $here
1960setup: cwd: $here
69bf2b16
NTND
1961setup: prefix: 14/sub/sub/
1962EOF
e6ec2b6a
JS
1963 git config --file="$here/14.git/config" core.worktree "$here" &&
1964 test_repo 14/sub/sub "$here/14/.git"
69bf2b16
NTND
1965'
1966
f7c85883
NTND
1967#
1968# case #15
1969#
1970############################################################
1971#
1972# Input:
1973#
1974# - GIT_WORK_TREE is set
1975# - GIT_DIR is set
1976# - core.worktree is set
1977# - .git is a file
1978# - core.bare is not set, cwd is outside .git
1979#
1980# Output:
1981#
1982# #7 except that git_dir is set by .git file
1983
1984test_expect_success '#15: setup' '
ed40ec55 1985 sane_unset GIT_DIR GIT_WORK_TREE &&
f7c85883
NTND
1986 mkdir 15 15/sub 15/sub/sub 15.wt 15.wt/sub 15/wt 15/wt/sub &&
1987 cd 15 &&
1988 git init &&
1989 git config core.worktree non-existent &&
1990 mv .git ../15.git &&
1991 echo gitdir: ../15.git >.git &&
1992 cd ..
1993'
1994
b3f66fd3 1995test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
f7c85883 1996 cat >15/expected <<EOF &&
e6ec2b6a
JS
1997setup: git_dir: $here/15.git
1998setup: worktree: $here/15
1999setup: cwd: $here/15
f7c85883
NTND
2000setup: prefix: (null)
2001EOF
e6ec2b6a 2002 test_repo 15 .git "$here/15"
f7c85883
NTND
2003'
2004
b3f66fd3 2005test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
f7c85883 2006 cat >15/expected <<EOF &&
e6ec2b6a
JS
2007setup: git_dir: $here/15.git
2008setup: worktree: $here/15
2009setup: cwd: $here/15
f7c85883
NTND
2010setup: prefix: (null)
2011EOF
2012 test_repo 15 .git .
2013'
2014
b3f66fd3 2015test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=root at root' '
f7c85883 2016 cat >15/expected <<EOF &&
e6ec2b6a
JS
2017setup: git_dir: $here/15.git
2018setup: worktree: $here/15
2019setup: cwd: $here/15
f7c85883
NTND
2020setup: prefix: (null)
2021EOF
e6ec2b6a 2022 test_repo 15 "$here/15/.git" "$here/15"
f7c85883
NTND
2023'
2024
b3f66fd3 2025test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
f7c85883 2026 cat >15/expected <<EOF &&
e6ec2b6a
JS
2027setup: git_dir: $here/15.git
2028setup: worktree: $here/15
2029setup: cwd: $here/15
f7c85883
NTND
2030setup: prefix: (null)
2031EOF
e6ec2b6a 2032 test_repo 15 "$here/15/.git" .
f7c85883
NTND
2033'
2034
b3f66fd3 2035test_expect_success '#15: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
f7c85883 2036 cat >15/sub/sub/expected <<EOF &&
e6ec2b6a
JS
2037setup: git_dir: $here/15.git
2038setup: worktree: $here/15
2039setup: cwd: $here/15
f7c85883
NTND
2040setup: prefix: sub/sub/
2041EOF
e6ec2b6a 2042 test_repo 15/sub/sub ../../.git "$here/15"
f7c85883
NTND
2043'
2044
b3f66fd3 2045test_expect_success '#15: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
f7c85883 2046 cat >15/sub/sub/expected <<EOF &&
e6ec2b6a
JS
2047setup: git_dir: $here/15.git
2048setup: worktree: $here/15
2049setup: cwd: $here/15
f7c85883
NTND
2050setup: prefix: sub/sub/
2051EOF
2052 test_repo 15/sub/sub ../../.git ../..
2053'
2054
b3f66fd3 2055test_expect_success '#15: GIT_DIR, GIT_WORKTREE=root in subdir' '
f7c85883 2056 cat >15/sub/expected <<EOF &&
e6ec2b6a
JS
2057setup: git_dir: $here/15.git
2058setup: worktree: $here/15
2059setup: cwd: $here/15
f7c85883
NTND
2060setup: prefix: sub/
2061EOF
e6ec2b6a 2062 test_repo 15/sub "$here/15/.git" "$here/15"
f7c85883
NTND
2063'
2064
b3f66fd3 2065test_expect_success '#15: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
f7c85883 2066 cat >15/sub/sub/expected <<EOF &&
e6ec2b6a
JS
2067setup: git_dir: $here/15.git
2068setup: worktree: $here/15
2069setup: cwd: $here/15
f7c85883
NTND
2070setup: prefix: sub/sub/
2071EOF
e6ec2b6a 2072 test_repo 15/sub/sub "$here/15/.git" ../..
f7c85883
NTND
2073'
2074
b3f66fd3 2075test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
f7c85883 2076 cat >15/expected <<EOF &&
e6ec2b6a
JS
2077setup: git_dir: $here/15.git
2078setup: worktree: $here/15/wt
2079setup: cwd: $here/15
f7c85883
NTND
2080setup: prefix: (null)
2081EOF
e6ec2b6a 2082 test_repo 15 .git "$here/15/wt"
f7c85883
NTND
2083'
2084
b3f66fd3 2085test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
f7c85883 2086 cat >15/expected <<EOF &&
e6ec2b6a
JS
2087setup: git_dir: $here/15.git
2088setup: worktree: $here/15/wt
2089setup: cwd: $here/15
f7c85883
NTND
2090setup: prefix: (null)
2091EOF
2092 test_repo 15 .git wt
2093'
2094
b3f66fd3 2095test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
f7c85883 2096 cat >15/expected <<EOF &&
e6ec2b6a
JS
2097setup: git_dir: $here/15.git
2098setup: worktree: $here/15/wt
2099setup: cwd: $here/15
f7c85883
NTND
2100setup: prefix: (null)
2101EOF
e6ec2b6a 2102 test_repo 15 "$here/15/.git" wt
f7c85883
NTND
2103'
2104
b3f66fd3 2105test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=wt at root' '
f7c85883 2106 cat >15/expected <<EOF &&
e6ec2b6a
JS
2107setup: git_dir: $here/15.git
2108setup: worktree: $here/15/wt
2109setup: cwd: $here/15
f7c85883
NTND
2110setup: prefix: (null)
2111EOF
e6ec2b6a 2112 test_repo 15 "$here/15/.git" "$here/15/wt"
f7c85883
NTND
2113'
2114
b3f66fd3 2115test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
f7c85883 2116 cat >15/sub/sub/expected <<EOF &&
e6ec2b6a
JS
2117setup: git_dir: $here/15.git
2118setup: worktree: $here/15/wt
2119setup: cwd: $here/15/sub/sub
f7c85883
NTND
2120setup: prefix: (null)
2121EOF
e6ec2b6a 2122 test_repo 15/sub/sub ../../.git "$here/15/wt"
f7c85883
NTND
2123'
2124
b3f66fd3 2125test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
f7c85883 2126 cat >15/sub/sub/expected <<EOF &&
e6ec2b6a
JS
2127setup: git_dir: $here/15.git
2128setup: worktree: $here/15/wt
2129setup: cwd: $here/15/sub/sub
f7c85883
NTND
2130setup: prefix: (null)
2131EOF
2132 test_repo 15/sub/sub ../../.git ../../wt
2133'
2134
b3f66fd3 2135test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
f7c85883 2136 cat >15/sub/sub/expected <<EOF &&
e6ec2b6a
JS
2137setup: git_dir: $here/15.git
2138setup: worktree: $here/15/wt
2139setup: cwd: $here/15/sub/sub
f7c85883
NTND
2140setup: prefix: (null)
2141EOF
e6ec2b6a 2142 test_repo 15/sub/sub "$here/15/.git" ../../wt
f7c85883
NTND
2143'
2144
b3f66fd3 2145test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
f7c85883 2146 cat >15/sub/sub/expected <<EOF &&
e6ec2b6a
JS
2147setup: git_dir: $here/15.git
2148setup: worktree: $here/15/wt
2149setup: cwd: $here/15/sub/sub
f7c85883
NTND
2150setup: prefix: (null)
2151EOF
e6ec2b6a 2152 test_repo 15/sub/sub "$here/15/.git" "$here/15/wt"
f7c85883
NTND
2153'
2154
b3f66fd3 2155test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
f7c85883 2156 cat >15/expected <<EOF &&
e6ec2b6a
JS
2157setup: git_dir: $here/15.git
2158setup: worktree: $here
2159setup: cwd: $here
f7c85883
NTND
2160setup: prefix: 15/
2161EOF
e6ec2b6a 2162 test_repo 15 .git "$here"
f7c85883
NTND
2163'
2164
b3f66fd3 2165test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
f7c85883 2166 cat >15/expected <<EOF &&
e6ec2b6a
JS
2167setup: git_dir: $here/15.git
2168setup: worktree: $here
2169setup: cwd: $here
f7c85883
NTND
2170setup: prefix: 15/
2171EOF
2172 test_repo 15 .git ..
2173'
2174
b3f66fd3 2175test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
f7c85883 2176 cat >15/expected <<EOF &&
e6ec2b6a
JS
2177setup: git_dir: $here/15.git
2178setup: worktree: $here
2179setup: cwd: $here
f7c85883
NTND
2180setup: prefix: 15/
2181EOF
e6ec2b6a 2182 test_repo 15 "$here/15/.git" ..
f7c85883
NTND
2183'
2184
b3f66fd3 2185test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=.. at root' '
f7c85883 2186 cat >15/expected <<EOF &&
e6ec2b6a
JS
2187setup: git_dir: $here/15.git
2188setup: worktree: $here
2189setup: cwd: $here
f7c85883
NTND
2190setup: prefix: 15/
2191EOF
e6ec2b6a 2192 test_repo 15 "$here/15/.git" "$here"
f7c85883
NTND
2193'
2194
b3f66fd3 2195test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
f7c85883 2196 cat >15/sub/sub/expected <<EOF &&
e6ec2b6a
JS
2197setup: git_dir: $here/15.git
2198setup: worktree: $here
2199setup: cwd: $here
f7c85883
NTND
2200setup: prefix: 15/sub/sub/
2201EOF
e6ec2b6a 2202 test_repo 15/sub/sub ../../.git "$here"
f7c85883
NTND
2203'
2204
b3f66fd3 2205test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
f7c85883 2206 cat >15/sub/sub/expected <<EOF &&
e6ec2b6a
JS
2207setup: git_dir: $here/15.git
2208setup: worktree: $here
2209setup: cwd: $here
f7c85883
NTND
2210setup: prefix: 15/sub/sub/
2211EOF
2212 test_repo 15/sub/sub ../../.git ../../..
2213'
2214
b3f66fd3 2215test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
f7c85883 2216 cat >15/sub/sub/expected <<EOF &&
e6ec2b6a
JS
2217setup: git_dir: $here/15.git
2218setup: worktree: $here
2219setup: cwd: $here
f7c85883
NTND
2220setup: prefix: 15/sub/sub/
2221EOF
e6ec2b6a 2222 test_repo 15/sub/sub "$here/15/.git" ../../../
f7c85883
NTND
2223'
2224
b3f66fd3 2225test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
f7c85883 2226 cat >15/sub/sub/expected <<EOF &&
e6ec2b6a
JS
2227setup: git_dir: $here/15.git
2228setup: worktree: $here
2229setup: cwd: $here
f7c85883
NTND
2230setup: prefix: 15/sub/sub/
2231EOF
e6ec2b6a 2232 test_repo 15/sub/sub "$here/15/.git" "$here"
f7c85883
NTND
2233'
2234
af62cc1b
NTND
2235#
2236# case #16.1
2237#
2238############################################################
2239#
2240# Input:
2241#
2242# - GIT_WORK_TREE is not set
2243# - GIT_DIR is not set
2244# - core.worktree is not set
2245# - .git is a directory
2246# - cwd is inside .git
2247#
2248# Output:
2249#
2250# - no worktree
2251# - cwd is unchanged
2252# - prefix is NULL
2253# - git_dir is set
2254# - cwd can't be outside worktree
2255
2256test_expect_success '#16.1: setup' '
ed40ec55 2257 sane_unset GIT_DIR GIT_WORK_TREE &&
af62cc1b
NTND
2258 mkdir 16 16/sub &&
2259 cd 16 &&
2260 git init &&
2261 mkdir .git/wt .git/wt/sub &&
2262 cd ..
2263'
2264
2265test_expect_success '#16.1: at .git' '
2266 cat >16/.git/expected <<EOF &&
2267setup: git_dir: .
2268setup: worktree: (null)
e6ec2b6a 2269setup: cwd: $here/16/.git
af62cc1b
NTND
2270setup: prefix: (null)
2271EOF
2272 test_repo 16/.git
2273'
2274
2275test_expect_success '#16.1: in .git/wt' '
2276 cat >16/.git/wt/expected <<EOF &&
e6ec2b6a 2277setup: git_dir: $here/16/.git
af62cc1b 2278setup: worktree: (null)
e6ec2b6a 2279setup: cwd: $here/16/.git/wt
af62cc1b
NTND
2280setup: prefix: (null)
2281EOF
2282 test_repo 16/.git/wt
2283'
2284
2285test_expect_success '#16.1: in .git/wt/sub' '
2286 cat >16/.git/wt/sub/expected <<EOF &&
e6ec2b6a 2287setup: git_dir: $here/16/.git
af62cc1b 2288setup: worktree: (null)
e6ec2b6a 2289setup: cwd: $here/16/.git/wt/sub
af62cc1b
NTND
2290setup: prefix: (null)
2291EOF
2292 test_repo 16/.git/wt/sub
2293'
2294
2295#
2296# case #16.2
2297#
2298############################################################
2299#
2300# Input:
2301#
2302# - GIT_WORK_TREE is not set
2303# - GIT_DIR is not set
2304# - core.worktree is not set
2305# - .git is a directory
2306# - core.bare is set
2307#
2308# Output:
2309#
2310# - no worktree
2311# - cwd is unchanged
2312# - prefix is NULL
2313# - git_dir is set
2314# - cwd can't be outside worktree
2315
2316test_expect_success '#16.2: setup' '
e6ec2b6a 2317 git config --file="$here/16/.git/config" core.bare true
af62cc1b
NTND
2318'
2319
2320test_expect_success '#16.2: at .git' '
2321 cat >16/.git/expected <<EOF &&
2322setup: git_dir: .
2323setup: worktree: (null)
e6ec2b6a 2324setup: cwd: $here/16/.git
af62cc1b
NTND
2325setup: prefix: (null)
2326EOF
2327 test_repo 16/.git
2328'
2329
2330test_expect_success '#16.2: in .git/wt' '
2331 cat >16/.git/wt/expected <<EOF &&
e6ec2b6a 2332setup: git_dir: $here/16/.git
af62cc1b 2333setup: worktree: (null)
e6ec2b6a 2334setup: cwd: $here/16/.git/wt
af62cc1b
NTND
2335setup: prefix: (null)
2336EOF
2337 test_repo 16/.git/wt
2338'
2339
2340test_expect_success '#16.2: in .git/wt/sub' '
2341 cat >16/.git/wt/sub/expected <<EOF &&
e6ec2b6a 2342setup: git_dir: $here/16/.git
af62cc1b 2343setup: worktree: (null)
e6ec2b6a 2344setup: cwd: $here/16/.git/wt/sub
af62cc1b
NTND
2345setup: prefix: (null)
2346EOF
2347 test_repo 16/.git/wt/sub
2348'
2349
2350test_expect_success '#16.2: at root' '
2351 cat >16/expected <<EOF &&
2352setup: git_dir: .git
2353setup: worktree: (null)
e6ec2b6a 2354setup: cwd: $here/16
af62cc1b
NTND
2355setup: prefix: (null)
2356EOF
2357 test_repo 16
2358'
2359
9951d3b3 2360test_expect_success '#16.2: in subdir' '
af62cc1b 2361 cat >16/sub/expected <<EOF &&
e6ec2b6a 2362setup: git_dir: $here/16/.git
af62cc1b 2363setup: worktree: (null)
e6ec2b6a 2364setup: cwd: $here/16/sub
af62cc1b
NTND
2365setup: prefix: (null)
2366EOF
2367 test_repo 16/sub
2368'
2369
cf83243b
NTND
2370#
2371# case #17.1
2372#
2373############################################################
2374#
2375# Input:
2376#
2377# - GIT_WORK_TREE is set
2378# - GIT_DIR is not set
2379# - core.worktree is not set
2380# - .git is a directory
2381# - cwd is inside .git
2382#
2383# Output:
2384#
2385# GIT_WORK_TREE is ignored -> #16.1 (with warnings perhaps)
2386
2387test_expect_success '#17.1: setup' '
ed40ec55 2388 sane_unset GIT_DIR GIT_WORK_TREE &&
cf83243b
NTND
2389 mkdir 17 17/sub &&
2390 cd 17 &&
2391 git init &&
2392 mkdir .git/wt .git/wt/sub &&
2393 GIT_WORK_TREE=non-existent &&
2394 export GIT_WORK_TREE &&
2395 cd ..
2396'
2397
e6aea2db 2398test_expect_success '#17.1: at .git' '
cf83243b
NTND
2399 cat >17/.git/expected <<EOF &&
2400setup: git_dir: .
2401setup: worktree: (null)
e6ec2b6a 2402setup: cwd: $here/17/.git
cf83243b
NTND
2403setup: prefix: (null)
2404EOF
2405 test_repo 17/.git
2406'
2407
e6aea2db 2408test_expect_success '#17.1: in .git/wt' '
cf83243b 2409 cat >17/.git/wt/expected <<EOF &&
e6ec2b6a 2410setup: git_dir: $here/17/.git
cf83243b 2411setup: worktree: (null)
e6ec2b6a 2412setup: cwd: $here/17/.git/wt
cf83243b
NTND
2413setup: prefix: (null)
2414EOF
2415 test_repo 17/.git/wt
2416'
2417
e6aea2db 2418test_expect_success '#17.1: in .git/wt/sub' '
cf83243b 2419 cat >17/.git/wt/sub/expected <<EOF &&
e6ec2b6a 2420setup: git_dir: $here/17/.git
cf83243b 2421setup: worktree: (null)
e6ec2b6a 2422setup: cwd: $here/17/.git/wt/sub
cf83243b
NTND
2423setup: prefix: (null)
2424EOF
2425 test_repo 17/.git/wt/sub
2426'
2427
2428#
2429# case #17.2
2430#
2431############################################################
2432#
2433# Input:
2434#
2435# - GIT_WORK_TREE is set
2436# - GIT_DIR is not set
2437# - core.worktree is not set
2438# - .git is a directory
2439# - core.bare is set
2440#
2441# Output:
2442#
2443# GIT_WORK_TREE is ignored -> #16.2 (with warnings perhaps)
2444
2445test_expect_success '#17.2: setup' '
e6ec2b6a 2446 git config --file="$here/17/.git/config" core.bare true
cf83243b
NTND
2447'
2448
e6aea2db 2449test_expect_success '#17.2: at .git' '
cf83243b
NTND
2450 cat >17/.git/expected <<EOF &&
2451setup: git_dir: .
2452setup: worktree: (null)
e6ec2b6a 2453setup: cwd: $here/17/.git
cf83243b
NTND
2454setup: prefix: (null)
2455EOF
2456 test_repo 17/.git
2457'
2458
e6aea2db 2459test_expect_success '#17.2: in .git/wt' '
cf83243b 2460 cat >17/.git/wt/expected <<EOF &&
e6ec2b6a 2461setup: git_dir: $here/17/.git
cf83243b 2462setup: worktree: (null)
e6ec2b6a 2463setup: cwd: $here/17/.git/wt
cf83243b
NTND
2464setup: prefix: (null)
2465EOF
2466 test_repo 17/.git/wt
2467'
2468
e6aea2db 2469test_expect_success '#17.2: in .git/wt/sub' '
cf83243b 2470 cat >17/.git/wt/sub/expected <<EOF &&
e6ec2b6a 2471setup: git_dir: $here/17/.git
cf83243b 2472setup: worktree: (null)
e6ec2b6a 2473setup: cwd: $here/17/.git/wt/sub
cf83243b
NTND
2474setup: prefix: (null)
2475EOF
2476 test_repo 17/.git/wt/sub
2477'
2478
e6aea2db 2479test_expect_success '#17.2: at root' '
cf83243b
NTND
2480 cat >17/expected <<EOF &&
2481setup: git_dir: .git
2482setup: worktree: (null)
e6ec2b6a 2483setup: cwd: $here/17
cf83243b
NTND
2484setup: prefix: (null)
2485EOF
2486 test_repo 17
2487'
2488
9951d3b3 2489test_expect_success '#17.2: in subdir' '
cf83243b 2490 cat >17/sub/expected <<EOF &&
e6ec2b6a 2491setup: git_dir: $here/17/.git
cf83243b 2492setup: worktree: (null)
e6ec2b6a 2493setup: cwd: $here/17/sub
cf83243b
NTND
2494setup: prefix: (null)
2495EOF
2496 test_repo 17/sub
2497'
2498
37eecb3d
NTND
2499#
2500# case #18
2501#
2502############################################################
2503#
2504# Input:
2505#
2506# - GIT_WORK_TREE is not set
2507# - GIT_DIR is set
2508# - core.worktree is not set
2509# - .git is a directory
2510# - core.bare is set
2511#
2512# Output:
2513#
2514# - no worktree (rule #8)
2515# - cwd is unchanged
2516# - prefix is NULL
2517# - git_dir is set to $GIT_DIR
2518# - cwd can't be outside worktree
2519
2520test_expect_success '#18: setup' '
ed40ec55 2521 sane_unset GIT_DIR GIT_WORK_TREE &&
37eecb3d
NTND
2522 mkdir 18 18/sub &&
2523 cd 18 &&
2524 git init &&
2525 mkdir .git/wt .git/wt/sub &&
2526 git config core.bare true &&
2527 cd ..
2528'
2529
2530test_expect_success '#18: (rel) at root' '
2531 cat >18/expected <<EOF &&
2532setup: git_dir: .git
2533setup: worktree: (null)
e6ec2b6a 2534setup: cwd: $here/18
37eecb3d
NTND
2535setup: prefix: (null)
2536EOF
2537 test_repo 18 .git
2538'
2539
2540test_expect_success '#18: at root' '
2541 cat >18/expected <<EOF &&
e6ec2b6a 2542setup: git_dir: $here/18/.git
37eecb3d 2543setup: worktree: (null)
e6ec2b6a 2544setup: cwd: $here/18
37eecb3d
NTND
2545setup: prefix: (null)
2546EOF
e6ec2b6a 2547 test_repo 18 "$here/18/.git"
37eecb3d
NTND
2548'
2549
2550test_expect_success '#18: (rel) in subdir' '
2551 cat >18/sub/expected <<EOF &&
2552setup: git_dir: ../.git
2553setup: worktree: (null)
e6ec2b6a 2554setup: cwd: $here/18/sub
37eecb3d
NTND
2555setup: prefix: (null)
2556EOF
2557 test_repo 18/sub ../.git
2558'
2559
2560test_expect_success '#18: in subdir' '
2561 cat >18/sub/expected <<EOF &&
e6ec2b6a 2562setup: git_dir: $here/18/.git
37eecb3d 2563setup: worktree: (null)
e6ec2b6a 2564setup: cwd: $here/18/sub
37eecb3d
NTND
2565setup: prefix: (null)
2566EOF
e6ec2b6a 2567 test_repo 18/sub "$here/18/.git"
37eecb3d
NTND
2568'
2569
09327fd8
NTND
2570#
2571# case #19
2572#
2573############################################################
2574#
2575# Input:
2576#
2577# - GIT_WORK_TREE is set
2578# - GIT_DIR is set
2579# - .git is a directory
2580# - core.worktree is not set
2581# - core.bare is set
2582#
2583# Output:
2584#
2585# bare repo is overridden by GIT_WORK_TREE -> #3
2586
2587test_expect_success '#19: setup' '
ed40ec55 2588 sane_unset GIT_DIR GIT_WORK_TREE &&
09327fd8
NTND
2589 mkdir 19 19/sub 19/sub/sub 19.wt 19.wt/sub 19/wt 19/wt/sub &&
2590 cd 19 &&
2591 git init &&
2592 git config core.bare true &&
2593 cd ..
2594'
2595
2596test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
2597 cat >19/expected <<EOF &&
2598setup: git_dir: .git
e6ec2b6a
JS
2599setup: worktree: $here/19
2600setup: cwd: $here/19
09327fd8
NTND
2601setup: prefix: (null)
2602EOF
e6ec2b6a 2603 test_repo 19 .git "$here/19"
09327fd8
NTND
2604'
2605
2606test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
2607 cat >19/expected <<EOF &&
2608setup: git_dir: .git
e6ec2b6a
JS
2609setup: worktree: $here/19
2610setup: cwd: $here/19
09327fd8
NTND
2611setup: prefix: (null)
2612EOF
2613 test_repo 19 .git .
2614'
2615
2616test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=root at root' '
2617 cat >19/expected <<EOF &&
e6ec2b6a
JS
2618setup: git_dir: $here/19/.git
2619setup: worktree: $here/19
2620setup: cwd: $here/19
09327fd8
NTND
2621setup: prefix: (null)
2622EOF
e6ec2b6a 2623 test_repo 19 "$here/19/.git" "$here/19"
09327fd8
NTND
2624'
2625
2626test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
2627 cat >19/expected <<EOF &&
e6ec2b6a
JS
2628setup: git_dir: $here/19/.git
2629setup: worktree: $here/19
2630setup: cwd: $here/19
09327fd8
NTND
2631setup: prefix: (null)
2632EOF
e6ec2b6a 2633 test_repo 19 "$here/19/.git" .
09327fd8
NTND
2634'
2635
2636test_expect_success '#19: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
2637 cat >19/sub/sub/expected <<EOF &&
e6ec2b6a
JS
2638setup: git_dir: $here/19/.git
2639setup: worktree: $here/19
2640setup: cwd: $here/19
09327fd8
NTND
2641setup: prefix: sub/sub/
2642EOF
e6ec2b6a 2643 test_repo 19/sub/sub ../../.git "$here/19"
09327fd8
NTND
2644'
2645
2646test_expect_success '#19: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
2647 cat >19/sub/sub/expected <<EOF &&
e6ec2b6a
JS
2648setup: git_dir: $here/19/.git
2649setup: worktree: $here/19
2650setup: cwd: $here/19
09327fd8
NTND
2651setup: prefix: sub/sub/
2652EOF
2653 test_repo 19/sub/sub ../../.git ../..
2654'
2655
2656test_expect_success '#19: GIT_DIR, GIT_WORKTREE=root in subdir' '
2657 cat >19/sub/expected <<EOF &&
e6ec2b6a
JS
2658setup: git_dir: $here/19/.git
2659setup: worktree: $here/19
2660setup: cwd: $here/19
09327fd8
NTND
2661setup: prefix: sub/
2662EOF
e6ec2b6a 2663 test_repo 19/sub "$here/19/.git" "$here/19"
09327fd8
NTND
2664'
2665
2666test_expect_success '#19: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
2667 cat >19/sub/sub/expected <<EOF &&
e6ec2b6a
JS
2668setup: git_dir: $here/19/.git
2669setup: worktree: $here/19
2670setup: cwd: $here/19
09327fd8
NTND
2671setup: prefix: sub/sub/
2672EOF
e6ec2b6a 2673 test_repo 19/sub/sub "$here/19/.git" ../..
09327fd8
NTND
2674'
2675
2676test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
2677 cat >19/expected <<EOF &&
2678setup: git_dir: .git
e6ec2b6a
JS
2679setup: worktree: $here/19/wt
2680setup: cwd: $here/19
09327fd8
NTND
2681setup: prefix: (null)
2682EOF
e6ec2b6a 2683 test_repo 19 .git "$here/19/wt"
09327fd8
NTND
2684'
2685
2686test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
2687 cat >19/expected <<EOF &&
2688setup: git_dir: .git
e6ec2b6a
JS
2689setup: worktree: $here/19/wt
2690setup: cwd: $here/19
09327fd8
NTND
2691setup: prefix: (null)
2692EOF
2693 test_repo 19 .git wt
2694'
2695
2696test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
2697 cat >19/expected <<EOF &&
e6ec2b6a
JS
2698setup: git_dir: $here/19/.git
2699setup: worktree: $here/19/wt
2700setup: cwd: $here/19
09327fd8
NTND
2701setup: prefix: (null)
2702EOF
e6ec2b6a 2703 test_repo 19 "$here/19/.git" wt
09327fd8
NTND
2704'
2705
2706test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=wt at root' '
2707 cat >19/expected <<EOF &&
e6ec2b6a
JS
2708setup: git_dir: $here/19/.git
2709setup: worktree: $here/19/wt
2710setup: cwd: $here/19
09327fd8
NTND
2711setup: prefix: (null)
2712EOF
e6ec2b6a 2713 test_repo 19 "$here/19/.git" "$here/19/wt"
09327fd8
NTND
2714'
2715
2716test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
2717 cat >19/sub/sub/expected <<EOF &&
2718setup: git_dir: ../../.git
e6ec2b6a
JS
2719setup: worktree: $here/19/wt
2720setup: cwd: $here/19/sub/sub
09327fd8
NTND
2721setup: prefix: (null)
2722EOF
e6ec2b6a 2723 test_repo 19/sub/sub ../../.git "$here/19/wt"
09327fd8
NTND
2724'
2725
2726test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
2727 cat >19/sub/sub/expected <<EOF &&
2728setup: git_dir: ../../.git
e6ec2b6a
JS
2729setup: worktree: $here/19/wt
2730setup: cwd: $here/19/sub/sub
09327fd8
NTND
2731setup: prefix: (null)
2732EOF
2733 test_repo 19/sub/sub ../../.git ../../wt
2734'
2735
2736test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
2737 cat >19/sub/sub/expected <<EOF &&
e6ec2b6a
JS
2738setup: git_dir: $here/19/.git
2739setup: worktree: $here/19/wt
2740setup: cwd: $here/19/sub/sub
09327fd8
NTND
2741setup: prefix: (null)
2742EOF
e6ec2b6a 2743 test_repo 19/sub/sub "$here/19/.git" ../../wt
09327fd8
NTND
2744'
2745
2746test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
2747 cat >19/sub/sub/expected <<EOF &&
e6ec2b6a
JS
2748setup: git_dir: $here/19/.git
2749setup: worktree: $here/19/wt
2750setup: cwd: $here/19/sub/sub
09327fd8
NTND
2751setup: prefix: (null)
2752EOF
e6ec2b6a 2753 test_repo 19/sub/sub "$here/19/.git" "$here/19/wt"
09327fd8
NTND
2754'
2755
2756test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
2757 cat >19/expected <<EOF &&
e6ec2b6a
JS
2758setup: git_dir: $here/19/.git
2759setup: worktree: $here
2760setup: cwd: $here
09327fd8
NTND
2761setup: prefix: 19/
2762EOF
e6ec2b6a 2763 test_repo 19 .git "$here"
09327fd8
NTND
2764'
2765
2766test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
2767 cat >19/expected <<EOF &&
e6ec2b6a
JS
2768setup: git_dir: $here/19/.git
2769setup: worktree: $here
2770setup: cwd: $here
09327fd8
NTND
2771setup: prefix: 19/
2772EOF
2773 test_repo 19 .git ..
2774'
2775
2776test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
2777 cat >19/expected <<EOF &&
e6ec2b6a
JS
2778setup: git_dir: $here/19/.git
2779setup: worktree: $here
2780setup: cwd: $here
09327fd8
NTND
2781setup: prefix: 19/
2782EOF
e6ec2b6a 2783 test_repo 19 "$here/19/.git" ..
09327fd8
NTND
2784'
2785
2786test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=.. at root' '
2787 cat >19/expected <<EOF &&
e6ec2b6a
JS
2788setup: git_dir: $here/19/.git
2789setup: worktree: $here
2790setup: cwd: $here
09327fd8
NTND
2791setup: prefix: 19/
2792EOF
e6ec2b6a 2793 test_repo 19 "$here/19/.git" "$here"
09327fd8
NTND
2794'
2795
2796test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
2797 cat >19/sub/sub/expected <<EOF &&
e6ec2b6a
JS
2798setup: git_dir: $here/19/.git
2799setup: worktree: $here
2800setup: cwd: $here
09327fd8
NTND
2801setup: prefix: 19/sub/sub/
2802EOF
e6ec2b6a 2803 test_repo 19/sub/sub ../../.git "$here"
09327fd8
NTND
2804'
2805
2806test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
2807 cat >19/sub/sub/expected <<EOF &&
e6ec2b6a
JS
2808setup: git_dir: $here/19/.git
2809setup: worktree: $here
2810setup: cwd: $here
09327fd8
NTND
2811setup: prefix: 19/sub/sub/
2812EOF
2813 test_repo 19/sub/sub ../../.git ../../..
2814'
2815
2816test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
2817 cat >19/sub/sub/expected <<EOF &&
e6ec2b6a
JS
2818setup: git_dir: $here/19/.git
2819setup: worktree: $here
2820setup: cwd: $here
09327fd8
NTND
2821setup: prefix: 19/sub/sub/
2822EOF
e6ec2b6a 2823 test_repo 19/sub/sub "$here/19/.git" ../../../
09327fd8
NTND
2824'
2825
2826test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
2827 cat >19/sub/sub/expected <<EOF &&
e6ec2b6a
JS
2828setup: git_dir: $here/19/.git
2829setup: worktree: $here
2830setup: cwd: $here
09327fd8
NTND
2831setup: prefix: 19/sub/sub/
2832EOF
e6ec2b6a 2833 test_repo 19/sub/sub "$here/19/.git" "$here"
09327fd8
NTND
2834'
2835
4a008842
NTND
2836#
2837# case #20.1
2838#
2839############################################################
2840#
2841# Input:
2842#
2843# - GIT_WORK_TREE is not set
2844# - GIT_DIR is not set
2845# - core.worktree is set
2846# - .git is a directory
2847# - cwd is inside .git
2848#
2849# Output:
2850#
2851# core.worktree is ignored -> #16.1
2852
2853test_expect_success '#20.1: setup' '
ed40ec55 2854 sane_unset GIT_DIR GIT_WORK_TREE &&
4a008842
NTND
2855 mkdir 20 20/sub &&
2856 cd 20 &&
2857 git init &&
2858 git config core.worktree non-existent &&
2859 mkdir .git/wt .git/wt/sub &&
2860 cd ..
2861'
2862
e6aea2db 2863test_expect_success '#20.1: at .git' '
4a008842
NTND
2864 cat >20/.git/expected <<EOF &&
2865setup: git_dir: .
2866setup: worktree: (null)
e6ec2b6a 2867setup: cwd: $here/20/.git
4a008842
NTND
2868setup: prefix: (null)
2869EOF
2870 test_repo 20/.git
2871'
2872
e6aea2db 2873test_expect_success '#20.1: in .git/wt' '
4a008842 2874 cat >20/.git/wt/expected <<EOF &&
e6ec2b6a 2875setup: git_dir: $here/20/.git
4a008842 2876setup: worktree: (null)
e6ec2b6a 2877setup: cwd: $here/20/.git/wt
4a008842
NTND
2878setup: prefix: (null)
2879EOF
2880 test_repo 20/.git/wt
2881'
2882
e6aea2db 2883test_expect_success '#20.1: in .git/wt/sub' '
4a008842 2884 cat >20/.git/wt/sub/expected <<EOF &&
e6ec2b6a 2885setup: git_dir: $here/20/.git
4a008842 2886setup: worktree: (null)
e6ec2b6a 2887setup: cwd: $here/20/.git/wt/sub
4a008842
NTND
2888setup: prefix: (null)
2889EOF
2890 test_repo 20/.git/wt/sub
2891'
2892
2893#
2894# case #20.2
2895#
2896############################################################
2897#
2898# Input:
2899#
2900# - GIT_WORK_TREE is not set
2901# - GIT_DIR is not set
2902# - core.worktree is set
2903# - .git is a directory
2904# - core.bare is set
2905#
2906# Output:
2907#
2908# core.worktree is ignored -> #16.2
2909
2910test_expect_success '#20.2: setup' '
e6ec2b6a 2911 git config --file="$here/20/.git/config" core.bare true
4a008842
NTND
2912'
2913
2914test_expect_success '#20.2: at .git' '
2915 cat >20/.git/expected <<EOF &&
2916setup: git_dir: .
2917setup: worktree: (null)
e6ec2b6a 2918setup: cwd: $here/20/.git
4a008842
NTND
2919setup: prefix: (null)
2920EOF
2921 test_repo 20/.git
2922'
2923
2924test_expect_success '#20.2: in .git/wt' '
2925 cat >20/.git/wt/expected <<EOF &&
e6ec2b6a 2926setup: git_dir: $here/20/.git
4a008842 2927setup: worktree: (null)
e6ec2b6a 2928setup: cwd: $here/20/.git/wt
4a008842
NTND
2929setup: prefix: (null)
2930EOF
2931 test_repo 20/.git/wt
2932'
2933
2934test_expect_success '#20.2: in .git/wt/sub' '
2935 cat >20/.git/wt/sub/expected <<EOF &&
e6ec2b6a 2936setup: git_dir: $here/20/.git
4a008842 2937setup: worktree: (null)
e6ec2b6a 2938setup: cwd: $here/20/.git/wt/sub
4a008842
NTND
2939setup: prefix: (null)
2940EOF
2941 test_repo 20/.git/wt/sub
2942'
2943
2944test_expect_success '#20.2: at root' '
2945 cat >20/expected <<EOF &&
2946setup: git_dir: .git
2947setup: worktree: (null)
e6ec2b6a 2948setup: cwd: $here/20
4a008842
NTND
2949setup: prefix: (null)
2950EOF
2951 test_repo 20
2952'
2953
9951d3b3 2954test_expect_success '#20.2: in subdir' '
4a008842 2955 cat >20/sub/expected <<EOF &&
e6ec2b6a 2956setup: git_dir: $here/20/.git
4a008842 2957setup: worktree: (null)
e6ec2b6a 2958setup: cwd: $here/20/sub
4a008842
NTND
2959setup: prefix: (null)
2960EOF
2961 test_repo 20/sub
2962'
2963
21b3466f
NTND
2964#
2965# case #21.1
2966#
2967############################################################
2968#
2969# Input:
2970#
2971# - GIT_WORK_TREE is set
2972# - GIT_DIR is not set
2973# - core.worktree is set
2974# - .git is a directory
2975# - cwd is inside .git
2976#
2977# Output:
2978#
2979# GIT_WORK_TREE/core.worktree are ignored -> #20.1
2980
2981test_expect_success '#21.1: setup' '
ed40ec55 2982 sane_unset GIT_DIR GIT_WORK_TREE &&
21b3466f
NTND
2983 mkdir 21 21/sub &&
2984 cd 21 &&
2985 git init &&
2986 git config core.worktree non-existent &&
2987 GIT_WORK_TREE=non-existent-too &&
2988 export GIT_WORK_TREE &&
2989 mkdir .git/wt .git/wt/sub &&
2990 cd ..
2991'
2992
e6aea2db 2993test_expect_success '#21.1: at .git' '
21b3466f
NTND
2994 cat >21/.git/expected <<EOF &&
2995setup: git_dir: .
2996setup: worktree: (null)
e6ec2b6a 2997setup: cwd: $here/21/.git
21b3466f
NTND
2998setup: prefix: (null)
2999EOF
3000 test_repo 21/.git
3001'
3002
e6aea2db 3003test_expect_success '#21.1: in .git/wt' '
21b3466f 3004 cat >21/.git/wt/expected <<EOF &&
e6ec2b6a 3005setup: git_dir: $here/21/.git
21b3466f 3006setup: worktree: (null)
e6ec2b6a 3007setup: cwd: $here/21/.git/wt
21b3466f
NTND
3008setup: prefix: (null)
3009EOF
3010 test_repo 21/.git/wt
3011'
3012
e6aea2db 3013test_expect_success '#21.1: in .git/wt/sub' '
21b3466f 3014 cat >21/.git/wt/sub/expected <<EOF &&
e6ec2b6a 3015setup: git_dir: $here/21/.git
21b3466f 3016setup: worktree: (null)
e6ec2b6a 3017setup: cwd: $here/21/.git/wt/sub
21b3466f
NTND
3018setup: prefix: (null)
3019EOF
3020 test_repo 21/.git/wt/sub
3021'
3022
3023#
3024# case #21.2
3025#
3026############################################################
3027#
3028# Input:
3029#
3030# - GIT_WORK_TREE is set
3031# - GIT_DIR is not set
3032# - core.worktree is set
3033# - .git is a directory
3034# - core.bare is set
3035#
3036# Output:
3037#
3038# GIT_WORK_TREE/core.worktree are ignored -> #20.2
3039
3040test_expect_success '#21.2: setup' '
e6ec2b6a 3041 git config --file="$here/21/.git/config" core.bare true
21b3466f
NTND
3042'
3043
e6aea2db 3044test_expect_success '#21.2: at .git' '
21b3466f
NTND
3045 cat >21/.git/expected <<EOF &&
3046setup: git_dir: .
3047setup: worktree: (null)
e6ec2b6a 3048setup: cwd: $here/21/.git
21b3466f
NTND
3049setup: prefix: (null)
3050EOF
3051 test_repo 21/.git
3052'
3053
e6aea2db 3054test_expect_success '#21.2: in .git/wt' '
21b3466f 3055 cat >21/.git/wt/expected <<EOF &&
e6ec2b6a 3056setup: git_dir: $here/21/.git
21b3466f 3057setup: worktree: (null)
e6ec2b6a 3058setup: cwd: $here/21/.git/wt
21b3466f
NTND
3059setup: prefix: (null)
3060EOF
3061 test_repo 21/.git/wt
3062'
3063
e6aea2db 3064test_expect_success '#21.2: in .git/wt/sub' '
21b3466f 3065 cat >21/.git/wt/sub/expected <<EOF &&
e6ec2b6a 3066setup: git_dir: $here/21/.git
21b3466f 3067setup: worktree: (null)
e6ec2b6a 3068setup: cwd: $here/21/.git/wt/sub
21b3466f
NTND
3069setup: prefix: (null)
3070EOF
3071 test_repo 21/.git/wt/sub
3072'
3073
e6aea2db 3074test_expect_success '#21.2: at root' '
21b3466f
NTND
3075 cat >21/expected <<EOF &&
3076setup: git_dir: .git
3077setup: worktree: (null)
e6ec2b6a 3078setup: cwd: $here/21
21b3466f
NTND
3079setup: prefix: (null)
3080EOF
3081 test_repo 21
3082'
3083
9951d3b3 3084test_expect_success '#21.2: in subdir' '
21b3466f 3085 cat >21/sub/expected <<EOF &&
e6ec2b6a 3086setup: git_dir: $here/21/.git
21b3466f 3087setup: worktree: (null)
e6ec2b6a 3088setup: cwd: $here/21/sub
21b3466f
NTND
3089setup: prefix: (null)
3090EOF
3091 test_repo 21/sub
3092'
3093
fd4e1888
NTND
3094#
3095# case #22.1
3096#
3097############################################################
3098#
3099# Input:
3100#
3101# - GIT_WORK_TREE is not set
3102# - GIT_DIR is set
3103# - core.worktree is set
3104# - .git is a directory
3105# - cwd is inside .git
3106#
3107# Output:
3108#
3109# bare attribute is ignored
3110#
3111# - worktree is at core.worktree
3112# - cwd is at worktree root
3113# - prefix is calculated
3114# - git_dir is at $GIT_DIR
3115# - cwd can be outside worktree
3116
3117test_expect_success '#22.1: setup' '
ed40ec55 3118 sane_unset GIT_DIR GIT_WORK_TREE &&
fd4e1888
NTND
3119 mkdir 22 &&
3120 cd 22 &&
3121 git init &&
3122 mkdir .git/sub .git/wt .git/wt/sub &&
3123 cd ..
3124'
3125
3126test_expect_success '#22.1: GIT_DIR(rel), core.worktree=. at .git' '
3127 cat >22/.git/expected <<EOF &&
3128setup: git_dir: .
e6ec2b6a
JS
3129setup: worktree: $here/22/.git
3130setup: cwd: $here/22/.git
fd4e1888
NTND
3131setup: prefix: (null)
3132EOF
e6ec2b6a 3133 git config --file="$here/22/.git/config" core.worktree "$here/22/.git" &&
fd4e1888
NTND
3134 test_repo 22/.git .
3135'
3136
3137test_expect_success '#22.1: GIT_DIR(rel), core.worktree=.(rel) at .git' '
3138 cat >22/.git/expected <<EOF &&
3139setup: git_dir: .
e6ec2b6a
JS
3140setup: worktree: $here/22/.git
3141setup: cwd: $here/22/.git
fd4e1888
NTND
3142setup: prefix: (null)
3143EOF
e6ec2b6a 3144 git config --file="$here/22/.git/config" core.worktree . &&
fd4e1888
NTND
3145 test_repo 22/.git .
3146'
3147
3148test_expect_success '#22.1: GIT_DIR, core.worktree=. at .git' '
3149 cat >22/.git/expected <<EOF &&
e6ec2b6a
JS
3150setup: git_dir: $here/22/.git
3151setup: worktree: $here/22/.git
3152setup: cwd: $here/22/.git
fd4e1888
NTND
3153setup: prefix: (null)
3154EOF
e6ec2b6a
JS
3155 git config --file="$here/22/.git/config" core.worktree "$here/22/.git" &&
3156 test_repo 22/.git "$here/22/.git"
fd4e1888
NTND
3157'
3158
3159test_expect_success '#22.1: GIT_DIR, core.worktree=.(rel) at root' '
3160 cat >22/.git/expected <<EOF &&
e6ec2b6a
JS
3161setup: git_dir: $here/22/.git
3162setup: worktree: $here/22/.git
3163setup: cwd: $here/22/.git
fd4e1888
NTND
3164setup: prefix: (null)
3165EOF
e6ec2b6a
JS
3166 git config --file="$here/22/.git/config" core.worktree . &&
3167 test_repo 22/.git "$here/22/.git"
fd4e1888
NTND
3168'
3169
b3f66fd3 3170test_expect_success '#22.1: GIT_DIR(rel), core.worktree=. in .git/sub' '
fd4e1888 3171 cat >22/.git/sub/expected <<EOF &&
e6ec2b6a
JS
3172setup: git_dir: $here/22/.git
3173setup: worktree: $here/22/.git
3174setup: cwd: $here/22/.git
fd4e1888
NTND
3175setup: prefix: sub/
3176EOF
e6ec2b6a 3177 git config --file="$here/22/.git/config" core.worktree "$here/22/.git" &&
fd4e1888
NTND
3178 test_repo 22/.git/sub ..
3179'
3180
b3f66fd3 3181test_expect_success '#22.1: GIT_DIR(rel), core.worktree=.(rel) in .git/sub' '
fd4e1888 3182 cat >22/.git/sub/expected <<EOF &&
e6ec2b6a
JS
3183setup: git_dir: $here/22/.git
3184setup: worktree: $here/22/.git
3185setup: cwd: $here/22/.git
fd4e1888
NTND
3186setup: prefix: sub/
3187EOF
e6ec2b6a 3188 git config --file="$here/22/.git/config" core.worktree . &&
fd4e1888
NTND
3189 test_repo 22/.git/sub/ ..
3190'
3191
3192test_expect_success '#22.1: GIT_DIR, core.worktree=. in .git/sub' '
3193 cat >22/.git/sub/expected <<EOF &&
e6ec2b6a
JS
3194setup: git_dir: $here/22/.git
3195setup: worktree: $here/22/.git
3196setup: cwd: $here/22/.git
fd4e1888
NTND
3197setup: prefix: sub/
3198EOF
e6ec2b6a
JS
3199 git config --file="$here/22/.git/config" core.worktree "$here/22/.git" &&
3200 test_repo 22/.git/sub "$here/22/.git"
fd4e1888
NTND
3201'
3202
3203test_expect_success '#22.1: GIT_DIR, core.worktree=.(rel) in .git/sub' '
3204 cat >22/.git/sub/expected <<EOF &&
e6ec2b6a
JS
3205setup: git_dir: $here/22/.git
3206setup: worktree: $here/22/.git
3207setup: cwd: $here/22/.git
fd4e1888
NTND
3208setup: prefix: sub/
3209EOF
e6ec2b6a
JS
3210 git config --file="$here/22/.git/config" core.worktree . &&
3211 test_repo 22/.git/sub "$here/22/.git"
fd4e1888
NTND
3212'
3213
3214test_expect_success '#22.1: GIT_DIR(rel), core.worktree=wt at .git' '
3215 cat >22/.git/expected <<EOF &&
3216setup: git_dir: .
e6ec2b6a
JS
3217setup: worktree: $here/22/.git/wt
3218setup: cwd: $here/22/.git
fd4e1888
NTND
3219setup: prefix: (null)
3220EOF
e6ec2b6a 3221 git config --file="$here/22/.git/config" core.worktree "$here/22/.git/wt" &&
fd4e1888
NTND
3222 test_repo 22/.git .
3223'
3224
3225test_expect_success '#22.1: GIT_DIR(rel), core.worktree=wt(rel) at .git' '
3226 cat >22/.git/expected <<EOF &&
3227setup: git_dir: .
e6ec2b6a
JS
3228setup: worktree: $here/22/.git/wt
3229setup: cwd: $here/22/.git
fd4e1888
NTND
3230setup: prefix: (null)
3231EOF
e6ec2b6a 3232 git config --file="$here/22/.git/config" core.worktree wt &&
fd4e1888
NTND
3233 test_repo 22/.git .
3234'
3235
3236test_expect_success '#22.1: GIT_DIR, core.worktree=wt(rel) at .git' '
3237 cat >22/.git/expected <<EOF &&
e6ec2b6a
JS
3238setup: git_dir: $here/22/.git
3239setup: worktree: $here/22/.git/wt
3240setup: cwd: $here/22/.git
fd4e1888
NTND
3241setup: prefix: (null)
3242EOF
e6ec2b6a
JS
3243 git config --file="$here/22/.git/config" core.worktree wt &&
3244 test_repo 22/.git "$here/22/.git"
fd4e1888
NTND
3245'
3246
3247test_expect_success '#22.1: GIT_DIR, core.worktree=wt at .git' '
3248 cat >22/.git/expected <<EOF &&
e6ec2b6a
JS
3249setup: git_dir: $here/22/.git
3250setup: worktree: $here/22/.git/wt
3251setup: cwd: $here/22/.git
fd4e1888
NTND
3252setup: prefix: (null)
3253EOF
e6ec2b6a
JS
3254 git config --file="$here/22/.git/config" core.worktree "$here/22/.git/wt" &&
3255 test_repo 22/.git "$here/22/.git"
fd4e1888
NTND
3256'
3257
3258test_expect_success '#22.1: GIT_DIR(rel), core.worktree=wt in .git/sub' '
3259 cat >22/.git/sub/expected <<EOF &&
3260setup: git_dir: ..
e6ec2b6a
JS
3261setup: worktree: $here/22/.git/wt
3262setup: cwd: $here/22/.git/sub
fd4e1888
NTND
3263setup: prefix: (null)
3264EOF
e6ec2b6a 3265 git config --file="$here/22/.git/config" core.worktree "$here/22/.git/wt" &&
fd4e1888
NTND
3266 test_repo 22/.git/sub ..
3267'
3268
3269test_expect_success '#22.1: GIT_DIR(rel), core.worktree=wt(rel) in .git/sub' '
3270 cat >22/.git/sub/expected <<EOF &&
3271setup: git_dir: ..
e6ec2b6a
JS
3272setup: worktree: $here/22/.git/wt
3273setup: cwd: $here/22/.git/sub
fd4e1888
NTND
3274setup: prefix: (null)
3275EOF
e6ec2b6a 3276 git config --file="$here/22/.git/config" core.worktree wt &&
fd4e1888
NTND
3277 test_repo 22/.git/sub ..
3278'
3279
3280test_expect_success '#22.1: GIT_DIR, core.worktree=wt(rel) in .git/sub' '
3281 cat >22/.git/sub/expected <<EOF &&
e6ec2b6a
JS
3282setup: git_dir: $here/22/.git
3283setup: worktree: $here/22/.git/wt
3284setup: cwd: $here/22/.git/sub
fd4e1888
NTND
3285setup: prefix: (null)
3286EOF
e6ec2b6a
JS
3287 git config --file="$here/22/.git/config" core.worktree wt &&
3288 test_repo 22/.git/sub "$here/22/.git"
fd4e1888
NTND
3289'
3290
3291test_expect_success '#22.1: GIT_DIR, core.worktree=wt in .git/sub' '
3292 cat >22/.git/sub/expected <<EOF &&
e6ec2b6a
JS
3293setup: git_dir: $here/22/.git
3294setup: worktree: $here/22/.git/wt
3295setup: cwd: $here/22/.git/sub
fd4e1888
NTND
3296setup: prefix: (null)
3297EOF
e6ec2b6a
JS
3298 git config --file="$here/22/.git/config" core.worktree "$here/22/.git/wt" &&
3299 test_repo 22/.git/sub "$here/22/.git"
fd4e1888
NTND
3300'
3301
b3f66fd3 3302test_expect_success '#22.1: GIT_DIR(rel), core.worktree=.. at .git' '
fd4e1888 3303 cat >22/.git/expected <<EOF &&
e6ec2b6a
JS
3304setup: git_dir: $here/22/.git
3305setup: worktree: $here/22
3306setup: cwd: $here/22
fd4e1888
NTND
3307setup: prefix: .git/
3308EOF
e6ec2b6a 3309 git config --file="$here/22/.git/config" core.worktree "$here/22" &&
fd4e1888
NTND
3310 test_repo 22/.git .
3311'
3312
b3f66fd3 3313test_expect_success '#22.1: GIT_DIR(rel), core.worktree=..(rel) at .git' '
fd4e1888 3314 cat >22/.git/expected <<EOF &&
e6ec2b6a
JS
3315setup: git_dir: $here/22/.git
3316setup: worktree: $here/22
3317setup: cwd: $here/22
fd4e1888
NTND
3318setup: prefix: .git/
3319EOF
e6ec2b6a 3320 git config --file="$here/22/.git/config" core.worktree .. &&
fd4e1888
NTND
3321 test_repo 22/.git .
3322'
3323
3324test_expect_success '#22.1: GIT_DIR, core.worktree=..(rel) at .git' '
3325 cat >22/.git/expected <<EOF &&
e6ec2b6a
JS
3326setup: git_dir: $here/22/.git
3327setup: worktree: $here/22
3328setup: cwd: $here/22
fd4e1888
NTND
3329setup: prefix: .git/
3330EOF
e6ec2b6a
JS
3331 git config --file="$here/22/.git/config" core.worktree .. &&
3332 test_repo 22/.git "$here/22/.git"
fd4e1888
NTND
3333'
3334
3335test_expect_success '#22.1: GIT_DIR, core.worktree=.. at .git' '
3336 cat >22/.git/expected <<EOF &&
e6ec2b6a
JS
3337setup: git_dir: $here/22/.git
3338setup: worktree: $here/22
3339setup: cwd: $here/22
fd4e1888
NTND
3340setup: prefix: .git/
3341EOF
e6ec2b6a
JS
3342 git config --file="$here/22/.git/config" core.worktree "$here/22" &&
3343 test_repo 22/.git "$here/22/.git"
fd4e1888
NTND
3344'
3345
b3f66fd3 3346test_expect_success '#22.1: GIT_DIR(rel), core.worktree=.. in .git/sub' '
fd4e1888 3347 cat >22/.git/sub/expected <<EOF &&
e6ec2b6a
JS
3348setup: git_dir: $here/22/.git
3349setup: worktree: $here/22
3350setup: cwd: $here/22
fd4e1888
NTND
3351setup: prefix: .git/sub/
3352EOF
e6ec2b6a 3353 git config --file="$here/22/.git/config" core.worktree "$here/22" &&
fd4e1888
NTND
3354 test_repo 22/.git/sub ..
3355'
3356
b3f66fd3 3357test_expect_success '#22.1: GIT_DIR(rel), core.worktree=..(rel) in .git/sub' '
fd4e1888 3358 cat >22/.git/sub/expected <<EOF &&
e6ec2b6a
JS
3359setup: git_dir: $here/22/.git
3360setup: worktree: $here/22
3361setup: cwd: $here/22
fd4e1888
NTND
3362setup: prefix: .git/sub/
3363EOF
e6ec2b6a 3364 git config --file="$here/22/.git/config" core.worktree .. &&
fd4e1888
NTND
3365 test_repo 22/.git/sub ..
3366'
3367
3368test_expect_success '#22.1: GIT_DIR, core.worktree=..(rel) in .git/sub' '
3369 cat >22/.git/sub/expected <<EOF &&
e6ec2b6a
JS
3370setup: git_dir: $here/22/.git
3371setup: worktree: $here/22
3372setup: cwd: $here/22
fd4e1888
NTND
3373setup: prefix: .git/sub/
3374EOF
e6ec2b6a
JS
3375 git config --file="$here/22/.git/config" core.worktree .. &&
3376 test_repo 22/.git/sub "$here/22/.git"
fd4e1888
NTND
3377'
3378
3379test_expect_success '#22.1: GIT_DIR, core.worktree=.. in .git/sub' '
3380 cat >22/.git/sub/expected <<EOF &&
e6ec2b6a
JS
3381setup: git_dir: $here/22/.git
3382setup: worktree: $here/22
3383setup: cwd: $here/22
fd4e1888
NTND
3384setup: prefix: .git/sub/
3385EOF
e6ec2b6a
JS
3386 git config --file="$here/22/.git/config" core.worktree "$here/22" &&
3387 test_repo 22/.git/sub "$here/22/.git"
fd4e1888
NTND
3388'
3389
3390#
3391# case #22.2
3392#
3393############################################################
3394#
3395# Input:
3396#
3397# - GIT_WORK_TREE is not set
3398# - GIT_DIR is set
3399# - core.worktree is set
3400# - .git is a directory
3401# - core.bare is set
3402#
3403# Output:
3404#
3405# core.worktree and core.bare conflict, won't fly.
3406
3407test_expect_success '#22.2: setup' '
e6ec2b6a 3408 git config --file="$here/22/.git/config" core.bare true
fd4e1888
NTND
3409'
3410
b3f66fd3 3411test_expect_success '#22.2: at .git' '
fd4e1888
NTND
3412 (
3413 cd 22/.git &&
3414 GIT_DIR=. &&
3415 export GIT_DIR &&
3416 test_must_fail git symbolic-ref HEAD 2>result &&
3417 grep "core.bare and core.worktree do not make sense" result
3418 )
3419'
3420
b3f66fd3 3421test_expect_success '#22.2: at root' '
fd4e1888
NTND
3422 (
3423 cd 22 &&
3424 GIT_DIR=.git &&
3425 export GIT_DIR &&
3426 test_must_fail git symbolic-ref HEAD 2>result &&
3427 grep "core.bare and core.worktree do not make sense" result
3428 )
3429'
3430
5362cbfc
NTND
3431#
3432# case #23
3433#
3434############################################################
3435#
3436# Input:
3437#
3438# - GIT_WORK_TREE is set
3439# - GIT_DIR is set
3440# - core.worktree is set
3441# - .git is a directory
3442# - core.bare is set
3443#
3444# Output:
3445#
3446# core.worktree is overridden by GIT_WORK_TREE -> #19
3447
3448test_expect_success '#23: setup' '
ed40ec55 3449 sane_unset GIT_DIR GIT_WORK_TREE &&
5362cbfc
NTND
3450 mkdir 23 23/sub 23/sub/sub 23.wt 23.wt/sub 23/wt 23/wt/sub &&
3451 cd 23 &&
3452 git init &&
3453 git config core.bare true &&
3454 git config core.worktree non-existent &&
3455 cd ..
3456'
3457
3458test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
3459 cat >23/expected <<EOF &&
3460setup: git_dir: .git
e6ec2b6a
JS
3461setup: worktree: $here/23
3462setup: cwd: $here/23
5362cbfc
NTND
3463setup: prefix: (null)
3464EOF
e6ec2b6a 3465 test_repo 23 .git "$here/23"
5362cbfc
NTND
3466'
3467
3468test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
3469 cat >23/expected <<EOF &&
3470setup: git_dir: .git
e6ec2b6a
JS
3471setup: worktree: $here/23
3472setup: cwd: $here/23
5362cbfc
NTND
3473setup: prefix: (null)
3474EOF
3475 test_repo 23 .git .
3476'
3477
3478test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=root at root' '
3479 cat >23/expected <<EOF &&
e6ec2b6a
JS
3480setup: git_dir: $here/23/.git
3481setup: worktree: $here/23
3482setup: cwd: $here/23
5362cbfc
NTND
3483setup: prefix: (null)
3484EOF
e6ec2b6a 3485 test_repo 23 "$here/23/.git" "$here/23"
5362cbfc
NTND
3486'
3487
3488test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
3489 cat >23/expected <<EOF &&
e6ec2b6a
JS
3490setup: git_dir: $here/23/.git
3491setup: worktree: $here/23
3492setup: cwd: $here/23
5362cbfc
NTND
3493setup: prefix: (null)
3494EOF
e6ec2b6a 3495 test_repo 23 "$here/23/.git" .
5362cbfc
NTND
3496'
3497
3498test_expect_success '#23: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
3499 cat >23/sub/sub/expected <<EOF &&
e6ec2b6a
JS
3500setup: git_dir: $here/23/.git
3501setup: worktree: $here/23
3502setup: cwd: $here/23
5362cbfc
NTND
3503setup: prefix: sub/sub/
3504EOF
e6ec2b6a 3505 test_repo 23/sub/sub ../../.git "$here/23"
5362cbfc
NTND
3506'
3507
3508test_expect_success '#23: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
3509 cat >23/sub/sub/expected <<EOF &&
e6ec2b6a
JS
3510setup: git_dir: $here/23/.git
3511setup: worktree: $here/23
3512setup: cwd: $here/23
5362cbfc
NTND
3513setup: prefix: sub/sub/
3514EOF
3515 test_repo 23/sub/sub ../../.git ../..
3516'
3517
3518test_expect_success '#23: GIT_DIR, GIT_WORKTREE=root in subdir' '
3519 cat >23/sub/expected <<EOF &&
e6ec2b6a
JS
3520setup: git_dir: $here/23/.git
3521setup: worktree: $here/23
3522setup: cwd: $here/23
5362cbfc
NTND
3523setup: prefix: sub/
3524EOF
e6ec2b6a 3525 test_repo 23/sub "$here/23/.git" "$here/23"
5362cbfc
NTND
3526'
3527
3528test_expect_success '#23: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
3529 cat >23/sub/sub/expected <<EOF &&
e6ec2b6a
JS
3530setup: git_dir: $here/23/.git
3531setup: worktree: $here/23
3532setup: cwd: $here/23
5362cbfc
NTND
3533setup: prefix: sub/sub/
3534EOF
e6ec2b6a 3535 test_repo 23/sub/sub "$here/23/.git" ../..
5362cbfc
NTND
3536'
3537
3538test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
3539 cat >23/expected <<EOF &&
3540setup: git_dir: .git
e6ec2b6a
JS
3541setup: worktree: $here/23/wt
3542setup: cwd: $here/23
5362cbfc
NTND
3543setup: prefix: (null)
3544EOF
e6ec2b6a 3545 test_repo 23 .git "$here/23/wt"
5362cbfc
NTND
3546'
3547
3548test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
3549 cat >23/expected <<EOF &&
3550setup: git_dir: .git
e6ec2b6a
JS
3551setup: worktree: $here/23/wt
3552setup: cwd: $here/23
5362cbfc
NTND
3553setup: prefix: (null)
3554EOF
3555 test_repo 23 .git wt
3556'
3557
3558test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
3559 cat >23/expected <<EOF &&
e6ec2b6a
JS
3560setup: git_dir: $here/23/.git
3561setup: worktree: $here/23/wt
3562setup: cwd: $here/23
5362cbfc
NTND
3563setup: prefix: (null)
3564EOF
e6ec2b6a 3565 test_repo 23 "$here/23/.git" wt
5362cbfc
NTND
3566'
3567
3568test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt at root' '
3569 cat >23/expected <<EOF &&
e6ec2b6a
JS
3570setup: git_dir: $here/23/.git
3571setup: worktree: $here/23/wt
3572setup: cwd: $here/23
5362cbfc
NTND
3573setup: prefix: (null)
3574EOF
e6ec2b6a 3575 test_repo 23 "$here/23/.git" "$here/23/wt"
5362cbfc
NTND
3576'
3577
3578test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
3579 cat >23/sub/sub/expected <<EOF &&
3580setup: git_dir: ../../.git
e6ec2b6a
JS
3581setup: worktree: $here/23/wt
3582setup: cwd: $here/23/sub/sub
5362cbfc
NTND
3583setup: prefix: (null)
3584EOF
e6ec2b6a 3585 test_repo 23/sub/sub ../../.git "$here/23/wt"
5362cbfc
NTND
3586'
3587
3588test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
3589 cat >23/sub/sub/expected <<EOF &&
3590setup: git_dir: ../../.git
e6ec2b6a
JS
3591setup: worktree: $here/23/wt
3592setup: cwd: $here/23/sub/sub
5362cbfc
NTND
3593setup: prefix: (null)
3594EOF
3595 test_repo 23/sub/sub ../../.git ../../wt
3596'
3597
3598test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
3599 cat >23/sub/sub/expected <<EOF &&
e6ec2b6a
JS
3600setup: git_dir: $here/23/.git
3601setup: worktree: $here/23/wt
3602setup: cwd: $here/23/sub/sub
5362cbfc
NTND
3603setup: prefix: (null)
3604EOF
e6ec2b6a 3605 test_repo 23/sub/sub "$here/23/.git" ../../wt
5362cbfc
NTND
3606'
3607
3608test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
3609 cat >23/sub/sub/expected <<EOF &&
e6ec2b6a
JS
3610setup: git_dir: $here/23/.git
3611setup: worktree: $here/23/wt
3612setup: cwd: $here/23/sub/sub
5362cbfc
NTND
3613setup: prefix: (null)
3614EOF
e6ec2b6a 3615 test_repo 23/sub/sub "$here/23/.git" "$here/23/wt"
5362cbfc
NTND
3616'
3617
3618test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
3619 cat >23/expected <<EOF &&
e6ec2b6a
JS
3620setup: git_dir: $here/23/.git
3621setup: worktree: $here
3622setup: cwd: $here
5362cbfc
NTND
3623setup: prefix: 23/
3624EOF
e6ec2b6a 3625 test_repo 23 .git "$here"
5362cbfc
NTND
3626'
3627
3628test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
3629 cat >23/expected <<EOF &&
e6ec2b6a
JS
3630setup: git_dir: $here/23/.git
3631setup: worktree: $here
3632setup: cwd: $here
5362cbfc
NTND
3633setup: prefix: 23/
3634EOF
3635 test_repo 23 .git ..
3636'
3637
3638test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
3639 cat >23/expected <<EOF &&
e6ec2b6a
JS
3640setup: git_dir: $here/23/.git
3641setup: worktree: $here
3642setup: cwd: $here
5362cbfc
NTND
3643setup: prefix: 23/
3644EOF
e6ec2b6a 3645 test_repo 23 "$here/23/.git" ..
5362cbfc
NTND
3646'
3647
3648test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=.. at root' '
3649 cat >23/expected <<EOF &&
e6ec2b6a
JS
3650setup: git_dir: $here/23/.git
3651setup: worktree: $here
3652setup: cwd: $here
5362cbfc
NTND
3653setup: prefix: 23/
3654EOF
e6ec2b6a 3655 test_repo 23 "$here/23/.git" "$here"
5362cbfc
NTND
3656'
3657
3658test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
3659 cat >23/sub/sub/expected <<EOF &&
e6ec2b6a
JS
3660setup: git_dir: $here/23/.git
3661setup: worktree: $here
3662setup: cwd: $here
5362cbfc
NTND
3663setup: prefix: 23/sub/sub/
3664EOF
e6ec2b6a 3665 test_repo 23/sub/sub ../../.git "$here"
5362cbfc
NTND
3666'
3667
3668test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
3669 cat >23/sub/sub/expected <<EOF &&
e6ec2b6a
JS
3670setup: git_dir: $here/23/.git
3671setup: worktree: $here
3672setup: cwd: $here
5362cbfc
NTND
3673setup: prefix: 23/sub/sub/
3674EOF
3675 test_repo 23/sub/sub ../../.git ../../..
3676'
3677
3678test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
3679 cat >23/sub/sub/expected <<EOF &&
e6ec2b6a
JS
3680setup: git_dir: $here/23/.git
3681setup: worktree: $here
3682setup: cwd: $here
5362cbfc
NTND
3683setup: prefix: 23/sub/sub/
3684EOF
e6ec2b6a 3685 test_repo 23/sub/sub "$here/23/.git" ../../../
5362cbfc
NTND
3686'
3687
3688test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
3689 cat >23/sub/sub/expected <<EOF &&
e6ec2b6a
JS
3690setup: git_dir: $here/23/.git
3691setup: worktree: $here
3692setup: cwd: $here
5362cbfc
NTND
3693setup: prefix: 23/sub/sub/
3694EOF
e6ec2b6a 3695 test_repo 23/sub/sub "$here/23/.git" "$here"
5362cbfc
NTND
3696'
3697
73a509ce
NTND
3698#
3699# case #24
3700#
3701############################################################
3702#
3703# Input:
3704#
3705# - GIT_WORK_TREE is not set
3706# - GIT_DIR is not set
3707# - core.worktree is not set
3708# - .git is a file
3709# - core.bare is set
3710#
3711# Output:
3712#
3713# #16.2 except git_dir is set according to .git file
3714
3715test_expect_success '#24: setup' '
ed40ec55 3716 sane_unset GIT_DIR GIT_WORK_TREE &&
73a509ce
NTND
3717 mkdir 24 24/sub &&
3718 cd 24 &&
3719 git init &&
3720 git config core.bare true &&
3721 mv .git ../24.git &&
3722 echo gitdir: ../24.git >.git &&
3723 cd ..
3724'
3725
9951d3b3 3726test_expect_success '#24: at root' '
73a509ce 3727 cat >24/expected <<EOF &&
e6ec2b6a 3728setup: git_dir: $here/24.git
73a509ce 3729setup: worktree: (null)
e6ec2b6a 3730setup: cwd: $here/24
73a509ce
NTND
3731setup: prefix: (null)
3732EOF
3733 test_repo 24
3734'
3735
9951d3b3 3736test_expect_success '#24: in subdir' '
73a509ce 3737 cat >24/sub/expected <<EOF &&
e6ec2b6a 3738setup: git_dir: $here/24.git
73a509ce 3739setup: worktree: (null)
e6ec2b6a 3740setup: cwd: $here/24/sub
73a509ce
NTND
3741setup: prefix: (null)
3742EOF
3743 test_repo 24/sub
3744'
3745
468d6822
NTND
3746#
3747# case #25
3748#
3749############################################################
3750#
3751# Input:
3752#
3753# - GIT_WORK_TREE is set
3754# - GIT_DIR is not set
3755# - core.worktree is not set
3756# - .git is a file
3757# - core.bare is set
3758#
3759# Output:
3760#
3761# #17.2 except git_dir is set according to .git file
3762
3763test_expect_success '#25: setup' '
ed40ec55 3764 sane_unset GIT_DIR GIT_WORK_TREE &&
468d6822
NTND
3765 mkdir 25 25/sub &&
3766 cd 25 &&
3767 git init &&
3768 git config core.bare true &&
3769 GIT_WORK_TREE=non-existent &&
3770 export GIT_WORK_TREE &&
3771 mv .git ../25.git &&
3772 echo gitdir: ../25.git >.git &&
3773 cd ..
3774'
3775
9951d3b3 3776test_expect_success '#25: at root' '
468d6822 3777 cat >25/expected <<EOF &&
e6ec2b6a 3778setup: git_dir: $here/25.git
468d6822 3779setup: worktree: (null)
e6ec2b6a 3780setup: cwd: $here/25
468d6822
NTND
3781setup: prefix: (null)
3782EOF
3783 test_repo 25
3784'
3785
9951d3b3 3786test_expect_success '#25: in subdir' '
468d6822 3787 cat >25/sub/expected <<EOF &&
e6ec2b6a 3788setup: git_dir: $here/25.git
468d6822 3789setup: worktree: (null)
e6ec2b6a 3790setup: cwd: $here/25/sub
468d6822
NTND
3791setup: prefix: (null)
3792EOF
3793 test_repo 25/sub
3794'
3795
cdcef7d5
NTND
3796#
3797# case #26
3798#
3799############################################################
3800#
3801# Input:
3802#
3803# - GIT_WORK_TREE is not set
3804# - GIT_DIR is set
3805# - core.worktree is not set
3806# - .git is a file
3807# - core.bare is set
3808#
3809# Output:
3810#
3811# #18 except git_dir is set according to .git file
3812
3813test_expect_success '#26: setup' '
ed40ec55 3814 sane_unset GIT_DIR GIT_WORK_TREE &&
cdcef7d5
NTND
3815 mkdir 26 26/sub &&
3816 cd 26 &&
3817 git init &&
3818 git config core.bare true &&
3819 mv .git ../26.git &&
3820 echo gitdir: ../26.git >.git &&
3821 cd ..
3822'
3823
b3f66fd3 3824test_expect_success '#26: (rel) at root' '
cdcef7d5 3825 cat >26/expected <<EOF &&
e6ec2b6a 3826setup: git_dir: $here/26.git
cdcef7d5 3827setup: worktree: (null)
e6ec2b6a 3828setup: cwd: $here/26
cdcef7d5
NTND
3829setup: prefix: (null)
3830EOF
3831 test_repo 26 .git
3832'
3833
b3f66fd3 3834test_expect_success '#26: at root' '
cdcef7d5 3835 cat >26/expected <<EOF &&
e6ec2b6a 3836setup: git_dir: $here/26.git
cdcef7d5 3837setup: worktree: (null)
e6ec2b6a 3838setup: cwd: $here/26
cdcef7d5
NTND
3839setup: prefix: (null)
3840EOF
e6ec2b6a 3841 test_repo 26 "$here/26/.git"
cdcef7d5
NTND
3842'
3843
b3f66fd3 3844test_expect_success '#26: (rel) in subdir' '
cdcef7d5 3845 cat >26/sub/expected <<EOF &&
e6ec2b6a 3846setup: git_dir: $here/26.git
cdcef7d5 3847setup: worktree: (null)
e6ec2b6a 3848setup: cwd: $here/26/sub
cdcef7d5
NTND
3849setup: prefix: (null)
3850EOF
3851 test_repo 26/sub ../.git
3852'
3853
b3f66fd3 3854test_expect_success '#26: in subdir' '
cdcef7d5 3855 cat >26/sub/expected <<EOF &&
e6ec2b6a 3856setup: git_dir: $here/26.git
cdcef7d5 3857setup: worktree: (null)
e6ec2b6a 3858setup: cwd: $here/26/sub
cdcef7d5
NTND
3859setup: prefix: (null)
3860EOF
e6ec2b6a 3861 test_repo 26/sub "$here/26/.git"
cdcef7d5
NTND
3862'
3863
00bc13a9
NTND
3864#
3865# case #27
3866#
3867############################################################
3868#
3869# Input:
3870#
3871# - GIT_WORK_TREE is set
3872# - GIT_DIR is set
3873# - .git is a file
3874# - core.worktree is not set
3875# - core.bare is set
3876#
3877# Output:
3878#
3879# #19 except git_dir is set according to .git file
3880
3881test_expect_success '#27: setup' '
ed40ec55 3882 sane_unset GIT_DIR GIT_WORK_TREE &&
00bc13a9
NTND
3883 mkdir 27 27/sub 27/sub/sub 27.wt 27.wt/sub 27/wt 27/wt/sub &&
3884 cd 27 &&
3885 git init &&
3886 git config core.bare true &&
3887 mv .git ../27.git &&
3888 echo gitdir: ../27.git >.git &&
3889 cd ..
3890'
3891
b3f66fd3 3892test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
00bc13a9 3893 cat >27/expected <<EOF &&
e6ec2b6a
JS
3894setup: git_dir: $here/27.git
3895setup: worktree: $here/27
3896setup: cwd: $here/27
00bc13a9
NTND
3897setup: prefix: (null)
3898EOF
e6ec2b6a 3899 test_repo 27 .git "$here/27"
00bc13a9
NTND
3900'
3901
b3f66fd3 3902test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
00bc13a9 3903 cat >27/expected <<EOF &&
e6ec2b6a
JS
3904setup: git_dir: $here/27.git
3905setup: worktree: $here/27
3906setup: cwd: $here/27
00bc13a9
NTND
3907setup: prefix: (null)
3908EOF
3909 test_repo 27 .git .
3910'
3911
b3f66fd3 3912test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=root at root' '
00bc13a9 3913 cat >27/expected <<EOF &&
e6ec2b6a
JS
3914setup: git_dir: $here/27.git
3915setup: worktree: $here/27
3916setup: cwd: $here/27
00bc13a9
NTND
3917setup: prefix: (null)
3918EOF
e6ec2b6a 3919 test_repo 27 "$here/27/.git" "$here/27"
00bc13a9
NTND
3920'
3921
b3f66fd3 3922test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
00bc13a9 3923 cat >27/expected <<EOF &&
e6ec2b6a
JS
3924setup: git_dir: $here/27.git
3925setup: worktree: $here/27
3926setup: cwd: $here/27
00bc13a9
NTND
3927setup: prefix: (null)
3928EOF
e6ec2b6a 3929 test_repo 27 "$here/27/.git" .
00bc13a9
NTND
3930'
3931
b3f66fd3 3932test_expect_success '#27: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
00bc13a9 3933 cat >27/sub/sub/expected <<EOF &&
e6ec2b6a
JS
3934setup: git_dir: $here/27.git
3935setup: worktree: $here/27
3936setup: cwd: $here/27
00bc13a9
NTND
3937setup: prefix: sub/sub/
3938EOF
e6ec2b6a 3939 test_repo 27/sub/sub ../../.git "$here/27"
00bc13a9
NTND
3940'
3941
b3f66fd3 3942test_expect_success '#27: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
00bc13a9 3943 cat >27/sub/sub/expected <<EOF &&
e6ec2b6a
JS
3944setup: git_dir: $here/27.git
3945setup: worktree: $here/27
3946setup: cwd: $here/27
00bc13a9
NTND
3947setup: prefix: sub/sub/
3948EOF
3949 test_repo 27/sub/sub ../../.git ../..
3950'
3951
b3f66fd3 3952test_expect_success '#27: GIT_DIR, GIT_WORKTREE=root in subdir' '
00bc13a9 3953 cat >27/sub/expected <<EOF &&
e6ec2b6a
JS
3954setup: git_dir: $here/27.git
3955setup: worktree: $here/27
3956setup: cwd: $here/27
00bc13a9
NTND
3957setup: prefix: sub/
3958EOF
e6ec2b6a 3959 test_repo 27/sub "$here/27/.git" "$here/27"
00bc13a9
NTND
3960'
3961
b3f66fd3 3962test_expect_success '#27: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
00bc13a9 3963 cat >27/sub/sub/expected <<EOF &&
e6ec2b6a
JS
3964setup: git_dir: $here/27.git
3965setup: worktree: $here/27
3966setup: cwd: $here/27
00bc13a9
NTND
3967setup: prefix: sub/sub/
3968EOF
e6ec2b6a 3969 test_repo 27/sub/sub "$here/27/.git" ../..
00bc13a9
NTND
3970'
3971
b3f66fd3 3972test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
00bc13a9 3973 cat >27/expected <<EOF &&
e6ec2b6a
JS
3974setup: git_dir: $here/27.git
3975setup: worktree: $here/27/wt
3976setup: cwd: $here/27
00bc13a9
NTND
3977setup: prefix: (null)
3978EOF
e6ec2b6a 3979 test_repo 27 .git "$here/27/wt"
00bc13a9
NTND
3980'
3981
b3f66fd3 3982test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
00bc13a9 3983 cat >27/expected <<EOF &&
e6ec2b6a
JS
3984setup: git_dir: $here/27.git
3985setup: worktree: $here/27/wt
3986setup: cwd: $here/27
00bc13a9
NTND
3987setup: prefix: (null)
3988EOF
3989 test_repo 27 .git wt
3990'
3991
b3f66fd3 3992test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
00bc13a9 3993 cat >27/expected <<EOF &&
e6ec2b6a
JS
3994setup: git_dir: $here/27.git
3995setup: worktree: $here/27/wt
3996setup: cwd: $here/27
00bc13a9
NTND
3997setup: prefix: (null)
3998EOF
e6ec2b6a 3999 test_repo 27 "$here/27/.git" wt
00bc13a9
NTND
4000'
4001
b3f66fd3 4002test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=wt at root' '
00bc13a9 4003 cat >27/expected <<EOF &&
e6ec2b6a
JS
4004setup: git_dir: $here/27.git
4005setup: worktree: $here/27/wt
4006setup: cwd: $here/27
00bc13a9
NTND
4007setup: prefix: (null)
4008EOF
e6ec2b6a 4009 test_repo 27 "$here/27/.git" "$here/27/wt"
00bc13a9
NTND
4010'
4011
b3f66fd3 4012test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
00bc13a9 4013 cat >27/sub/sub/expected <<EOF &&
e6ec2b6a
JS
4014setup: git_dir: $here/27.git
4015setup: worktree: $here/27/wt
4016setup: cwd: $here/27/sub/sub
00bc13a9
NTND
4017setup: prefix: (null)
4018EOF
e6ec2b6a 4019 test_repo 27/sub/sub ../../.git "$here/27/wt"
00bc13a9
NTND
4020'
4021
b3f66fd3 4022test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
00bc13a9 4023 cat >27/sub/sub/expected <<EOF &&
e6ec2b6a
JS
4024setup: git_dir: $here/27.git
4025setup: worktree: $here/27/wt
4026setup: cwd: $here/27/sub/sub
00bc13a9
NTND
4027setup: prefix: (null)
4028EOF
4029 test_repo 27/sub/sub ../../.git ../../wt
4030'
4031
b3f66fd3 4032test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
00bc13a9 4033 cat >27/sub/sub/expected <<EOF &&
e6ec2b6a
JS
4034setup: git_dir: $here/27.git
4035setup: worktree: $here/27/wt
4036setup: cwd: $here/27/sub/sub
00bc13a9
NTND
4037setup: prefix: (null)
4038EOF
e6ec2b6a 4039 test_repo 27/sub/sub "$here/27/.git" ../../wt
00bc13a9
NTND
4040'
4041
b3f66fd3 4042test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
00bc13a9 4043 cat >27/sub/sub/expected <<EOF &&
e6ec2b6a
JS
4044setup: git_dir: $here/27.git
4045setup: worktree: $here/27/wt
4046setup: cwd: $here/27/sub/sub
00bc13a9
NTND
4047setup: prefix: (null)
4048EOF
e6ec2b6a 4049 test_repo 27/sub/sub "$here/27/.git" "$here/27/wt"
00bc13a9
NTND
4050'
4051
b3f66fd3 4052test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
00bc13a9 4053 cat >27/expected <<EOF &&
e6ec2b6a
JS
4054setup: git_dir: $here/27.git
4055setup: worktree: $here
4056setup: cwd: $here
00bc13a9
NTND
4057setup: prefix: 27/
4058EOF
e6ec2b6a 4059 test_repo 27 .git "$here"
00bc13a9
NTND
4060'
4061
b3f66fd3 4062test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
00bc13a9 4063 cat >27/expected <<EOF &&
e6ec2b6a
JS
4064setup: git_dir: $here/27.git
4065setup: worktree: $here
4066setup: cwd: $here
00bc13a9
NTND
4067setup: prefix: 27/
4068EOF
4069 test_repo 27 .git ..
4070'
4071
b3f66fd3 4072test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
00bc13a9 4073 cat >27/expected <<EOF &&
e6ec2b6a
JS
4074setup: git_dir: $here/27.git
4075setup: worktree: $here
4076setup: cwd: $here
00bc13a9
NTND
4077setup: prefix: 27/
4078EOF
e6ec2b6a 4079 test_repo 27 "$here/27/.git" ..
00bc13a9
NTND
4080'
4081
b3f66fd3 4082test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=.. at root' '
00bc13a9 4083 cat >27/expected <<EOF &&
e6ec2b6a
JS
4084setup: git_dir: $here/27.git
4085setup: worktree: $here
4086setup: cwd: $here
00bc13a9
NTND
4087setup: prefix: 27/
4088EOF
e6ec2b6a 4089 test_repo 27 "$here/27/.git" "$here"
00bc13a9
NTND
4090'
4091
b3f66fd3 4092test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
00bc13a9 4093 cat >27/sub/sub/expected <<EOF &&
e6ec2b6a
JS
4094setup: git_dir: $here/27.git
4095setup: worktree: $here
4096setup: cwd: $here
00bc13a9
NTND
4097setup: prefix: 27/sub/sub/
4098EOF
e6ec2b6a 4099 test_repo 27/sub/sub ../../.git "$here"
00bc13a9
NTND
4100'
4101
b3f66fd3 4102test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
00bc13a9 4103 cat >27/sub/sub/expected <<EOF &&
e6ec2b6a
JS
4104setup: git_dir: $here/27.git
4105setup: worktree: $here
4106setup: cwd: $here
00bc13a9
NTND
4107setup: prefix: 27/sub/sub/
4108EOF
4109 test_repo 27/sub/sub ../../.git ../../..
4110'
4111
b3f66fd3 4112test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
00bc13a9 4113 cat >27/sub/sub/expected <<EOF &&
e6ec2b6a
JS
4114setup: git_dir: $here/27.git
4115setup: worktree: $here
4116setup: cwd: $here
00bc13a9
NTND
4117setup: prefix: 27/sub/sub/
4118EOF
e6ec2b6a 4119 test_repo 27/sub/sub "$here/27/.git" ../../../
00bc13a9
NTND
4120'
4121
b3f66fd3 4122test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
00bc13a9 4123 cat >27/sub/sub/expected <<EOF &&
e6ec2b6a
JS
4124setup: git_dir: $here/27.git
4125setup: worktree: $here
4126setup: cwd: $here
00bc13a9
NTND
4127setup: prefix: 27/sub/sub/
4128EOF
e6ec2b6a 4129 test_repo 27/sub/sub "$here/27/.git" "$here"
00bc13a9
NTND
4130'
4131
2e8c6bab
NTND
4132#
4133# case #28
4134#
4135############################################################
4136#
4137# Input:
4138#
4139# - GIT_WORK_TREE is not set
4140# - GIT_DIR is not set
4141# - core.worktree is set
4142# - .git is a file
4143# - core.bare is set
4144#
4145# Output:
4146#
4147# core.worktree is ignored -> #24
4148
4149test_expect_success '#28: setup' '
ed40ec55 4150 sane_unset GIT_DIR GIT_WORK_TREE &&
2e8c6bab
NTND
4151 mkdir 28 28/sub &&
4152 cd 28 &&
4153 git init &&
4154 git config core.bare true &&
4155 git config core.worktree non-existent &&
4156 mv .git ../28.git &&
4157 echo gitdir: ../28.git >.git &&
4158 cd ..
4159'
4160
9951d3b3 4161test_expect_success '#28: at root' '
2e8c6bab 4162 cat >28/expected <<EOF &&
e6ec2b6a 4163setup: git_dir: $here/28.git
2e8c6bab 4164setup: worktree: (null)
e6ec2b6a 4165setup: cwd: $here/28
2e8c6bab
NTND
4166setup: prefix: (null)
4167EOF
4168 test_repo 28
4169'
4170
9951d3b3 4171test_expect_success '#28: in subdir' '
2e8c6bab 4172 cat >28/sub/expected <<EOF &&
e6ec2b6a 4173setup: git_dir: $here/28.git
2e8c6bab 4174setup: worktree: (null)
e6ec2b6a 4175setup: cwd: $here/28/sub
2e8c6bab
NTND
4176setup: prefix: (null)
4177EOF
4178 test_repo 28/sub
4179'
4180
6ab5da11
NTND
4181#
4182# case #29
4183#
4184############################################################
4185#
4186# Input:
4187#
4188# - GIT_WORK_TREE is set
4189# - GIT_DIR is not set
4190# - core.worktree is set
4191# - .git is a file
4192# - core.bare is set
4193#
4194# Output:
4195#
4196# GIT_WORK_TREE/core.worktree are ignored -> #28
4197
4198test_expect_success '#29: setup' '
ed40ec55 4199 sane_unset GIT_DIR GIT_WORK_TREE &&
6ab5da11
NTND
4200 mkdir 29 29/sub &&
4201 cd 29 &&
4202 git init &&
4203 git config core.bare true &&
4204 GIT_WORK_TREE=non-existent &&
4205 export GIT_WORK_TREE &&
4206 mv .git ../29.git &&
4207 echo gitdir: ../29.git >.git &&
4208 cd ..
4209'
4210
9951d3b3 4211test_expect_success '#29: at root' '
6ab5da11 4212 cat >29/expected <<EOF &&
e6ec2b6a 4213setup: git_dir: $here/29.git
6ab5da11 4214setup: worktree: (null)
e6ec2b6a 4215setup: cwd: $here/29
6ab5da11
NTND
4216setup: prefix: (null)
4217EOF
4218 test_repo 29
4219'
4220
9951d3b3 4221test_expect_success '#29: in subdir' '
6ab5da11 4222 cat >29/sub/expected <<EOF &&
e6ec2b6a 4223setup: git_dir: $here/29.git
6ab5da11 4224setup: worktree: (null)
e6ec2b6a 4225setup: cwd: $here/29/sub
6ab5da11
NTND
4226setup: prefix: (null)
4227EOF
4228 test_repo 29/sub
4229'
4230
a2f509e1
NTND
4231#
4232# case #30
4233#
4234############################################################
4235#
4236# Input:
4237#
4238# - GIT_WORK_TREE is not set
4239# - GIT_DIR is set
4240# - core.worktree is set
4241# - .git is a file
4242# - core.bare is set
4243#
4244# Output:
4245#
4246# core.worktree and core.bare conflict, won't fly.
4247
4248test_expect_success '#30: setup' '
ed40ec55 4249 sane_unset GIT_DIR GIT_WORK_TREE &&
a2f509e1
NTND
4250 mkdir 30 &&
4251 cd 30 &&
4252 git init &&
4253 git config core.bare true &&
4254 git config core.worktree non-existent &&
4255 mv .git ../30.git &&
4256 echo gitdir: ../30.git >.git &&
4257 cd ..
4258'
4259
b3f66fd3 4260test_expect_success '#30: at root' '
a2f509e1
NTND
4261 (
4262 cd 30 &&
4263 GIT_DIR=.git &&
4264 export GIT_DIR &&
4265 test_must_fail git symbolic-ref HEAD 2>result &&
4266 grep "core.bare and core.worktree do not make sense" result
4267 )
4268'
4269
e0d769d1
NTND
4270#
4271# case #31
4272#
4273############################################################
4274#
4275# Input:
4276#
4277# - GIT_WORK_TREE is set
4278# - GIT_DIR is set
4279# - core.worktree is set
4280# - .git is a file
4281# - core.bare is set
4282#
4283# Output:
4284#
4285# #23 except git_dir is set according to .git file
4286
4287test_expect_success '#31: setup' '
ed40ec55 4288 sane_unset GIT_DIR GIT_WORK_TREE &&
e0d769d1
NTND
4289 mkdir 31 31/sub 31/sub/sub 31.wt 31.wt/sub 31/wt 31/wt/sub &&
4290 cd 31 &&
4291 git init &&
4292 git config core.bare true &&
4293 git config core.worktree non-existent &&
4294 mv .git ../31.git &&
4295 echo gitdir: ../31.git >.git &&
4296 cd ..
4297'
4298
b3f66fd3 4299test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
e0d769d1 4300 cat >31/expected <<EOF &&
e6ec2b6a
JS
4301setup: git_dir: $here/31.git
4302setup: worktree: $here/31
4303setup: cwd: $here/31
e0d769d1
NTND
4304setup: prefix: (null)
4305EOF
e6ec2b6a 4306 test_repo 31 .git "$here/31"
e0d769d1
NTND
4307'
4308
b3f66fd3 4309test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
e0d769d1 4310 cat >31/expected <<EOF &&
e6ec2b6a
JS
4311setup: git_dir: $here/31.git
4312setup: worktree: $here/31
4313setup: cwd: $here/31
e0d769d1
NTND
4314setup: prefix: (null)
4315EOF
4316 test_repo 31 .git .
4317'
4318
b3f66fd3 4319test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=root at root' '
e0d769d1 4320 cat >31/expected <<EOF &&
e6ec2b6a
JS
4321setup: git_dir: $here/31.git
4322setup: worktree: $here/31
4323setup: cwd: $here/31
e0d769d1
NTND
4324setup: prefix: (null)
4325EOF
e6ec2b6a 4326 test_repo 31 "$here/31/.git" "$here/31"
e0d769d1
NTND
4327'
4328
b3f66fd3 4329test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
e0d769d1 4330 cat >31/expected <<EOF &&
e6ec2b6a
JS
4331setup: git_dir: $here/31.git
4332setup: worktree: $here/31
4333setup: cwd: $here/31
e0d769d1
NTND
4334setup: prefix: (null)
4335EOF
e6ec2b6a 4336 test_repo 31 "$here/31/.git" .
e0d769d1
NTND
4337'
4338
b3f66fd3 4339test_expect_success '#31: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
e0d769d1 4340 cat >31/sub/sub/expected <<EOF &&
e6ec2b6a
JS
4341setup: git_dir: $here/31.git
4342setup: worktree: $here/31
4343setup: cwd: $here/31
e0d769d1
NTND
4344setup: prefix: sub/sub/
4345EOF
e6ec2b6a 4346 test_repo 31/sub/sub ../../.git "$here/31"
e0d769d1
NTND
4347'
4348
b3f66fd3 4349test_expect_success '#31: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
e0d769d1 4350 cat >31/sub/sub/expected <<EOF &&
e6ec2b6a
JS
4351setup: git_dir: $here/31.git
4352setup: worktree: $here/31
4353setup: cwd: $here/31
e0d769d1
NTND
4354setup: prefix: sub/sub/
4355EOF
4356 test_repo 31/sub/sub ../../.git ../..
4357'
4358
b3f66fd3 4359test_expect_success '#31: GIT_DIR, GIT_WORKTREE=root in subdir' '
e0d769d1 4360 cat >31/sub/expected <<EOF &&
e6ec2b6a
JS
4361setup: git_dir: $here/31.git
4362setup: worktree: $here/31
4363setup: cwd: $here/31
e0d769d1
NTND
4364setup: prefix: sub/
4365EOF
e6ec2b6a 4366 test_repo 31/sub "$here/31/.git" "$here/31"
e0d769d1
NTND
4367'
4368
b3f66fd3 4369test_expect_success '#31: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
e0d769d1 4370 cat >31/sub/sub/expected <<EOF &&
e6ec2b6a
JS
4371setup: git_dir: $here/31.git
4372setup: worktree: $here/31
4373setup: cwd: $here/31
e0d769d1
NTND
4374setup: prefix: sub/sub/
4375EOF
e6ec2b6a 4376 test_repo 31/sub/sub "$here/31/.git" ../..
e0d769d1
NTND
4377'
4378
b3f66fd3 4379test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
e0d769d1 4380 cat >31/expected <<EOF &&
e6ec2b6a
JS
4381setup: git_dir: $here/31.git
4382setup: worktree: $here/31/wt
4383setup: cwd: $here/31
e0d769d1
NTND
4384setup: prefix: (null)
4385EOF
e6ec2b6a 4386 test_repo 31 .git "$here/31/wt"
e0d769d1
NTND
4387'
4388
b3f66fd3 4389test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
e0d769d1 4390 cat >31/expected <<EOF &&
e6ec2b6a
JS
4391setup: git_dir: $here/31.git
4392setup: worktree: $here/31/wt
4393setup: cwd: $here/31
e0d769d1
NTND
4394setup: prefix: (null)
4395EOF
4396 test_repo 31 .git wt
4397'
4398
b3f66fd3 4399test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
e0d769d1 4400 cat >31/expected <<EOF &&
e6ec2b6a
JS
4401setup: git_dir: $here/31.git
4402setup: worktree: $here/31/wt
4403setup: cwd: $here/31
e0d769d1
NTND
4404setup: prefix: (null)
4405EOF
e6ec2b6a 4406 test_repo 31 "$here/31/.git" wt
e0d769d1
NTND
4407'
4408
b3f66fd3 4409test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=wt at root' '
e0d769d1 4410 cat >31/expected <<EOF &&
e6ec2b6a
JS
4411setup: git_dir: $here/31.git
4412setup: worktree: $here/31/wt
4413setup: cwd: $here/31
e0d769d1
NTND
4414setup: prefix: (null)
4415EOF
e6ec2b6a 4416 test_repo 31 "$here/31/.git" "$here/31/wt"
e0d769d1
NTND
4417'
4418
b3f66fd3 4419test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
e0d769d1 4420 cat >31/sub/sub/expected <<EOF &&
e6ec2b6a
JS
4421setup: git_dir: $here/31.git
4422setup: worktree: $here/31/wt
4423setup: cwd: $here/31/sub/sub
e0d769d1
NTND
4424setup: prefix: (null)
4425EOF
e6ec2b6a 4426 test_repo 31/sub/sub ../../.git "$here/31/wt"
e0d769d1
NTND
4427'
4428
b3f66fd3 4429test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
e0d769d1 4430 cat >31/sub/sub/expected <<EOF &&
e6ec2b6a
JS
4431setup: git_dir: $here/31.git
4432setup: worktree: $here/31/wt
4433setup: cwd: $here/31/sub/sub
e0d769d1
NTND
4434setup: prefix: (null)
4435EOF
4436 test_repo 31/sub/sub ../../.git ../../wt
4437'
4438
b3f66fd3 4439test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
e0d769d1 4440 cat >31/sub/sub/expected <<EOF &&
e6ec2b6a
JS
4441setup: git_dir: $here/31.git
4442setup: worktree: $here/31/wt
4443setup: cwd: $here/31/sub/sub
e0d769d1
NTND
4444setup: prefix: (null)
4445EOF
e6ec2b6a 4446 test_repo 31/sub/sub "$here/31/.git" ../../wt
e0d769d1
NTND
4447'
4448
b3f66fd3 4449test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
e0d769d1 4450 cat >31/sub/sub/expected <<EOF &&
e6ec2b6a
JS
4451setup: git_dir: $here/31.git
4452setup: worktree: $here/31/wt
4453setup: cwd: $here/31/sub/sub
e0d769d1
NTND
4454setup: prefix: (null)
4455EOF
e6ec2b6a 4456 test_repo 31/sub/sub "$here/31/.git" "$here/31/wt"
e0d769d1
NTND
4457'
4458
b3f66fd3 4459test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
e0d769d1 4460 cat >31/expected <<EOF &&
e6ec2b6a
JS
4461setup: git_dir: $here/31.git
4462setup: worktree: $here
4463setup: cwd: $here
e0d769d1
NTND
4464setup: prefix: 31/
4465EOF
e6ec2b6a 4466 test_repo 31 .git "$here"
e0d769d1
NTND
4467'
4468
b3f66fd3 4469test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
e0d769d1 4470 cat >31/expected <<EOF &&
e6ec2b6a
JS
4471setup: git_dir: $here/31.git
4472setup: worktree: $here
4473setup: cwd: $here
e0d769d1
NTND
4474setup: prefix: 31/
4475EOF
4476 test_repo 31 .git ..
4477'
4478
b3f66fd3 4479test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
e0d769d1 4480 cat >31/expected <<EOF &&
e6ec2b6a
JS
4481setup: git_dir: $here/31.git
4482setup: worktree: $here
4483setup: cwd: $here
e0d769d1
NTND
4484setup: prefix: 31/
4485EOF
e6ec2b6a 4486 test_repo 31 "$here/31/.git" ..
e0d769d1
NTND
4487'
4488
b3f66fd3 4489test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=.. at root' '
e0d769d1 4490 cat >31/expected <<EOF &&
e6ec2b6a
JS
4491setup: git_dir: $here/31.git
4492setup: worktree: $here
4493setup: cwd: $here
e0d769d1
NTND
4494setup: prefix: 31/
4495EOF
e6ec2b6a 4496 test_repo 31 "$here/31/.git" "$here"
e0d769d1
NTND
4497'
4498
b3f66fd3 4499test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
e0d769d1 4500 cat >31/sub/sub/expected <<EOF &&
e6ec2b6a
JS
4501setup: git_dir: $here/31.git
4502setup: worktree: $here
4503setup: cwd: $here
e0d769d1
NTND
4504setup: prefix: 31/sub/sub/
4505EOF
e6ec2b6a 4506 test_repo 31/sub/sub ../../.git "$here"
e0d769d1
NTND
4507'
4508
b3f66fd3 4509test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
e0d769d1 4510 cat >31/sub/sub/expected <<EOF &&
e6ec2b6a
JS
4511setup: git_dir: $here/31.git
4512setup: worktree: $here
4513setup: cwd: $here
e0d769d1
NTND
4514setup: prefix: 31/sub/sub/
4515EOF
4516 test_repo 31/sub/sub ../../.git ../../..
4517'
4518
b3f66fd3 4519test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
e0d769d1 4520 cat >31/sub/sub/expected <<EOF &&
e6ec2b6a
JS
4521setup: git_dir: $here/31.git
4522setup: worktree: $here
4523setup: cwd: $here
e0d769d1
NTND
4524setup: prefix: 31/sub/sub/
4525EOF
e6ec2b6a 4526 test_repo 31/sub/sub "$here/31/.git" ../../../
e0d769d1
NTND
4527'
4528
b3f66fd3 4529test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
e0d769d1 4530 cat >31/sub/sub/expected <<EOF &&
e6ec2b6a
JS
4531setup: git_dir: $here/31.git
4532setup: worktree: $here
4533setup: cwd: $here
e0d769d1
NTND
4534setup: prefix: 31/sub/sub/
4535EOF
e6ec2b6a 4536 test_repo 31/sub/sub "$here/31/.git" "$here"
e0d769d1
NTND
4537'
4538
03a2b6ef 4539test_done