37
"
38
. ./test-lib.sh
39
40
+here=$(pwd)
41
+
42
test_repo () {
43
(
44
cd "$1" &&
59
)
60
}
61
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
-
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
-
88
-test_expect_success '#0: setup' '
89
- sane_unset GIT_DIR GIT_WORK_TREE &&
90
- mkdir 0 0/sub &&
91
- (cd 0 && git init) &&
92
- here=$(pwd)
93
-'
94
-
95
-test_expect_success '#0: at root' '
96
- cat >0/expected <<EOF &&
97
-setup: git_dir: .git
98
-setup: worktree: $here/0
99
-setup: cwd: $here/0
100
-setup: prefix: (null)
101
-EOF
102
- test_repo 0
103
-'
104
-
105
-test_expect_success '#0: in subdir' '
106
- cat >0/sub/expected <<EOF &&
107
-setup: git_dir: .git
108
-setup: worktree: $here/0
109
-setup: cwd: $here/0
110
-setup: prefix: sub/
111
-EOF
112
- test_repo 0/sub
113
-'
114
-
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
-
132
-test_expect_success '#1: setup' '
133
- sane_unset GIT_DIR GIT_WORK_TREE &&
134
- mkdir 1 1/sub 1.wt 1.wt/sub 1/wt 1/wt/sub &&
135
- cd 1 &&
136
- git init &&
137
- GIT_WORK_TREE=non-existent &&
138
- export GIT_WORK_TREE &&
139
- cd ..
140
-'
141
-
142
-test_expect_success '#1: at root' '
143
- cat >1/expected <<EOF &&
144
-setup: git_dir: .git
145
-setup: worktree: $here/1
146
-setup: cwd: $here/1
147
-setup: prefix: (null)
148
-EOF
149
- test_repo 1
150
-'
151
-
152
-test_expect_success '#1: in subdir' '
153
- cat >1/sub/expected <<EOF &&
154
-setup: git_dir: .git
155
-setup: worktree: $here/1
156
-setup: cwd: $here/1
157
-setup: prefix: sub/
158
-EOF
159
- test_repo 1/sub
160
-'
161
-
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
-
183
-test_expect_success '#2: setup' '
184
- sane_unset GIT_DIR GIT_WORK_TREE &&
185
- mkdir 2 2/sub &&
186
- cd 2 && git init && cd ..
187
-'
188
-
189
-test_expect_success '#2: at root' '
190
- cat >2/expected <<EOF &&
191
-setup: git_dir: $here/2/.git
192
-setup: worktree: $here/2
193
-setup: cwd: $here/2
194
-setup: prefix: (null)
195
-EOF
196
- test_repo 2 "$here/2/.git"
197
-'
198
-
199
-test_expect_success '#2: in subdir' '
200
- cat >2/sub/expected <<EOF &&
201
-setup: git_dir: $here/2/.git
202
-setup: worktree: $here/2/sub
203
-setup: cwd: $here/2/sub
204
-setup: prefix: (null)
205
-EOF
206
- test_repo 2/sub "$here/2/.git"
207
-'
208
-
209
-test_expect_success '#2: relative GIT_DIR at root' '
210
- cat >2/expected <<EOF &&
211
-setup: git_dir: .git
212
-setup: worktree: $here/2
213
-setup: cwd: $here/2
214
-setup: prefix: (null)
215
-EOF
216
- test_repo 2 .git
217
-'
218
-
219
-test_expect_success '#2: relative GIT_DIR in subdir' '
220
- cat >2/sub/expected <<EOF &&
221
-setup: git_dir: ../.git
222
-setup: worktree: $here/2/sub
223
-setup: cwd: $here/2/sub
224
-setup: prefix: (null)
225
-EOF
226
- test_repo 2/sub ../.git
227
-'
228
-
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
-
250
-test_expect_success '#3: setup' '
251
- sane_unset GIT_DIR GIT_WORK_TREE &&
252
- mkdir 3 3/sub 3/sub/sub 3.wt 3.wt/sub 3/wt 3/wt/sub &&
253
- cd 3 && git init && cd ..
254
-'
255
-
256
-test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
257
- cat >3/expected <<EOF &&
258
-setup: git_dir: .git
259
-setup: worktree: $here/3
260
-setup: cwd: $here/3
261
-setup: prefix: (null)
262
-EOF
263
- test_repo 3 .git "$here/3"
264
-'
265
-
266
-test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
267
- cat >3/expected <<EOF &&
268
-setup: git_dir: .git
269
-setup: worktree: $here/3
270
-setup: cwd: $here/3
271
-setup: prefix: (null)
272
-EOF
273
- test_repo 3 .git .
274
-'
275
-
276
-test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=root at root' '
277
- cat >3/expected <<EOF &&
278
-setup: git_dir: $here/3/.git
279
-setup: worktree: $here/3
280
-setup: cwd: $here/3
281
-setup: prefix: (null)
282
-EOF
283
- test_repo 3 "$here/3/.git" "$here/3"
284
-'
285
-
286
-test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
287
- cat >3/expected <<EOF &&
288
-setup: git_dir: $here/3/.git
289
-setup: worktree: $here/3
290
-setup: cwd: $here/3
291
-setup: prefix: (null)
292
-EOF
293
- test_repo 3 "$here/3/.git" .
294
-'
295
-
296
-test_expect_success '#3: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
297
- cat >3/sub/sub/expected <<EOF &&
298
-setup: git_dir: $here/3/.git
299
-setup: worktree: $here/3
300
-setup: cwd: $here/3
301
-setup: prefix: sub/sub/
302
-EOF
303
- test_repo 3/sub/sub ../../.git "$here/3"
304
-'
305
-
306
-test_expect_success '#3: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
307
- cat >3/sub/sub/expected <<EOF &&
308
-setup: git_dir: $here/3/.git
309
-setup: worktree: $here/3
310
-setup: cwd: $here/3
311
-setup: prefix: sub/sub/
312
-EOF
313
- test_repo 3/sub/sub ../../.git ../..
314
-'
315
-
316
-test_expect_success '#3: GIT_DIR, GIT_WORKTREE=root in subdir' '
317
- cat >3/sub/expected <<EOF &&
318
-setup: git_dir: $here/3/.git
319
-setup: worktree: $here/3
320
-setup: cwd: $here/3
321
-setup: prefix: sub/
322
-EOF
323
- test_repo 3/sub "$here/3/.git" "$here/3"
324
-'
325
-
326
-test_expect_success '#3: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
327
- cat >3/sub/sub/expected <<EOF &&
328
-setup: git_dir: $here/3/.git
329
-setup: worktree: $here/3
330
-setup: cwd: $here/3
331
-setup: prefix: sub/sub/
332
-EOF
333
- test_repo 3/sub/sub "$here/3/.git" ../..
334
-'
335
-
336
-test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
337
- cat >3/expected <<EOF &&
338
-setup: git_dir: .git
339
-setup: worktree: $here/3/wt
340
-setup: cwd: $here/3
341
-setup: prefix: (null)
342
-EOF
343
- test_repo 3 .git "$here/3/wt"
344
-'
345
-
346
-test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
347
- cat >3/expected <<EOF &&
348
-setup: git_dir: .git
349
-setup: worktree: $here/3/wt
350
-setup: cwd: $here/3
351
-setup: prefix: (null)
352
-EOF
353
- test_repo 3 .git wt
354
-'
355
-
356
-test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
357
- cat >3/expected <<EOF &&
358
-setup: git_dir: $here/3/.git
359
-setup: worktree: $here/3/wt
360
-setup: cwd: $here/3
361
-setup: prefix: (null)
362
-EOF
363
- test_repo 3 "$here/3/.git" wt
364
-'
365
-
366
-test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=wt at root' '
367
- cat >3/expected <<EOF &&
368
-setup: git_dir: $here/3/.git
369
-setup: worktree: $here/3/wt
370
-setup: cwd: $here/3
371
-setup: prefix: (null)
372
-EOF
373
- test_repo 3 "$here/3/.git" "$here/3/wt"
374
-'
375
-
376
-test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
377
- cat >3/sub/sub/expected <<EOF &&
378
-setup: git_dir: ../../.git
379
-setup: worktree: $here/3/wt
380
-setup: cwd: $here/3/sub/sub
381
-setup: prefix: (null)
382
-EOF
383
- test_repo 3/sub/sub ../../.git "$here/3/wt"
384
-'
385
-
386
-test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
387
- cat >3/sub/sub/expected <<EOF &&
388
-setup: git_dir: ../../.git
389
-setup: worktree: $here/3/wt
390
-setup: cwd: $here/3/sub/sub
391
-setup: prefix: (null)
392
-EOF
393
- test_repo 3/sub/sub ../../.git ../../wt
394
-'
395
-
396
-test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
397
- cat >3/sub/sub/expected <<EOF &&
398
-setup: git_dir: $here/3/.git
399
-setup: worktree: $here/3/wt
400
-setup: cwd: $here/3/sub/sub
401
-setup: prefix: (null)
402
-EOF
403
- test_repo 3/sub/sub "$here/3/.git" ../../wt
404
-'
405
-
406
-test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
407
- cat >3/sub/sub/expected <<EOF &&
408
-setup: git_dir: $here/3/.git
409
-setup: worktree: $here/3/wt
410
-setup: cwd: $here/3/sub/sub
411
-setup: prefix: (null)
412
-EOF
413
- test_repo 3/sub/sub "$here/3/.git" "$here/3/wt"
414
-'
415
-
416
-test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
417
- cat >3/expected <<EOF &&
418
-setup: git_dir: $here/3/.git
419
-setup: worktree: $here
420
-setup: cwd: $here
421
-setup: prefix: 3/
422
-EOF
423
- test_repo 3 .git "$here"
424
-'
425
-
426
-test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
427
- cat >3/expected <<EOF &&
428
-setup: git_dir: $here/3/.git
429
-setup: worktree: $here
430
-setup: cwd: $here
431
-setup: prefix: 3/
432
-EOF
433
- test_repo 3 .git ..
434
-'
435
-
436
-test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
437
- cat >3/expected <<EOF &&
438
-setup: git_dir: $here/3/.git
439
-setup: worktree: $here
440
-setup: cwd: $here
441
-setup: prefix: 3/
442
-EOF
443
- test_repo 3 "$here/3/.git" ..
444
-'
445
-
446
-test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=.. at root' '
447
- cat >3/expected <<EOF &&
448
-setup: git_dir: $here/3/.git
449
-setup: worktree: $here
450
-setup: cwd: $here
451
-setup: prefix: 3/
452
-EOF
453
- test_repo 3 "$here/3/.git" "$here"
454
-'
455
-
456
-test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
457
- cat >3/sub/sub/expected <<EOF &&
458
-setup: git_dir: $here/3/.git
459
-setup: worktree: $here
460
-setup: cwd: $here
461
-setup: prefix: 3/sub/sub/
462
-EOF
463
- test_repo 3/sub/sub ../../.git "$here"
464
-'
465
-
466
-test_expect_success '#3: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
467
- cat >3/sub/sub/expected <<EOF &&
468
-setup: git_dir: $here/3/.git
469
-setup: worktree: $here
470
-setup: cwd: $here
471
-setup: prefix: 3/sub/sub/
472
-EOF
473
- test_repo 3/sub/sub ../../.git ../../..
474
-'
475
-
476
-test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
477
- cat >3/sub/sub/expected <<EOF &&
478
-setup: git_dir: $here/3/.git
479
-setup: worktree: $here
480
-setup: cwd: $here
481
-setup: prefix: 3/sub/sub/
482
-EOF
483
- test_repo 3/sub/sub "$here/3/.git" ../../../
484
-'
485
-
486
-test_expect_success '#3: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
487
- cat >3/sub/sub/expected <<EOF &&
488
-setup: git_dir: $here/3/.git
489
-setup: worktree: $here
490
-setup: cwd: $here
491
-setup: prefix: 3/sub/sub/
492
-EOF
493
- test_repo 3/sub/sub "$here/3/.git" "$here"
494
-'
495
-
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
-
513
-test_expect_success '#4: setup' '
514
- sane_unset GIT_DIR GIT_WORK_TREE &&
515
- mkdir 4 4/sub &&
516
- cd 4 &&
517
- git init &&
518
- git config core.worktree non-existent &&
519
- cd ..
520
-'
521
-
522
-test_expect_success '#4: at root' '
523
- cat >4/expected <<EOF &&
524
-setup: git_dir: .git
525
-setup: worktree: $here/4
526
-setup: cwd: $here/4
527
-setup: prefix: (null)
528
-EOF
529
- test_repo 4
530
-'
531
-
532
-test_expect_success '#4: in subdir' '
533
- cat >4/sub/expected <<EOF &&
534
-setup: git_dir: .git
535
-setup: worktree: $here/4
536
-setup: cwd: $here/4
537
-setup: prefix: sub/
538
-EOF
539
- test_repo 4/sub
540
-'
541
-
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
62
+maybe_config () {
63
+ file=$1 var=$2 value=$3 &&
64
+ if test "$value" != unset
65
+ then
66
+ git config --file="$file" "$var" "$value"
67
+ fi
68
+}
69
559
-test_expect_success '#5: setup' '
70
+setup_repo () {
71
+ name=$1 worktreecfg=$2 gitfile=$3 barecfg=$4 &&
72
sane_unset GIT_DIR GIT_WORK_TREE &&
561
- mkdir 5 5/sub &&
562
- cd 5 &&
563
- git init &&
564
- git config core.worktree non-existent &&
565
- GIT_WORK_TREE=non-existent-too &&
566
- export GIT_WORK_TREE &&
567
- cd ..
568
-'
73
570
-test_expect_success '#5: at root' '
571
- cat >5/expected <<EOF &&
572
-setup: git_dir: .git
573
-setup: worktree: $here/5
574
-setup: cwd: $here/5
575
-setup: prefix: (null)
576
-EOF
577
- test_repo 5
578
-'
74
+ git init "$name" &&
75
+ maybe_config "$name/.git/config" core.worktree "$worktreecfg" &&
76
+ maybe_config "$name/.git/config" core.bare "$barecfg" &&
77
+ mkdir -p "$name/sub/sub" &&
78
580
-test_expect_success '#5: in subdir' '
581
- cat >5/sub/expected <<EOF &&
582
-setup: git_dir: .git
583
-setup: worktree: $here/5
584
-setup: cwd: $here/5
585
-setup: prefix: sub/
586
-EOF
587
- test_repo 5/sub
588
-'
79
+ if test "${gitfile:+set}"
80
+ then
81
+ mv "$name/.git" "$name.git" &&
82
+ echo "gitdir: ../$name.git" >"$name/.git"
83
+ fi
84
+}
85
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
86
+maybe_set () {
87
+ var=$1 value=$2 &&
88
+ if test "$value" != unset
89
+ then
90
+ eval "$var=\$value" &&
91
+ export $var
92
+ fi
93
+}
94
611
-test_expect_success '#6: setup' '
95
+setup_env () {
96
+ worktreenv=$1 gitdirenv=$2 &&
97
sane_unset GIT_DIR GIT_WORK_TREE &&
613
- mkdir 6 6/sub 6/sub/sub 6.wt 6.wt/sub 6/wt 6/wt/sub &&
614
- cd 6 && git init && cd ..
615
-'
616
-
617
-test_expect_success '#6: GIT_DIR(rel), core.worktree=.. at root' '
618
- cat >6/expected <<EOF &&
619
-setup: git_dir: .git
620
-setup: worktree: $here/6
621
-setup: cwd: $here/6
622
-setup: prefix: (null)
623
-EOF
624
- git config --file="$here/6/.git/config" core.worktree "$here/6" &&
625
- test_repo 6 .git
626
-'
627
-
628
-test_expect_success '#6: GIT_DIR(rel), core.worktree=..(rel) at root' '
629
- cat >6/expected <<EOF &&
630
-setup: git_dir: .git
631
-setup: worktree: $here/6
632
-setup: cwd: $here/6
633
-setup: prefix: (null)
634
-EOF
635
- git config --file="$here/6/.git/config" core.worktree .. &&
636
- test_repo 6 .git
637
-'
638
-
639
-test_expect_success '#6: GIT_DIR, core.worktree=.. at root' '
640
- cat >6/expected <<EOF &&
641
-setup: git_dir: $here/6/.git
642
-setup: worktree: $here/6
643
-setup: cwd: $here/6
644
-setup: prefix: (null)
645
-EOF
646
- git config --file="$here/6/.git/config" core.worktree "$here/6" &&
647
- test_repo 6 "$here/6/.git"
648
-'
649
-
650
-test_expect_success '#6: GIT_DIR, core.worktree=..(rel) at root' '
651
- cat >6/expected <<EOF &&
652
-setup: git_dir: $here/6/.git
653
-setup: worktree: $here/6
654
-setup: cwd: $here/6
655
-setup: prefix: (null)
656
-EOF
657
- git config --file="$here/6/.git/config" core.worktree .. &&
658
- test_repo 6 "$here/6/.git"
659
-'
660
-
661
-test_expect_success '#6: GIT_DIR(rel), core.worktree=.. in subdir' '
662
- cat >6/sub/sub/expected <<EOF &&
663
-setup: git_dir: $here/6/.git
664
-setup: worktree: $here/6
665
-setup: cwd: $here/6
666
-setup: prefix: sub/sub/
667
-EOF
668
- git config --file="$here/6/.git/config" core.worktree "$here/6" &&
669
- test_repo 6/sub/sub ../../.git
670
-'
671
-
672
-test_expect_success '#6: GIT_DIR(rel), core.worktree=..(rel) in subdir' '
673
- cat >6/sub/sub/expected <<EOF &&
674
-setup: git_dir: $here/6/.git
675
-setup: worktree: $here/6
676
-setup: cwd: $here/6
677
-setup: prefix: sub/sub/
678
-EOF
679
- git config --file="$here/6/.git/config" core.worktree .. &&
680
- test_repo 6/sub/sub ../../.git
681
-'
682
-
683
-test_expect_success '#6: GIT_DIR, core.worktree=.. in subdir' '
684
- cat >6/sub/expected <<EOF &&
685
-setup: git_dir: $here/6/.git
686
-setup: worktree: $here/6
687
-setup: cwd: $here/6
688
-setup: prefix: sub/
689
-EOF
690
- git config --file="$here/6/.git/config" core.worktree "$here/6" &&
691
- test_repo 6/sub "$here/6/.git"
692
-'
693
-
694
-test_expect_success '#6: GIT_DIR, core.worktree=..(rel) in subdir' '
695
- cat >6/sub/sub/expected <<EOF &&
696
-setup: git_dir: $here/6/.git
697
-setup: worktree: $here/6
698
-setup: cwd: $here/6
699
-setup: prefix: sub/sub/
700
-EOF
701
- git config --file="$here/6/.git/config" core.worktree .. &&
702
- test_repo 6/sub/sub "$here/6/.git"
703
-'
704
-
705
-test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt at root' '
706
- cat >6/expected <<EOF &&
707
-setup: git_dir: .git
708
-setup: worktree: $here/6/wt
709
-setup: cwd: $here/6
710
-setup: prefix: (null)
711
-EOF
712
- git config --file="$here/6/.git/config" core.worktree "$here/6/wt" &&
713
- test_repo 6 .git
714
-'
715
-
716
-test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt(rel) at root' '
717
- cat >6/expected <<EOF &&
718
-setup: git_dir: .git
719
-setup: worktree: $here/6/wt
720
-setup: cwd: $here/6
721
-setup: prefix: (null)
722
-EOF
723
- git config --file="$here/6/.git/config" core.worktree ../wt &&
724
- test_repo 6 .git
725
-'
726
-
727
-test_expect_success '#6: GIT_DIR, core.worktree=../wt(rel) at root' '
728
- cat >6/expected <<EOF &&
729
-setup: git_dir: $here/6/.git
730
-setup: worktree: $here/6/wt
731
-setup: cwd: $here/6
732
-setup: prefix: (null)
733
-EOF
734
- git config --file="$here/6/.git/config" core.worktree ../wt &&
735
- test_repo 6 "$here/6/.git"
736
-'
737
-
738
-test_expect_success '#6: GIT_DIR, core.worktree=../wt at root' '
739
- cat >6/expected <<EOF &&
740
-setup: git_dir: $here/6/.git
741
-setup: worktree: $here/6/wt
742
-setup: cwd: $here/6
743
-setup: prefix: (null)
744
-EOF
745
- git config --file="$here/6/.git/config" core.worktree "$here/6/wt" &&
746
- test_repo 6 "$here/6/.git"
747
-'
748
-
749
-test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt in subdir' '
750
- cat >6/sub/sub/expected <<EOF &&
751
-setup: git_dir: ../../.git
752
-setup: worktree: $here/6/wt
753
-setup: cwd: $here/6/sub/sub
754
-setup: prefix: (null)
755
-EOF
756
- git config --file="$here/6/.git/config" core.worktree "$here/6/wt" &&
757
- test_repo 6/sub/sub ../../.git
758
-'
759
-
760
-test_expect_success '#6: GIT_DIR(rel), core.worktree=../wt(rel) in subdir' '
761
- cat >6/sub/sub/expected <<EOF &&
762
-setup: git_dir: ../../.git
763
-setup: worktree: $here/6/wt
764
-setup: cwd: $here/6/sub/sub
765
-setup: prefix: (null)
766
-EOF
767
- git config --file="$here/6/.git/config" core.worktree ../wt &&
768
- test_repo 6/sub/sub ../../.git
769
-'
770
-
771
-test_expect_success '#6: GIT_DIR, core.worktree=../wt(rel) in subdir' '
772
- cat >6/sub/sub/expected <<EOF &&
773
-setup: git_dir: $here/6/.git
774
-setup: worktree: $here/6/wt
775
-setup: cwd: $here/6/sub/sub
776
-setup: prefix: (null)
777
-EOF
778
- git config --file="$here/6/.git/config" core.worktree ../wt &&
779
- test_repo 6/sub/sub "$here/6/.git"
780
-'
98
+ maybe_set GIT_DIR "$gitdirenv" &&
99
+ maybe_set GIT_WORK_TREE "$worktreeenv"
100
+}
101
782
-test_expect_success '#6: GIT_DIR, core.worktree=../wt in subdir' '
783
- cat >6/sub/sub/expected <<EOF &&
784
-setup: git_dir: $here/6/.git
785
-setup: worktree: $here/6/wt
786
-setup: cwd: $here/6/sub/sub
787
-setup: prefix: (null)
788
-EOF
789
- git config --file="$here/6/.git/config" core.worktree "$here/6/wt" &&
790
- test_repo 6/sub/sub "$here/6/.git"
791
-'
102
+expect () {
103
+ cat >"$1/expected" <<-EOF
104
+ setup: git_dir: $2
105
+ setup: worktree: $3
106
+ setup: cwd: $4
107
+ setup: prefix: $5
108
+ EOF
109
+}
110
793
-test_expect_success '#6: GIT_DIR(rel), core.worktree=../.. at root' '
794
- cat >6/expected <<EOF &&
795
-setup: git_dir: $here/6/.git
796
-setup: worktree: $here
797
-setup: cwd: $here
798
-setup: prefix: 6/
799
-EOF
800
- git config --file="$here/6/.git/config" core.worktree "$here" &&
801
- test_repo 6 .git
802
-'
111
+try_case () {
112
+ name=$1 worktreeenv=$2 gitdirenv=$3 &&
113
+ setup_env "$worktreeenv" "$gitdirenv" &&
114
+ expect "$name" "$4" "$5" "$6" "$7" &&
115
+ test_repo "$name"
116
+}
117
804
-test_expect_success '#6: GIT_DIR(rel), core.worktree=../..(rel) at root' '
805
- cat >6/expected <<EOF &&
806
-setup: git_dir: $here/6/.git
807
-setup: worktree: $here
808
-setup: cwd: $here
809
-setup: prefix: 6/
810
-EOF
811
- git config --file="$here/6/.git/config" core.worktree ../../ &&
812
- test_repo 6 .git
813
-'
118
+run_wt_tests () {
119
+ N=$1 gitfile=$2
120
+
121
+ absgit="$here/$N/.git"
122
+ dotgit=.git
123
+ dotdotgit=../../.git
124
+
125
+ if test "$gitfile"
126
+ then
127
+ absgit="$here/$N.git"
128
+ dotgit=$absgit dotdotgit=$absgit
129
+ fi
130
+
131
+ test_expect_success "#$N: explicit GIT_WORK_TREE and GIT_DIR at toplevel" '
132
+ try_case $N "$here/$N" .git \
133
+ "$dotgit" "$here/$N" "$here/$N" "(null)" &&
134
+ try_case $N . .git \
135
+ "$dotgit" "$here/$N" "$here/$N" "(null)" &&
136
+ try_case $N "$here/$N" "$here/$N/.git" \
137
+ "$absgit" "$here/$N" "$here/$N" "(null)" &&
138
+ try_case $N . "$here/$N/.git" \
139
+ "$absgit" "$here/$N" "$here/$N" "(null)"
140
+ '
141
+
142
+ test_expect_success "#$N: explicit GIT_WORK_TREE and GIT_DIR in subdir" '
143
+ try_case $N/sub/sub "$here/$N" ../../.git \
144
+ "$absgit" "$here/$N" "$here/$N" sub/sub/ &&
145
+ try_case $N/sub/sub ../.. ../../.git \
146
+ "$absgit" "$here/$N" "$here/$N" sub/sub/ &&
147
+ try_case $N/sub/sub "$here/$N" "$here/$N/.git" \
148
+ "$absgit" "$here/$N" "$here/$N" sub/sub/ &&
149
+ try_case $N/sub/sub ../.. "$here/$N/.git" \
150
+ "$absgit" "$here/$N" "$here/$N" sub/sub/
151
+ '
152
+
153
+ test_expect_success "#$N: explicit GIT_WORK_TREE from parent of worktree" '
154
+ try_case $N "$here/$N/wt" .git \
155
+ "$dotgit" "$here/$N/wt" "$here/$N" "(null)" &&
156
+ try_case $N wt .git \
157
+ "$dotgit" "$here/$N/wt" "$here/$N" "(null)" &&
158
+ try_case $N wt "$here/$N/.git" \
159
+ "$absgit" "$here/$N/wt" "$here/$N" "(null)" &&
160
+ try_case $N "$here/$N/wt" "$here/$N/.git" \
161
+ "$absgit" "$here/$N/wt" "$here/$N" "(null)"
162
+ '
163
+
164
+ test_expect_success "#$N: explicit GIT_WORK_TREE from nephew of worktree" '
165
+ try_case $N/sub/sub "$here/$N/wt" ../../.git \
166
+ "$dotdotgit" "$here/$N/wt" "$here/$N/sub/sub" "(null)" &&
167
+ try_case $N/sub/sub ../../wt ../../.git \
168
+ "$dotdotgit" "$here/$N/wt" "$here/$N/sub/sub" "(null)" &&
169
+ try_case $N/sub/sub ../../wt "$here/$N/.git" \
170
+ "$absgit" "$here/$N/wt" "$here/$N/sub/sub" "(null)" &&
171
+ try_case $N/sub/sub "$here/$N/wt" "$here/$N/.git" \
172
+ "$absgit" "$here/$N/wt" "$here/$N/sub/sub" "(null)"
173
+ '
174
+
175
+ test_expect_success "#$N: chdir_to_toplevel uses worktree, not git dir" '
176
+ try_case $N "$here" .git \
177
+ "$absgit" "$here" "$here" $N/ &&
178
+ try_case $N .. .git \
179
+ "$absgit" "$here" "$here" $N/ &&
180
+ try_case $N .. "$here/$N/.git" \
181
+ "$absgit" "$here" "$here" $N/ &&
182
+ try_case $N "$here" "$here/$N/.git" \
183
+ "$absgit" "$here" "$here" $N/
184
+ '
185
+
186
+ test_expect_success "#$N: chdir_to_toplevel uses worktree (from subdir)" '
187
+ try_case $N/sub/sub "$here" ../../.git \
188
+ "$absgit" "$here" "$here" $N/sub/sub/ &&
189
+ try_case $N/sub/sub ../../.. ../../.git \
190
+ "$absgit" "$here" "$here" $N/sub/sub/ &&
191
+ try_case $N/sub/sub ../../../ "$here/$N/.git" \
192
+ "$absgit" "$here" "$here" $N/sub/sub/ &&
193
+ try_case $N/sub/sub "$here" "$here/$N/.git" \
194
+ "$absgit" "$here" "$here" $N/sub/sub/
195
+ '
196
+}
197
815
-test_expect_success '#6: GIT_DIR, core.worktree=../..(rel) at root' '
816
- cat >6/expected <<EOF &&
817
-setup: git_dir: $here/6/.git
818
-setup: worktree: $here
819
-setup: cwd: $here
820
-setup: prefix: 6/
821
-EOF
822
- git config --file="$here/6/.git/config" core.worktree ../../ &&
823
- test_repo 6 "$here/6/.git"
824
-'
198
+# try_repo #c GIT_WORK_TREE GIT_DIR core.worktree .gitfile? core.bare \
199
+# (git dir) (work tree) (cwd) (prefix) \ <-- at toplevel
200
+# (git dir) (work tree) (cwd) (prefix) <-- from subdir
201
+try_repo () {
202
+ name=$1 worktreeenv=$2 gitdirenv=$3 &&
203
+ setup_repo "$name" "$4" "$5" "$6" &&
204
+ shift 6 &&
205
+ try_case "$name" "$worktreeenv" "$gitdirenv" \
206
+ "$1" "$2" "$3" "$4" &&
207
+ shift 4 &&
208
+ case "$gitdirenv" in
209
+ /* | ?:/* | unset) ;;
210
+ *)
211
+ gitdirenv=../$gitdirenv ;;
212
+ esac &&
213
+ try_case "$name/sub" "$worktreeenv" "$gitdirenv" \
214
+ "$1" "$2" "$3" "$4"
215
+}
216
826
-test_expect_success '#6: GIT_DIR, core.worktree=../.. at root' '
827
- cat >6/expected <<EOF &&
828
-setup: git_dir: $here/6/.git
829
-setup: worktree: $here
830
-setup: cwd: $here
831
-setup: prefix: 6/
832
-EOF
833
- git config --file="$here/6/.git/config" core.worktree "$here" &&
834
- test_repo 6 "$here/6/.git"
835
-'
217
+# Bit 0 = GIT_WORK_TREE
218
+# Bit 1 = GIT_DIR
219
+# Bit 2 = core.worktree
220
+# Bit 3 = .git is a file
221
+# Bit 4 = bare repo
222
+# Case# = encoding of the above 5 bits
223
837
-test_expect_success '#6: GIT_DIR(rel), core.worktree=../.. in subdir' '
838
- cat >6/sub/sub/expected <<EOF &&
839
-setup: git_dir: $here/6/.git
840
-setup: worktree: $here
841
-setup: cwd: $here
842
-setup: prefix: 6/sub/sub/
843
-EOF
844
- git config --file="$here/6/.git/config" core.worktree "$here" &&
845
- test_repo 6/sub/sub ../../.git
224
+test_expect_success '#0: nonbare repo, no explicit configuration' '
225
+ try_repo 0 unset unset unset "" unset \
226
+ .git "$here/0" "$here/0" "(null)" \
227
+ .git "$here/0" "$here/0" sub/
228
'
229
848
-test_expect_success '#6: GIT_DIR(rel), core.worktree=../..(rel) in subdir' '
849
- cat >6/sub/sub/expected <<EOF &&
850
-setup: git_dir: $here/6/.git
851
-setup: worktree: $here
852
-setup: cwd: $here
853
-setup: prefix: 6/sub/sub/
854
-EOF
855
- git config --file="$here/6/.git/config" core.worktree ../.. &&
856
- test_repo 6/sub/sub ../../.git
230
+test_expect_success '#1: GIT_WORK_TREE without explicit GIT_DIR is ignored' '
231
+ try_repo 1 non-existent unset unset "" unset \
232
+ .git "$here/1" "$here/1" "(null)" \
233
+ .git "$here/1" "$here/1" sub/
234
'
235
859
-test_expect_success '#6: GIT_DIR, core.worktree=../..(rel) in subdir' '
860
- cat >6/sub/sub/expected <<EOF &&
861
-setup: git_dir: $here/6/.git
862
-setup: worktree: $here
863
-setup: cwd: $here
864
-setup: prefix: 6/sub/sub/
865
-EOF
866
- git config --file="$here/6/.git/config" core.worktree ../.. &&
867
- test_repo 6/sub/sub "$here/6/.git"
236
+test_expect_success '#2: worktree defaults to cwd with explicit GIT_DIR' '
237
+ try_repo 2 unset "$here/2/.git" unset "" unset \
238
+ "$here/2/.git" "$here/2" "$here/2" "(null)" \
239
+ "$here/2/.git" "$here/2/sub" "$here/2/sub" "(null)"
240
'
241
870
-test_expect_success '#6: GIT_DIR, core.worktree=../.. in subdir' '
871
- cat >6/sub/sub/expected <<EOF &&
872
-setup: git_dir: $here/6/.git
873
-setup: worktree: $here
874
-setup: cwd: $here
875
-setup: prefix: 6/sub/sub/
876
-EOF
877
- git config --file="$here/6/.git/config" core.worktree "$here" &&
878
- test_repo 6/sub/sub "$here/6/.git"
242
+test_expect_success '#2b: relative GIT_DIR' '
243
+ try_repo 2b unset ".git" unset "" unset \
244
+ ".git" "$here/2b" "$here/2b" "(null)" \
245
+ "../.git" "$here/2b/sub" "$here/2b/sub" "(null)"
246
'
247
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
-
248
+test_expect_success '#3: setup' '
249
+ setup_repo 3 unset "" unset &&
250
+ mkdir -p 3/sub/sub 3/wt/sub
251
+'
252
+run_wt_tests 3
253
+
254
+test_expect_success '#4: core.worktree without GIT_DIR set is ignored' '
255
+ try_repo 4 unset unset non-existent "" unset \
256
+ .git "$here/4" "$here/4" "(null)" \
257
+ .git "$here/4" "$here/4" sub/
258
+'
259
+
260
+test_expect_success '#5: core.worktree + GIT_WORK_TREE is still ignored' '
261
+ # or: you cannot intimidate away the lack of GIT_DIR setting
262
+ try_repo 5 non-existent-too unset non-existent "" unset \
263
+ .git "$here/5" "$here/5" "(null)" \
264
+ .git "$here/5" "$here/5" sub/
265
+'
266
+
267
+test_expect_success '#6: setting GIT_DIR brings core.worktree to life' '
268
+ setup_repo 6 "$here/6" "" unset &&
269
+ try_case 6 unset .git \
270
+ .git "$here/6" "$here/6" "(null)" &&
271
+ try_case 6 unset "$here/6/.git" \
272
+ "$here/6/.git" "$here/6" "$here/6" "(null)" &&
273
+ try_case 6/sub/sub unset ../../.git \
274
+ "$here/6/.git" "$here/6" "$here/6" sub/sub/ &&
275
+ try_case 6/sub/sub unset "$here/6/.git" \
276
+ "$here/6/.git" "$here/6" "$here/6" sub/sub/
277
+'
278
+
279
+test_expect_success '#6b: GIT_DIR set, core.worktree relative' '
280
+ setup_repo 6b .. "" unset &&
281
+ try_case 6b unset .git \
282
+ .git "$here/6b" "$here/6b" "(null)" &&
283
+ try_case 6b unset "$here/6b/.git" \
284
+ "$here/6b/.git" "$here/6b" "$here/6b" "(null)" &&
285
+ try_case 6b/sub/sub unset ../../.git \
286
+ "$here/6b/.git" "$here/6b" "$here/6b" sub/sub/ &&
287
+ try_case 6b/sub/sub unset "$here/6b/.git" \
288
+ "$here/6b/.git" "$here/6b" "$here/6b" sub/sub/
289
+'
290
+
291
+test_expect_success '#6c: GIT_DIR set, core.worktree=../wt (absolute)' '
292
+ setup_repo 6c "$here/6c/wt" "" unset &&
293
+ mkdir -p 6c/wt/sub &&
294
+
295
+ try_case 6c unset .git \
296
+ .git "$here/6c/wt" "$here/6c" "(null)" &&
297
+ try_case 6c unset "$here/6c/.git" \
298
+ "$here/6c/.git" "$here/6c/wt" "$here/6c" "(null)" &&
299
+ try_case 6c/sub/sub unset ../../.git \
300
+ ../../.git "$here/6c/wt" "$here/6c/sub/sub" "(null)" &&
301
+ try_case 6c/sub/sub unset "$here/6c/.git" \
302
+ "$here/6c/.git" "$here/6c/wt" "$here/6c/sub/sub" "(null)"
303
+'
304
+
305
+test_expect_success '#6d: GIT_DIR set, core.worktree=../wt (relative)' '
306
+ setup_repo 6d "$here/6d/wt" "" unset &&
307
+ mkdir -p 6d/wt/sub &&
308
+
309
+ try_case 6d unset .git \
310
+ .git "$here/6d/wt" "$here/6d" "(null)" &&
311
+ try_case 6d unset "$here/6d/.git" \
312
+ "$here/6d/.git" "$here/6d/wt" "$here/6d" "(null)" &&
313
+ try_case 6d/sub/sub unset ../../.git \
314
+ ../../.git "$here/6d/wt" "$here/6d/sub/sub" "(null)" &&
315
+ try_case 6d/sub/sub unset "$here/6d/.git" \
316
+ "$here/6d/.git" "$here/6d/wt" "$here/6d/sub/sub" "(null)"
317
+'
318
+
319
+test_expect_success '#6e: GIT_DIR set, core.worktree=../.. (absolute)' '
320
+ setup_repo 6e "$here" "" unset &&
321
+ try_case 6e unset .git \
322
+ "$here/6e/.git" "$here" "$here" 6e/ &&
323
+ try_case 6e unset "$here/6e/.git" \
324
+ "$here/6e/.git" "$here" "$here" 6e/ &&
325
+ try_case 6e/sub/sub unset ../../.git \
326
+ "$here/6e/.git" "$here" "$here" 6e/sub/sub/ &&
327
+ try_case 6e/sub/sub unset "$here/6e/.git" \
328
+ "$here/6e/.git" "$here" "$here" 6e/sub/sub/
329
+'
330
+
331
+test_expect_success '#6f: GIT_DIR set, core.worktree=../.. (relative)' '
332
+ setup_repo 6f ../../ "" unset &&
333
+ try_case 6f unset .git \
334
+ "$here/6f/.git" "$here" "$here" 6f/ &&
335
+ try_case 6f unset "$here/6f/.git" \
336
+ "$here/6f/.git" "$here" "$here" 6f/ &&
337
+ try_case 6f/sub/sub unset ../../.git \
338
+ "$here/6f/.git" "$here" "$here" 6f/sub/sub/ &&
339
+ try_case 6f/sub/sub unset "$here/6f/.git" \
340
+ "$here/6f/.git" "$here" "$here" 6f/sub/sub/
341
+'
342
+
343
+# case #7: GIT_WORK_TREE overrides core.worktree.
344
test_expect_success '#7: setup' '
899
- sane_unset GIT_DIR GIT_WORK_TREE &&
900
- mkdir 7 7/sub 7/sub/sub 7.wt 7.wt/sub 7/wt 7/wt/sub &&
901
- cd 7 &&
902
- git init &&
903
- git config core.worktree non-existent &&
904
- cd ..
905
-'
906
-
907
-test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
908
- cat >7/expected <<EOF &&
909
-setup: git_dir: .git
910
-setup: worktree: $here/7
911
-setup: cwd: $here/7
912
-setup: prefix: (null)
913
-EOF
914
- test_repo 7 .git "$here/7"
915
-'
916
-
917
-test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
918
- cat >7/expected <<EOF &&
919
-setup: git_dir: .git
920
-setup: worktree: $here/7
921
-setup: cwd: $here/7
922
-setup: prefix: (null)
923
-EOF
924
- test_repo 7 .git .
925
-'
926
-
927
-test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=root at root' '
928
- cat >7/expected <<EOF &&
929
-setup: git_dir: $here/7/.git
930
-setup: worktree: $here/7
931
-setup: cwd: $here/7
932
-setup: prefix: (null)
933
-EOF
934
- test_repo 7 "$here/7/.git" "$here/7"
935
-'
936
-
937
-test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
938
- cat >7/expected <<EOF &&
939
-setup: git_dir: $here/7/.git
940
-setup: worktree: $here/7
941
-setup: cwd: $here/7
942
-setup: prefix: (null)
943
-EOF
944
- test_repo 7 "$here/7/.git" .
945
-'
946
-
947
-test_expect_success '#7: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
948
- cat >7/sub/sub/expected <<EOF &&
949
-setup: git_dir: $here/7/.git
950
-setup: worktree: $here/7
951
-setup: cwd: $here/7
952
-setup: prefix: sub/sub/
953
-EOF
954
- test_repo 7/sub/sub ../../.git "$here/7"
955
-'
956
-
957
-test_expect_success '#7: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
958
- cat >7/sub/sub/expected <<EOF &&
959
-setup: git_dir: $here/7/.git
960
-setup: worktree: $here/7
961
-setup: cwd: $here/7
962
-setup: prefix: sub/sub/
963
-EOF
964
- test_repo 7/sub/sub ../../.git ../..
965
-'
966
-
967
-test_expect_success '#7: GIT_DIR, GIT_WORKTREE=root in subdir' '
968
- cat >7/sub/expected <<EOF &&
969
-setup: git_dir: $here/7/.git
970
-setup: worktree: $here/7
971
-setup: cwd: $here/7
972
-setup: prefix: sub/
973
-EOF
974
- test_repo 7/sub "$here/7/.git" "$here/7"
975
-'
976
-
977
-test_expect_success '#7: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
978
- cat >7/sub/sub/expected <<EOF &&
979
-setup: git_dir: $here/7/.git
980
-setup: worktree: $here/7
981
-setup: cwd: $here/7
982
-setup: prefix: sub/sub/
983
-EOF
984
- test_repo 7/sub/sub "$here/7/.git" ../..
985
-'
986
-
987
-test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
988
- cat >7/expected <<EOF &&
989
-setup: git_dir: .git
990
-setup: worktree: $here/7/wt
991
-setup: cwd: $here/7
992
-setup: prefix: (null)
993
-EOF
994
- test_repo 7 .git "$here/7/wt"
995
-'
996
-
997
-test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
998
- cat >7/expected <<EOF &&
999
-setup: git_dir: .git
1000
-setup: worktree: $here/7/wt
1001
-setup: cwd: $here/7
1002
-setup: prefix: (null)
1003
-EOF
1004
- test_repo 7 .git wt
1005
-'
1006
-
1007
-test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
1008
- cat >7/expected <<EOF &&
1009
-setup: git_dir: $here/7/.git
1010
-setup: worktree: $here/7/wt
1011
-setup: cwd: $here/7
1012
-setup: prefix: (null)
1013
-EOF
1014
- test_repo 7 "$here/7/.git" wt
1015
-'
1016
-
1017
-test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=wt at root' '
1018
- cat >7/expected <<EOF &&
1019
-setup: git_dir: $here/7/.git
1020
-setup: worktree: $here/7/wt
1021
-setup: cwd: $here/7
1022
-setup: prefix: (null)
1023
-EOF
1024
- test_repo 7 "$here/7/.git" "$here/7/wt"
1025
-'
1026
-
1027
-test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
1028
- cat >7/sub/sub/expected <<EOF &&
1029
-setup: git_dir: ../../.git
1030
-setup: worktree: $here/7/wt
1031
-setup: cwd: $here/7/sub/sub
1032
-setup: prefix: (null)
1033
-EOF
1034
- test_repo 7/sub/sub ../../.git "$here/7/wt"
1035
-'
1036
-
1037
-test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
1038
- cat >7/sub/sub/expected <<EOF &&
1039
-setup: git_dir: ../../.git
1040
-setup: worktree: $here/7/wt
1041
-setup: cwd: $here/7/sub/sub
1042
-setup: prefix: (null)
1043
-EOF
1044
- test_repo 7/sub/sub ../../.git ../../wt
1045
-'
1046
-
1047
-test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
1048
- cat >7/sub/sub/expected <<EOF &&
1049
-setup: git_dir: $here/7/.git
1050
-setup: worktree: $here/7/wt
1051
-setup: cwd: $here/7/sub/sub
1052
-setup: prefix: (null)
1053
-EOF
1054
- test_repo 7/sub/sub "$here/7/.git" ../../wt
1055
-'
1056
-
1057
-test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
1058
- cat >7/sub/sub/expected <<EOF &&
1059
-setup: git_dir: $here/7/.git
1060
-setup: worktree: $here/7/wt
1061
-setup: cwd: $here/7/sub/sub
1062
-setup: prefix: (null)
1063
-EOF
1064
- test_repo 7/sub/sub "$here/7/.git" "$here/7/wt"
1065
-'
1066
-
1067
-test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
1068
- cat >7/expected <<EOF &&
1069
-setup: git_dir: $here/7/.git
1070
-setup: worktree: $here
1071
-setup: cwd: $here
1072
-setup: prefix: 7/
1073
-EOF
1074
- test_repo 7 .git "$here"
1075
-'
1076
-
1077
-test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
1078
- cat >7/expected <<EOF &&
1079
-setup: git_dir: $here/7/.git
1080
-setup: worktree: $here
1081
-setup: cwd: $here
1082
-setup: prefix: 7/
1083
-EOF
1084
- test_repo 7 .git ..
1085
-'
1086
-
1087
-test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
1088
- cat >7/expected <<EOF &&
1089
-setup: git_dir: $here/7/.git
1090
-setup: worktree: $here
1091
-setup: cwd: $here
1092
-setup: prefix: 7/
1093
-EOF
1094
- test_repo 7 "$here/7/.git" ..
1095
-'
1096
-
1097
-test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=.. at root' '
1098
- cat >7/expected <<EOF &&
1099
-setup: git_dir: $here/7/.git
1100
-setup: worktree: $here
1101
-setup: cwd: $here
1102
-setup: prefix: 7/
1103
-EOF
1104
- test_repo 7 "$here/7/.git" "$here"
1105
-'
1106
-
1107
-test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
1108
- cat >7/sub/sub/expected <<EOF &&
1109
-setup: git_dir: $here/7/.git
1110
-setup: worktree: $here
1111
-setup: cwd: $here
1112
-setup: prefix: 7/sub/sub/
1113
-EOF
1114
- test_repo 7/sub/sub ../../.git "$here"
1115
-'
1116
-
1117
-test_expect_success '#7: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
1118
- cat >7/sub/sub/expected <<EOF &&
1119
-setup: git_dir: $here/7/.git
1120
-setup: worktree: $here
1121
-setup: cwd: $here
1122
-setup: prefix: 7/sub/sub/
1123
-EOF
1124
- test_repo 7/sub/sub ../../.git ../../..
1125
-'
1126
-
1127
-test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
1128
- cat >7/sub/sub/expected <<EOF &&
1129
-setup: git_dir: $here/7/.git
1130
-setup: worktree: $here
1131
-setup: cwd: $here
1132
-setup: prefix: 7/sub/sub/
1133
-EOF
1134
- test_repo 7/sub/sub "$here/7/.git" ../../../
1135
-'
1136
-
1137
-test_expect_success '#7: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
1138
- cat >7/sub/sub/expected <<EOF &&
1139
-setup: git_dir: $here/7/.git
1140
-setup: worktree: $here
1141
-setup: cwd: $here
1142
-setup: prefix: 7/sub/sub/
1143
-EOF
1144
- test_repo 7/sub/sub "$here/7/.git" "$here"
1145
-'
1146
-
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
-
1164
-test_expect_success '#8: setup' '
1165
- sane_unset GIT_DIR GIT_WORK_TREE &&
1166
- mkdir 8 8/sub &&
1167
- cd 8 &&
1168
- git init &&
1169
- mv .git ../8.git &&
1170
- echo gitdir: ../8.git >.git &&
1171
- cd ..
1172
-'
1173
-
1174
-test_expect_success '#8: at root' '
1175
- cat >8/expected <<EOF &&
1176
-setup: git_dir: $here/8.git
1177
-setup: worktree: $here/8
1178
-setup: cwd: $here/8
1179
-setup: prefix: (null)
1180
-EOF
1181
- test_repo 8
1182
-'
1183
-
1184
-test_expect_success '#8: in subdir' '
1185
- cat >8/sub/expected <<EOF &&
1186
-setup: git_dir: $here/8.git
1187
-setup: worktree: $here/8
1188
-setup: cwd: $here/8
1189
-setup: prefix: sub/
1190
-EOF
1191
- test_repo 8/sub
1192
-'
1193
-
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
-
1211
-test_expect_success '#9: setup' '
1212
- sane_unset GIT_DIR GIT_WORK_TREE &&
1213
- mkdir 9 9/sub 9.wt 9.wt/sub 9/wt 9/wt/sub &&
1214
- cd 9 &&
1215
- git init &&
1216
- mv .git ../9.git &&
1217
- echo gitdir: ../9.git >.git &&
1218
- GIT_WORK_TREE=non-existent &&
1219
- export GIT_WORK_TREE &&
1220
- cd ..
1221
-'
1222
-
1223
-test_expect_success '#9: at root' '
1224
- cat >9/expected <<EOF &&
1225
-setup: git_dir: $here/9.git
1226
-setup: worktree: $here/9
1227
-setup: cwd: $here/9
1228
-setup: prefix: (null)
1229
-EOF
1230
- test_repo 9
1231
-'
1232
-
1233
-test_expect_success '#9: in subdir' '
1234
- cat >9/sub/expected <<EOF &&
1235
-setup: git_dir: $here/9.git
1236
-setup: worktree: $here/9
1237
-setup: cwd: $here/9
1238
-setup: prefix: sub/
1239
-EOF
1240
- test_repo 9/sub
1241
-'
1242
-
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
-
1260
-test_expect_success '#10: setup' '
1261
- sane_unset GIT_DIR GIT_WORK_TREE &&
1262
- mkdir 10 10/sub &&
1263
- cd 10 &&
1264
- git init &&
1265
- mv .git ../10.git &&
1266
- echo gitdir: ../10.git >.git &&
1267
- cd ..
345
+ setup_repo 7 non-existent "" unset &&
346
+ mkdir -p 7/sub/sub 7/wt/sub
347
'
348
+run_wt_tests 7
349
1270
-test_expect_success '#10: at root' '
1271
- cat >10/expected <<EOF &&
1272
-setup: git_dir: $here/10.git
1273
-setup: worktree: $here/10
1274
-setup: cwd: $here/10
1275
-setup: prefix: (null)
1276
-EOF
1277
- test_repo 10 "$here/10/.git"
350
+test_expect_success '#8: gitfile, easy case' '
351
+ try_repo 8 unset unset unset gitfile unset \
352
+ "$here/8.git" "$here/8" "$here/8" "(null)" \
353
+ "$here/8.git" "$here/8" "$here/8" sub/
354
'
355
1280
-test_expect_success '#10: in subdir' '
1281
- cat >10/sub/expected <<EOF &&
1282
-setup: git_dir: $here/10.git
1283
-setup: worktree: $here/10/sub
1284
-setup: cwd: $here/10/sub
1285
-setup: prefix: (null)
1286
-EOF
1287
- test_repo 10/sub "$here/10/.git"
356
+test_expect_success '#9: GIT_WORK_TREE ignored even with gitfile' '
357
+ try_repo 9 non-existent unset unset gitfile unset \
358
+ "$here/9.git" "$here/9" "$here/9" "(null)" \
359
+ "$here/9.git" "$here/9" "$here/9" sub/
360
'
361
1290
-test_expect_success '#10: relative GIT_DIR at root' '
1291
- cat >10/expected <<EOF &&
1292
-setup: git_dir: $here/10.git
1293
-setup: worktree: $here/10
1294
-setup: cwd: $here/10
1295
-setup: prefix: (null)
1296
-EOF
1297
- test_repo 10 .git
362
+test_expect_success '#10: GIT_DIR can point to gitfile' '
363
+ try_repo 10 unset "$here/10/.git" unset gitfile unset \
364
+ "$here/10.git" "$here/10" "$here/10" "(null)" \
365
+ "$here/10.git" "$here/10/sub" "$here/10/sub" "(null)"
366
'
367
1300
-test_expect_success '#10: relative GIT_DIR in subdir' '
1301
- cat >10/sub/expected <<EOF &&
1302
-setup: git_dir: $here/10.git
1303
-setup: worktree: $here/10/sub
1304
-setup: cwd: $here/10/sub
1305
-setup: prefix: (null)
1306
-EOF
1307
- test_repo 10/sub ../.git
368
+test_expect_success '#10b: relative GIT_DIR can point to gitfile' '
369
+ try_repo 10b unset .git unset gitfile unset \
370
+ "$here/10b.git" "$here/10b" "$here/10b" "(null)" \
371
+ "$here/10b.git" "$here/10b/sub" "$here/10b/sub" "(null)"
372
'
373
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
-
374
+# case #11: GIT_WORK_TREE works, gitfile case.
375
test_expect_success '#11: setup' '
1328
- sane_unset GIT_DIR GIT_WORK_TREE &&
1329
- mkdir 11 11/sub 11/sub/sub 11.wt 11.wt/sub 11/wt 11/wt/sub &&
1330
- cd 11 &&
1331
- git init &&
1332
- mv .git ../11.git &&
1333
- echo gitdir: ../11.git >.git &&
1334
- cd ..
1335
-'
1336
-
1337
-test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
1338
- cat >11/expected <<EOF &&
1339
-setup: git_dir: $here/11.git
1340
-setup: worktree: $here/11
1341
-setup: cwd: $here/11
1342
-setup: prefix: (null)
1343
-EOF
1344
- test_repo 11 .git "$here/11"
1345
-'
1346
-
1347
-test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
1348
- cat >11/expected <<EOF &&
1349
-setup: git_dir: $here/11.git
1350
-setup: worktree: $here/11
1351
-setup: cwd: $here/11
1352
-setup: prefix: (null)
1353
-EOF
1354
- test_repo 11 .git .
1355
-'
1356
-
1357
-test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=root at root' '
1358
- cat >11/expected <<EOF &&
1359
-setup: git_dir: $here/11.git
1360
-setup: worktree: $here/11
1361
-setup: cwd: $here/11
1362
-setup: prefix: (null)
1363
-EOF
1364
- test_repo 11 "$here/11/.git" "$here/11"
1365
-'
1366
-
1367
-test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
1368
- cat >11/expected <<EOF &&
1369
-setup: git_dir: $here/11.git
1370
-setup: worktree: $here/11
1371
-setup: cwd: $here/11
1372
-setup: prefix: (null)
1373
-EOF
1374
- test_repo 11 "$here/11/.git" .
1375
-'
1376
-
1377
-test_expect_success '#11: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
1378
- cat >11/sub/sub/expected <<EOF &&
1379
-setup: git_dir: $here/11.git
1380
-setup: worktree: $here/11
1381
-setup: cwd: $here/11
1382
-setup: prefix: sub/sub/
1383
-EOF
1384
- test_repo 11/sub/sub ../../.git "$here/11"
1385
-'
1386
-
1387
-test_expect_success '#11: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
1388
- cat >11/sub/sub/expected <<EOF &&
1389
-setup: git_dir: $here/11.git
1390
-setup: worktree: $here/11
1391
-setup: cwd: $here/11
1392
-setup: prefix: sub/sub/
1393
-EOF
1394
- test_repo 11/sub/sub ../../.git ../..
1395
-'
1396
-
1397
-test_expect_success '#11: GIT_DIR, GIT_WORKTREE=root in subdir' '
1398
- cat >11/sub/expected <<EOF &&
1399
-setup: git_dir: $here/11.git
1400
-setup: worktree: $here/11
1401
-setup: cwd: $here/11
1402
-setup: prefix: sub/
1403
-EOF
1404
- test_repo 11/sub "$here/11/.git" "$here/11"
1405
-'
1406
-
1407
-test_expect_success '#11: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
1408
- cat >11/sub/sub/expected <<EOF &&
1409
-setup: git_dir: $here/11.git
1410
-setup: worktree: $here/11
1411
-setup: cwd: $here/11
1412
-setup: prefix: sub/sub/
1413
-EOF
1414
- test_repo 11/sub/sub "$here/11/.git" ../..
376
+ setup_repo 11 unset gitfile unset &&
377
+ mkdir -p 11/sub/sub 11/wt/sub
378
+'
379
+run_wt_tests 11 gitfile
380
+
381
+test_expect_success '#12: core.worktree with gitfile is still ignored' '
382
+ try_repo 12 unset unset non-existent gitfile unset \
383
+ "$here/12.git" "$here/12" "$here/12" "(null)" \
384
+ "$here/12.git" "$here/12" "$here/12" sub/
385
+'
386
+
387
+test_expect_success '#13: core.worktree+GIT_WORK_TREE ignored (with gitfile)' '
388
+ # or: you cannot intimidate away the lack of GIT_DIR setting
389
+ try_repo 13 non-existent-too unset non-existent gitfile unset \
390
+ "$here/13.git" "$here/13" "$here/13" "(null)" \
391
+ "$here/13.git" "$here/13" "$here/13" sub/
392
+'
393
+
394
+# case #14.
395
+# If this were more table-driven, it could share code with case #6.
396
+
397
+test_expect_success '#14: core.worktree with GIT_DIR pointing to gitfile' '
398
+ setup_repo 14 "$here/14" gitfile unset &&
399
+ try_case 14 unset .git \
400
+ "$here/14.git" "$here/14" "$here/14" "(null)" &&
401
+ try_case 14 unset "$here/14/.git" \
402
+ "$here/14.git" "$here/14" "$here/14" "(null)" &&
403
+ try_case 14/sub/sub unset ../../.git \
404
+ "$here/14.git" "$here/14" "$here/14" sub/sub/ &&
405
+ try_case 14/sub/sub unset "$here/14/.git" \
406
+ "$here/14.git" "$here/14" "$here/14" sub/sub/ &&
407
+
408
+ setup_repo 14c "$here/14c/wt" gitfile unset &&
409
+ mkdir -p 14c/wt/sub &&
410
+
411
+ try_case 14c unset .git \
412
+ "$here/14c.git" "$here/14c/wt" "$here/14c" "(null)" &&
413
+ try_case 14c unset "$here/14c/.git" \
414
+ "$here/14c.git" "$here/14c/wt" "$here/14c" "(null)" &&
415
+ try_case 14c/sub/sub unset ../../.git \
416
+ "$here/14c.git" "$here/14c/wt" "$here/14c/sub/sub" "(null)" &&
417
+ try_case 14c/sub/sub unset "$here/14c/.git" \
418
+ "$here/14c.git" "$here/14c/wt" "$here/14c/sub/sub" "(null)" &&
419
+
420
+ setup_repo 14d "$here/14d/wt" gitfile unset &&
421
+ mkdir -p 14d/wt/sub &&
422
+
423
+ try_case 14d unset .git \
424
+ "$here/14d.git" "$here/14d/wt" "$here/14d" "(null)" &&
425
+ try_case 14d unset "$here/14d/.git" \
426
+ "$here/14d.git" "$here/14d/wt" "$here/14d" "(null)" &&
427
+ try_case 14d/sub/sub unset ../../.git \
428
+ "$here/14d.git" "$here/14d/wt" "$here/14d/sub/sub" "(null)" &&
429
+ try_case 14d/sub/sub unset "$here/14d/.git" \
430
+ "$here/14d.git" "$here/14d/wt" "$here/14d/sub/sub" "(null)" &&
431
+
432
+ setup_repo 14e "$here" gitfile unset &&
433
+ try_case 14e unset .git \
434
+ "$here/14e.git" "$here" "$here" 14e/ &&
435
+ try_case 14e unset "$here/14e/.git" \
436
+ "$here/14e.git" "$here" "$here" 14e/ &&
437
+ try_case 14e/sub/sub unset ../../.git \
438
+ "$here/14e.git" "$here" "$here" 14e/sub/sub/ &&
439
+ try_case 14e/sub/sub unset "$here/14e/.git" \
440
+ "$here/14e.git" "$here" "$here" 14e/sub/sub/
441
+'
442
+
443
+test_expect_success '#14b: core.worktree is relative to actual git dir' '
444
+ setup_repo 14b ../14b gitfile unset &&
445
+ try_case 14b unset .git \
446
+ "$here/14b.git" "$here/14b" "$here/14b" "(null)" &&
447
+ try_case 14b unset "$here/14b/.git" \
448
+ "$here/14b.git" "$here/14b" "$here/14b" "(null)" &&
449
+ try_case 14b/sub/sub unset ../../.git \
450
+ "$here/14b.git" "$here/14b" "$here/14b" sub/sub/ &&
451
+ try_case 14b/sub/sub unset "$here/14b/.git" \
452
+ "$here/14b.git" "$here/14b" "$here/14b" sub/sub/ &&
453
+
454
+ setup_repo 14f ../ gitfile unset &&
455
+ try_case 14f unset .git \
456
+ "$here/14f.git" "$here" "$here" 14f/ &&
457
+ try_case 14f unset "$here/14f/.git" \
458
+ "$here/14f.git" "$here" "$here" 14f/ &&
459
+ try_case 14f/sub/sub unset ../../.git \
460
+ "$here/14f.git" "$here" "$here" 14f/sub/sub/ &&
461
+ try_case 14f/sub/sub unset "$here/14f/.git" \
462
+ "$here/14f.git" "$here" "$here" 14f/sub/sub/
463
+'
464
+
465
+# case #15: GIT_WORK_TREE overrides core.worktree (gitfile case).
466
+test_expect_success '#15: setup' '
467
+ setup_repo 15 non-existent gitfile unset &&
468
+ mkdir -p 15/sub/sub 15/wt/sub
469
'
470
+run_wt_tests 15 gitfile
471
1417
-test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
1418
- cat >11/expected <<EOF &&
1419
-setup: git_dir: $here/11.git
1420
-setup: worktree: $here/11/wt
1421
-setup: cwd: $here/11
1422
-setup: prefix: (null)
1423
-EOF
1424
- test_repo 11 .git "$here/11/wt"
1425
-'
472
+test_expect_success '#16a: implicitly bare repo (cwd inside .git dir)' '
473
+ setup_repo 16a unset "" unset &&
474
+ mkdir -p 16a/.git/wt/sub &&
475
1427
-test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
1428
- cat >11/expected <<EOF &&
1429
-setup: git_dir: $here/11.git
1430
-setup: worktree: $here/11/wt
1431
-setup: cwd: $here/11
1432
-setup: prefix: (null)
1433
-EOF
1434
- test_repo 11 .git wt
476
+ try_case 16a/.git unset unset \
477
+ . "(null)" "$here/16a/.git" "(null)" &&
478
+ try_case 16a/.git/wt unset unset \
479
+ "$here/16a/.git" "(null)" "$here/16a/.git/wt" "(null)" &&
480
+ try_case 16a/.git/wt/sub unset unset \
481
+ "$here/16a/.git" "(null)" "$here/16a/.git/wt/sub" "(null)"
482
'
483
1437
-test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
1438
- cat >11/expected <<EOF &&
1439
-setup: git_dir: $here/11.git
1440
-setup: worktree: $here/11/wt
1441
-setup: cwd: $here/11
1442
-setup: prefix: (null)
1443
-EOF
1444
- test_repo 11 "$here/11/.git" wt
1445
-'
484
+test_expect_success '#16b: bare .git (cwd inside .git dir)' '
485
+ setup_repo 16b unset "" true &&
486
+ mkdir -p 16b/.git/wt/sub &&
487
1447
-test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=wt at root' '
1448
- cat >11/expected <<EOF &&
1449
-setup: git_dir: $here/11.git
1450
-setup: worktree: $here/11/wt
1451
-setup: cwd: $here/11
1452
-setup: prefix: (null)
1453
-EOF
1454
- test_repo 11 "$here/11/.git" "$here/11/wt"
488
+ try_case 16b/.git unset unset \
489
+ . "(null)" "$here/16b/.git" "(null)" &&
490
+ try_case 16b/.git/wt unset unset \
491
+ "$here/16b/.git" "(null)" "$here/16b/.git/wt" "(null)" &&
492
+ try_case 16b/.git/wt/sub unset unset \
493
+ "$here/16b/.git" "(null)" "$here/16b/.git/wt/sub" "(null)"
494
'
495
1457
-test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
1458
- cat >11/sub/sub/expected <<EOF &&
1459
-setup: git_dir: $here/11.git
1460
-setup: worktree: $here/11/wt
1461
-setup: cwd: $here/11/sub/sub
1462
-setup: prefix: (null)
1463
-EOF
1464
- test_repo 11/sub/sub ../../.git "$here/11/wt"
496
+test_expect_success '#16c: bare .git has no worktree' '
497
+ try_repo 16c unset unset unset "" true \
498
+ .git "(null)" "$here/16c" "(null)" \
499
+ "$here/16c/.git" "(null)" "$here/16c/sub" "(null)"
500
'
501
1467
-test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
1468
- cat >11/sub/sub/expected <<EOF &&
1469
-setup: git_dir: $here/11.git
1470
-setup: worktree: $here/11/wt
1471
-setup: cwd: $here/11/sub/sub
1472
-setup: prefix: (null)
1473
-EOF
1474
- test_repo 11/sub/sub ../../.git ../../wt
1475
-'
502
+test_expect_success '#17: GIT_WORK_TREE without explicit GIT_DIR is ignored (bare case)' '
503
+ # Just like #16.
504
+ setup_repo 17a unset "" true &&
505
+ setup_repo 17b unset "" true &&
506
+ mkdir -p 17a/.git/wt/sub &&
507
+ mkdir -p 17b/.git/wt/sub &&
508
1477
-test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
1478
- cat >11/sub/sub/expected <<EOF &&
1479
-setup: git_dir: $here/11.git
1480
-setup: worktree: $here/11/wt
1481
-setup: cwd: $here/11/sub/sub
1482
-setup: prefix: (null)
1483
-EOF
1484
- test_repo 11/sub/sub "$here/11/.git" ../../wt
1485
-'
509
+ try_case 17a/.git non-existent unset \
510
+ . "(null)" "$here/17a/.git" "(null)" &&
511
+ try_case 17a/.git/wt non-existent unset \
512
+ "$here/17a/.git" "(null)" "$here/17a/.git/wt" "(null)" &&
513
+ try_case 17a/.git/wt/sub non-existent unset \
514
+ "$here/17a/.git" "(null)" "$here/17a/.git/wt/sub" "(null)" &&
515
1487
-test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
1488
- cat >11/sub/sub/expected <<EOF &&
1489
-setup: git_dir: $here/11.git
1490
-setup: worktree: $here/11/wt
1491
-setup: cwd: $here/11/sub/sub
1492
-setup: prefix: (null)
1493
-EOF
1494
- test_repo 11/sub/sub "$here/11/.git" "$here/11/wt"
1495
-'
516
+ try_case 17b/.git non-existent unset \
517
+ . "(null)" "$here/17b/.git" "(null)" &&
518
+ try_case 17b/.git/wt non-existent unset \
519
+ "$here/17b/.git" "(null)" "$here/17b/.git/wt" "(null)" &&
520
+ try_case 17b/.git/wt/sub non-existent unset \
521
+ "$here/17b/.git" "(null)" "$here/17b/.git/wt/sub" "(null)" &&
522
1497
-test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
1498
- cat >11/expected <<EOF &&
1499
-setup: git_dir: $here/11.git
1500
-setup: worktree: $here
1501
-setup: cwd: $here
1502
-setup: prefix: 11/
1503
-EOF
1504
- test_repo 11 .git "$here"
523
+ try_repo 17c non-existent unset unset "" true \
524
+ .git "(null)" "$here/17c" "(null)" \
525
+ "$here/17c/.git" "(null)" "$here/17c/sub" "(null)"
526
'
527
1507
-test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
1508
- cat >11/expected <<EOF &&
1509
-setup: git_dir: $here/11.git
1510
-setup: worktree: $here
1511
-setup: cwd: $here
1512
-setup: prefix: 11/
1513
-EOF
1514
- test_repo 11 .git ..
528
+test_expect_success '#18: bare .git named by GIT_DIR has no worktree' '
529
+ try_repo 18 unset .git unset "" true \
530
+ .git "(null)" "$here/18" "(null)" \
531
+ ../.git "(null)" "$here/18/sub" "(null)" &&
532
+ try_repo 18b unset "$here/18b/.git" unset "" true \
533
+ "$here/18b/.git" "(null)" "$here/18b" "(null)" \
534
+ "$here/18b/.git" "(null)" "$here/18b/sub" "(null)"
535
'
536
1517
-test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
1518
- cat >11/expected <<EOF &&
1519
-setup: git_dir: $here/11.git
1520
-setup: worktree: $here
1521
-setup: cwd: $here
1522
-setup: prefix: 11/
1523
-EOF
1524
- test_repo 11 "$here/11/.git" ..
537
+# Case #19: GIT_DIR + GIT_WORK_TREE suppresses bareness.
538
+test_expect_success '#19: setup' '
539
+ setup_repo 19 unset "" true &&
540
+ mkdir -p 19/sub/sub 19/wt/sub
541
+'
542
+run_wt_tests 19
543
+
544
+test_expect_success '#20a: core.worktree without GIT_DIR ignored (inside .git)' '
545
+ # Just like case #16a.
546
+ setup_repo 20a non-existent "" unset &&
547
+ mkdir -p 20a/.git/wt/sub &&
548
+ try_case 20a/.git unset unset \
549
+ . "(null)" "$here/20a/.git" "(null)" &&
550
+ try_case 20a/.git/wt unset unset \
551
+ "$here/20a/.git" "(null)" "$here/20a/.git/wt" "(null)" &&
552
+ try_case 20a/.git/wt/sub unset unset \
553
+ "$here/20a/.git" "(null)" "$here/20a/.git/wt/sub" "(null)"
554
+'
555
+
556
+test_expect_success '#20b/c: core.worktree without GIT_DIR ignored (bare repository)' '
557
+ # Just like case #16b/c.
558
+ setup_repo 20b non-existent "" true &&
559
+ mkdir -p 20b/.git/wt/sub &&
560
+ try_case 20b/.git unset unset \
561
+ . "(null)" "$here/20b/.git" "(null)" &&
562
+ try_case 20b/.git/wt unset unset \
563
+ "$here/20b/.git" "(null)" "$here/20b/.git/wt" "(null)" &&
564
+ try_case 20b/.git/wt/sub unset unset \
565
+ "$here/20b/.git" "(null)" "$here/20b/.git/wt/sub" "(null)" &&
566
+ try_repo 20c unset unset non-existent "" true \
567
+ .git "(null)" "$here/20c" "(null)" \
568
+ "$here/20c/.git" "(null)" "$here/20c/sub" "(null)"
569
+'
570
+
571
+test_expect_success '#21: core.worktree+GIT_WORK_TREE without GIT_DIR ignored (bare cases)' '
572
+ setup_repo 21a non-existent "" unset &&
573
+ mkdir -p 21a/.git/wt/sub &&
574
+ try_case 21a/.git non-existent-too unset \
575
+ . "(null)" "$here/21a/.git" "(null)" &&
576
+ try_case 21a/.git/wt non-existent-too unset \
577
+ "$here/21a/.git" "(null)" "$here/21a/.git/wt" "(null)" &&
578
+ try_case 21a/.git/wt/sub non-existent-too unset \
579
+ "$here/21a/.git" "(null)" "$here/21a/.git/wt/sub" "(null)" &&
580
+
581
+ setup_repo 21b non-existent "" true &&
582
+ mkdir -p 21b/.git/wt/sub &&
583
+ try_case 21b/.git non-existent-too unset \
584
+ . "(null)" "$here/21b/.git" "(null)" &&
585
+ try_case 21b/.git/wt non-existent-too unset \
586
+ "$here/21b/.git" "(null)" "$here/21b/.git/wt" "(null)" &&
587
+ try_case 21b/.git/wt/sub non-existent-too unset \
588
+ "$here/21b/.git" "(null)" "$here/21b/.git/wt/sub" "(null)" &&
589
+
590
+ try_repo 21c non-existent-too unset non-existent "" true \
591
+ .git "(null)" "$here/21c" "(null)" \
592
+ "$here/21c/.git" "(null)" "$here/21c/sub" "(null)"
593
+'
594
+
595
+test_expect_success '#22a: core.worktree = GIT_DIR = .git dir' '
596
+ # like case #6.
597
+
598
+ setup_repo 22a "$here/22a/.git" "" unset &&
599
+ setup_repo 22ab . "" unset
600
+ mkdir -p 22a/.git/sub 22a/sub &&
601
+ mkdir -p 22ab/.git/sub 22ab/sub &&
602
+ try_case 22a/.git unset . \
603
+ . "$here/22a/.git" "$here/22a/.git" "(null)" &&
604
+ try_case 22a/.git unset "$here/22a/.git" \
605
+ "$here/22a/.git" "$here/22a/.git" "$here/22a/.git" "(null)" &&
606
+ try_case 22a/.git/sub unset .. \
607
+ "$here/22a/.git" "$here/22a/.git" "$here/22a/.git" sub/ &&
608
+ try_case 22a/.git/sub unset "$here/22a/.git" \
609
+ "$here/22a/.git" "$here/22a/.git" "$here/22a/.git" sub/ &&
610
+
611
+ try_case 22ab/.git unset . \
612
+ . "$here/22ab/.git" "$here/22ab/.git" "(null)" &&
613
+ try_case 22ab/.git unset "$here/22ab/.git" \
614
+ "$here/22ab/.git" "$here/22ab/.git" "$here/22ab/.git" "(null)" &&
615
+ try_case 22ab/.git/sub unset .. \
616
+ "$here/22ab/.git" "$here/22ab/.git" "$here/22ab/.git" sub/ &&
617
+ try_case 22ab/.git unset "$here/22ab/.git" \
618
+ "$here/22ab/.git" "$here/22ab/.git" "$here/22ab/.git" "(null)"
619
+'
620
+
621
+test_expect_success '#22b: core.worktree child of .git, GIT_DIR=.git' '
622
+ setup_repo 22b "$here/22b/.git/wt" "" unset &&
623
+ setup_repo 22bb wt "" unset &&
624
+ mkdir -p 22b/.git/sub 22b/sub 22b/.git/wt/sub 22b/wt/sub &&
625
+ mkdir -p 22bb/.git/sub 22bb/sub 22bb/.git/wt 22bb/wt &&
626
+
627
+ try_case 22b/.git unset . \
628
+ . "$here/22b/.git/wt" "$here/22b/.git" "(null)" &&
629
+ try_case 22b/.git unset "$here/22b/.git" \
630
+ "$here/22b/.git" "$here/22b/.git/wt" "$here/22b/.git" "(null)" &&
631
+ try_case 22b/.git/sub unset .. \
632
+ .. "$here/22b/.git/wt" "$here/22b/.git/sub" "(null)" &&
633
+ try_case 22b/.git/sub unset "$here/22b/.git" \
634
+ "$here/22b/.git" "$here/22b/.git/wt" "$here/22b/.git/sub" "(null)" &&
635
+
636
+ try_case 22bb/.git unset . \
637
+ . "$here/22bb/.git/wt" "$here/22bb/.git" "(null)" &&
638
+ try_case 22bb/.git unset "$here/22bb/.git" \
639
+ "$here/22bb/.git" "$here/22bb/.git/wt" "$here/22bb/.git" "(null)" &&
640
+ try_case 22bb/.git/sub unset .. \
641
+ .. "$here/22bb/.git/wt" "$here/22bb/.git/sub" "(null)" &&
642
+ try_case 22bb/.git/sub unset "$here/22bb/.git" \
643
+ "$here/22bb/.git" "$here/22bb/.git/wt" "$here/22bb/.git/sub" "(null)"
644
+'
645
+
646
+test_expect_success '#22c: core.worktree = .git/.., GIT_DIR=.git' '
647
+ setup_repo 22c "$here/22c" "" unset &&
648
+ setup_repo 22cb .. "" unset &&
649
+ mkdir -p 22c/.git/sub 22c/sub &&
650
+ mkdir -p 22cb/.git/sub 22cb/sub &&
651
+
652
+ try_case 22c/.git unset . \
653
+ "$here/22c/.git" "$here/22c" "$here/22c" .git/ &&
654
+ try_case 22c/.git unset "$here/22c/.git" \
655
+ "$here/22c/.git" "$here/22c" "$here/22c" .git/ &&
656
+ try_case 22c/.git/sub unset .. \
657
+ "$here/22c/.git" "$here/22c" "$here/22c" .git/sub/ &&
658
+ try_case 22c/.git/sub unset "$here/22c/.git" \
659
+ "$here/22c/.git" "$here/22c" "$here/22c" .git/sub/ &&
660
+
661
+ try_case 22cb/.git unset . \
662
+ "$here/22cb/.git" "$here/22cb" "$here/22cb" .git/ &&
663
+ try_case 22cb/.git unset "$here/22cb/.git" \
664
+ "$here/22cb/.git" "$here/22cb" "$here/22cb" .git/ &&
665
+ try_case 22cb/.git/sub unset .. \
666
+ "$here/22cb/.git" "$here/22cb" "$here/22cb" .git/sub/ &&
667
+ try_case 22cb/.git/sub unset "$here/22cb/.git" \
668
+ "$here/22cb/.git" "$here/22cb" "$here/22cb" .git/sub/
669
+'
670
+
671
+test_expect_success '#22.2: core.worktree and core.bare conflict' '
672
+ setup_repo 22 "$here/22" "" true &&
673
+ (
674
+ cd 22/.git &&
675
+ GIT_DIR=. &&
676
+ export GIT_DIR &&
677
+ test_must_fail git symbolic-ref HEAD 2>result
678
+ ) &&
679
+ (
680
+ cd 22 &&
681
+ GIT_DIR=.git &&
682
+ export GIT_DIR &&
683
+ test_must_fail git symbolic-ref HEAD 2>result
684
+ ) &&
685
+ grep "core.bare and core.worktree" 22/.git/result &&
686
+ grep "core.bare and core.worktree" 22/result
687
'
688
1527
-test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=.. at root' '
1528
- cat >11/expected <<EOF &&
1529
-setup: git_dir: $here/11.git
1530
-setup: worktree: $here
1531
-setup: cwd: $here
1532
-setup: prefix: 11/
1533
-EOF
1534
- test_repo 11 "$here/11/.git" "$here"
689
+# Case #23: GIT_DIR + GIT_WORK_TREE(+core.worktree) suppresses bareness.
690
+test_expect_success '#23: setup' '
691
+ setup_repo 23 non-existent "" true &&
692
+ mkdir -p 23/sub/sub 23/wt/sub
693
'
694
+run_wt_tests 23
695
1537
-test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
1538
- cat >11/sub/sub/expected <<EOF &&
1539
-setup: git_dir: $here/11.git
1540
-setup: worktree: $here
1541
-setup: cwd: $here
1542
-setup: prefix: 11/sub/sub/
1543
-EOF
1544
- test_repo 11/sub/sub ../../.git "$here"
696
+test_expect_success '#24: bare repo has no worktree (gitfile case)' '
697
+ try_repo 24 unset unset unset gitfile true \
698
+ "$here/24.git" "(null)" "$here/24" "(null)" \
699
+ "$here/24.git" "(null)" "$here/24/sub" "(null)"
700
'
701
1547
-test_expect_success '#11: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
1548
- cat >11/sub/sub/expected <<EOF &&
1549
-setup: git_dir: $here/11.git
1550
-setup: worktree: $here
1551
-setup: cwd: $here
1552
-setup: prefix: 11/sub/sub/
1553
-EOF
1554
- test_repo 11/sub/sub ../../.git ../../..
702
+test_expect_success '#25: GIT_WORK_TREE ignored if GIT_DIR unset (bare gitfile case)' '
703
+ try_repo 25 non-existent unset unset gitfile true \
704
+ "$here/25.git" "(null)" "$here/25" "(null)" \
705
+ "$here/25.git" "(null)" "$here/25/sub" "(null)"
706
'
707
1557
-test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
1558
- cat >11/sub/sub/expected <<EOF &&
1559
-setup: git_dir: $here/11.git
1560
-setup: worktree: $here
1561
-setup: cwd: $here
1562
-setup: prefix: 11/sub/sub/
1563
-EOF
1564
- test_repo 11/sub/sub "$here/11/.git" ../../../
708
+test_expect_success '#26: bare repo has no worktree (GIT_DIR -> gitfile case)' '
709
+ try_repo 26 unset "$here/26/.git" unset gitfile true \
710
+ "$here/26.git" "(null)" "$here/26" "(null)" \
711
+ "$here/26.git" "(null)" "$here/26/sub" "(null)" &&
712
+ try_repo 26b unset .git unset gitfile true \
713
+ "$here/26b.git" "(null)" "$here/26b" "(null)" \
714
+ "$here/26b.git" "(null)" "$here/26b/sub" "(null)"
715
'
716
1567
-test_expect_success '#11: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
1568
- cat >11/sub/sub/expected <<EOF &&
1569
-setup: git_dir: $here/11.git
1570
-setup: worktree: $here
1571
-setup: cwd: $here
1572
-setup: prefix: 11/sub/sub/
1573
-EOF
1574
- test_repo 11/sub/sub "$here/11/.git" "$here"
717
+# Case #27: GIT_DIR + GIT_WORK_TREE suppresses bareness (with gitfile).
718
+test_expect_success '#27: setup' '
719
+ setup_repo 27 unset gitfile true &&
720
+ mkdir -p 27/sub/sub 27/wt/sub
721
'
722
+run_wt_tests 27 gitfile
723
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
-
1595
-test_expect_success '#12: setup' '
1596
- sane_unset GIT_DIR GIT_WORK_TREE &&
1597
- mkdir 12 12/sub 12/sub/sub 12.wt 12.wt/sub 12/wt 12/wt/sub &&
1598
- cd 12 &&
1599
- git init &&
1600
- git config core.worktree non-existent &&
1601
- mv .git ../12.git &&
1602
- echo gitdir: ../12.git >.git &&
1603
- cd ..
724
+test_expect_success '#28: core.worktree ignored if GIT_DIR unset (bare gitfile case)' '
725
+ try_repo 28 unset unset non-existent gitfile true \
726
+ "$here/28.git" "(null)" "$here/28" "(null)" \
727
+ "$here/28.git" "(null)" "$here/28/sub" "(null)"
728
'
729
1606
-test_expect_success '#12: at root' '
1607
- cat >12/expected <<EOF &&
1608
-setup: git_dir: $here/12.git
1609
-setup: worktree: $here/12
1610
-setup: cwd: $here/12
1611
-setup: prefix: (null)
1612
-EOF
1613
- test_repo 12
730
+test_expect_success '#29: GIT_WORK_TREE+core.worktree ignored if GIT_DIR unset (bare gitfile case)' '
731
+ try_repo 29 non-existent-too unset non-existent gitfile true \
732
+ "$here/29.git" "(null)" "$here/29" "(null)" \
733
+ "$here/29.git" "(null)" "$here/29/sub" "(null)"
734
'
735
1616
-test_expect_success '#12: in subdir' '
1617
- cat >12/sub/expected <<EOF &&
1618
-setup: git_dir: $here/12.git
1619
-setup: worktree: $here/12
1620
-setup: cwd: $here/12
1621
-setup: prefix: sub/
1622
-EOF
1623
- test_repo 12/sub
736
+test_expect_success '#30: core.worktree and core.bare conflict (gitfile version)' '
737
+ # Just like case #22.
738
+ setup_repo 30 "$here/30" gitfile true &&
739
+ (
740
+ cd 30 &&
741
+ GIT_DIR=.git &&
742
+ export GIT_DIR &&
743
+ test_must_fail git symbolic-ref HEAD 2>result
744
+ ) &&
745
+ grep "core.bare and core.worktree" 30/result
746
'
747
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
-
1643
-test_expect_success '#13: setup' '
1644
- sane_unset GIT_DIR GIT_WORK_TREE &&
1645
- mkdir 13 13/sub 13/sub/sub 13.wt 13.wt/sub 13/wt 13/wt/sub &&
1646
- cd 13 &&
1647
- git init &&
1648
- git config core.worktree non-existent &&
1649
- GIT_WORK_TREE=non-existent-too &&
1650
- export GIT_WORK_TREE &&
1651
- mv .git ../13.git &&
1652
- echo gitdir: ../13.git >.git &&
1653
- cd ..
1654
-'
1655
-
1656
-test_expect_success '#13: at root' '
1657
- cat >13/expected <<EOF &&
1658
-setup: git_dir: $here/13.git
1659
-setup: worktree: $here/13
1660
-setup: cwd: $here/13
1661
-setup: prefix: (null)
1662
-EOF
1663
- test_repo 13
1664
-'
1665
-
1666
-test_expect_success '#13: in subdir' '
1667
- cat >13/sub/expected <<EOF &&
1668
-setup: git_dir: $here/13.git
1669
-setup: worktree: $here/13
1670
-setup: cwd: $here/13
1671
-setup: prefix: sub/
1672
-EOF
1673
- test_repo 13/sub
1674
-'
1675
-
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
-
1693
-test_expect_success '#14: setup' '
1694
- sane_unset GIT_DIR GIT_WORK_TREE &&
1695
- mkdir 14 14/sub 14/sub/sub 14.wt 14.wt/sub 14/wt 14/wt/sub &&
1696
- cd 14 &&
1697
- git init &&
1698
- mv .git ../14.git &&
1699
- echo gitdir: ../14.git >.git &&
1700
- cd ..
1701
-'
1702
-
1703
-test_expect_success '#14: GIT_DIR(rel), core.worktree=../14 at root' '
1704
- cat >14/expected <<EOF &&
1705
-setup: git_dir: $here/14.git
1706
-setup: worktree: $here/14
1707
-setup: cwd: $here/14
1708
-setup: prefix: (null)
1709
-EOF
1710
- git config --file="$here/14.git/config" core.worktree "$here/14" &&
1711
- test_repo 14 .git
1712
-'
1713
-
1714
-test_expect_success '#14: GIT_DIR(rel), core.worktree=../14(rel) at root' '
1715
- cat >14/expected <<EOF &&
1716
-setup: git_dir: $here/14.git
1717
-setup: worktree: $here/14
1718
-setup: cwd: $here/14
1719
-setup: prefix: (null)
1720
-EOF
1721
- git config --file="$here/14.git/config" core.worktree ../14 &&
1722
- test_repo 14 .git
1723
-'
1724
-
1725
-test_expect_success '#14: GIT_DIR, core.worktree=../14 at root' '
1726
- cat >14/expected <<EOF &&
1727
-setup: git_dir: $here/14.git
1728
-setup: worktree: $here/14
1729
-setup: cwd: $here/14
1730
-setup: prefix: (null)
1731
-EOF
1732
- git config --file="$here/14.git/config" core.worktree "$here/14" &&
1733
- test_repo 14 "$here/14/.git"
1734
-'
1735
-
1736
-test_expect_success '#14: GIT_DIR, core.worktree=../14(rel) at root' '
1737
- cat >14/expected <<EOF &&
1738
-setup: git_dir: $here/14.git
1739
-setup: worktree: $here/14
1740
-setup: cwd: $here/14
1741
-setup: prefix: (null)
1742
-EOF
1743
- git config --file="$here/14.git/config" core.worktree ../14 &&
1744
- test_repo 14 "$here/14/.git"
1745
-'
1746
-
1747
-test_expect_success '#14: GIT_DIR(rel), core.worktree=../14 in subdir' '
1748
- cat >14/sub/sub/expected <<EOF &&
1749
-setup: git_dir: $here/14.git
1750
-setup: worktree: $here/14
1751
-setup: cwd: $here/14
1752
-setup: prefix: sub/sub/
1753
-EOF
1754
- git config --file="$here/14.git/config" core.worktree "$here/14" &&
1755
- test_repo 14/sub/sub ../../.git
1756
-'
1757
-
1758
-test_expect_success '#14: GIT_DIR(rel), core.worktree=../14(rel) in subdir' '
1759
- cat >14/sub/sub/expected <<EOF &&
1760
-setup: git_dir: $here/14.git
1761
-setup: worktree: $here/14
1762
-setup: cwd: $here/14
1763
-setup: prefix: sub/sub/
1764
-EOF
1765
- git config --file="$here/14.git/config" core.worktree ../14 &&
1766
- test_repo 14/sub/sub ../../.git
1767
-'
1768
-
1769
-test_expect_success '#14: GIT_DIR, core.worktree=../14 in subdir' '
1770
- cat >14/sub/expected <<EOF &&
1771
-setup: git_dir: $here/14.git
1772
-setup: worktree: $here/14
1773
-setup: cwd: $here/14
1774
-setup: prefix: sub/
1775
-EOF
1776
- git config --file="$here/14.git/config" core.worktree "$here/14" &&
1777
- test_repo 14/sub "$here/14/.git"
1778
-'
1779
-
1780
-test_expect_success '#14: GIT_DIR, core.worktree=../14(rel) in subdir' '
1781
- cat >14/sub/sub/expected <<EOF &&
1782
-setup: git_dir: $here/14.git
1783
-setup: worktree: $here/14
1784
-setup: cwd: $here/14
1785
-setup: prefix: sub/sub/
1786
-EOF
1787
- git config --file="$here/14.git/config" core.worktree ../14 &&
1788
- test_repo 14/sub/sub "$here/14/.git"
1789
-'
1790
-
1791
-test_expect_success '#14: GIT_DIR(rel), core.worktree=../14/wt at root' '
1792
- cat >14/expected <<EOF &&
1793
-setup: git_dir: $here/14.git
1794
-setup: worktree: $here/14/wt
1795
-setup: cwd: $here/14
1796
-setup: prefix: (null)
1797
-EOF
1798
- git config --file="$here/14.git/config" core.worktree "$here/14/wt" &&
1799
- test_repo 14 .git
1800
-'
1801
-
1802
-test_expect_success '#14: GIT_DIR(rel), core.worktree=../14/wt(rel) at root' '
1803
- cat >14/expected <<EOF &&
1804
-setup: git_dir: $here/14.git
1805
-setup: worktree: $here/14/wt
1806
-setup: cwd: $here/14
1807
-setup: prefix: (null)
1808
-EOF
1809
- git config --file="$here/14.git/config" core.worktree ../14/wt &&
1810
- test_repo 14 .git
1811
-'
1812
-
1813
-test_expect_success '#14: GIT_DIR, core.worktree=../14/wt(rel) at root' '
1814
- cat >14/expected <<EOF &&
1815
-setup: git_dir: $here/14.git
1816
-setup: worktree: $here/14/wt
1817
-setup: cwd: $here/14
1818
-setup: prefix: (null)
1819
-EOF
1820
- git config --file="$here/14.git/config" core.worktree ../14/wt &&
1821
- test_repo 14 "$here/14/.git"
1822
-'
1823
-
1824
-test_expect_success '#14: GIT_DIR, core.worktree=../14/wt at root' '
1825
- cat >14/expected <<EOF &&
1826
-setup: git_dir: $here/14.git
1827
-setup: worktree: $here/14/wt
1828
-setup: cwd: $here/14
1829
-setup: prefix: (null)
1830
-EOF
1831
- git config --file="$here/14.git/config" core.worktree "$here/14/wt" &&
1832
- test_repo 14 "$here/14/.git"
1833
-'
1834
-
1835
-test_expect_success '#14: GIT_DIR(rel), core.worktree=../14/wt in subdir' '
1836
- cat >14/sub/sub/expected <<EOF &&
1837
-setup: git_dir: $here/14.git
1838
-setup: worktree: $here/14/wt
1839
-setup: cwd: $here/14/sub/sub
1840
-setup: prefix: (null)
1841
-EOF
1842
- git config --file="$here/14.git/config" core.worktree "$here/14/wt" &&
1843
- test_repo 14/sub/sub ../../.git
1844
-'
1845
-
1846
-test_expect_success '#14: GIT_DIR(rel), core.worktree=../14/wt(rel) in subdir' '
1847
- cat >14/sub/sub/expected <<EOF &&
1848
-setup: git_dir: $here/14.git
1849
-setup: worktree: $here/14/wt
1850
-setup: cwd: $here/14/sub/sub
1851
-setup: prefix: (null)
1852
-EOF
1853
- git config --file="$here/14.git/config" core.worktree ../14/wt &&
1854
- test_repo 14/sub/sub ../../.git
1855
-'
1856
-
1857
-test_expect_success '#14: GIT_DIR, core.worktree=../14/wt(rel) in subdir' '
1858
- cat >14/sub/sub/expected <<EOF &&
1859
-setup: git_dir: $here/14.git
1860
-setup: worktree: $here/14/wt
1861
-setup: cwd: $here/14/sub/sub
1862
-setup: prefix: (null)
1863
-EOF
1864
- git config --file="$here/14.git/config" core.worktree ../14/wt &&
1865
- test_repo 14/sub/sub "$here/14/.git"
1866
-'
1867
-
1868
-test_expect_success '#14: GIT_DIR, core.worktree=../14/wt in subdir' '
1869
- cat >14/sub/sub/expected <<EOF &&
1870
-setup: git_dir: $here/14.git
1871
-setup: worktree: $here/14/wt
1872
-setup: cwd: $here/14/sub/sub
1873
-setup: prefix: (null)
1874
-EOF
1875
- git config --file="$here/14.git/config" core.worktree "$here/14/wt" &&
1876
- test_repo 14/sub/sub "$here/14/.git"
1877
-'
1878
-
1879
-test_expect_success '#14: GIT_DIR(rel), core.worktree=.. at root' '
1880
- cat >14/expected <<EOF &&
1881
-setup: git_dir: $here/14.git
1882
-setup: worktree: $here
1883
-setup: cwd: $here
1884
-setup: prefix: 14/
1885
-EOF
1886
- git config --file="$here/14.git/config" core.worktree "$here" &&
1887
- test_repo 14 .git
1888
-'
1889
-
1890
-test_expect_success '#14: GIT_DIR(rel), core.worktree=..(rel) at root' '
1891
- cat >14/expected <<EOF &&
1892
-setup: git_dir: $here/14.git
1893
-setup: worktree: $here
1894
-setup: cwd: $here
1895
-setup: prefix: 14/
1896
-EOF
1897
- git config --file="$here/14.git/config" core.worktree .. &&
1898
- test_repo 14 .git
1899
-'
1900
-
1901
-test_expect_success '#14: GIT_DIR, core.worktree=..(rel) at root' '
1902
- cat >14/expected <<EOF &&
1903
-setup: git_dir: $here/14.git
1904
-setup: worktree: $here
1905
-setup: cwd: $here
1906
-setup: prefix: 14/
1907
-EOF
1908
- git config --file="$here/14.git/config" core.worktree .. &&
1909
- test_repo 14 "$here/14/.git"
1910
-'
1911
-
1912
-test_expect_success '#14: GIT_DIR, core.worktree=.. at root' '
1913
- cat >14/expected <<EOF &&
1914
-setup: git_dir: $here/14.git
1915
-setup: worktree: $here
1916
-setup: cwd: $here
1917
-setup: prefix: 14/
1918
-EOF
1919
- git config --file="$here/14.git/config" core.worktree "$here" &&
1920
- test_repo 14 "$here/14/.git"
1921
-'
1922
-
1923
-test_expect_success '#14: GIT_DIR(rel), core.worktree=.. in subdir' '
1924
- cat >14/sub/sub/expected <<EOF &&
1925
-setup: git_dir: $here/14.git
1926
-setup: worktree: $here
1927
-setup: cwd: $here
1928
-setup: prefix: 14/sub/sub/
1929
-EOF
1930
- git config --file="$here/14.git/config" core.worktree "$here" &&
1931
- test_repo 14/sub/sub ../../.git
1932
-'
1933
-
1934
-test_expect_success '#14: GIT_DIR(rel), core.worktree=..(rel) in subdir' '
1935
- cat >14/sub/sub/expected <<EOF &&
1936
-setup: git_dir: $here/14.git
1937
-setup: worktree: $here
1938
-setup: cwd: $here
1939
-setup: prefix: 14/sub/sub/
1940
-EOF
1941
- git config --file="$here/14.git/config" core.worktree .. &&
1942
- test_repo 14/sub/sub ../../.git
1943
-'
1944
-
1945
-test_expect_success '#14: GIT_DIR, core.worktree=..(rel) in subdir' '
1946
- cat >14/sub/sub/expected <<EOF &&
1947
-setup: git_dir: $here/14.git
1948
-setup: worktree: $here
1949
-setup: cwd: $here
1950
-setup: prefix: 14/sub/sub/
1951
-EOF
1952
- git config --file="$here/14.git/config" core.worktree .. &&
1953
- test_repo 14/sub/sub "$here/14/.git"
1954
-'
1955
-
1956
-test_expect_success '#14: GIT_DIR, core.worktree=.. in subdir' '
1957
- cat >14/sub/sub/expected <<EOF &&
1958
-setup: git_dir: $here/14.git
1959
-setup: worktree: $here
1960
-setup: cwd: $here
1961
-setup: prefix: 14/sub/sub/
1962
-EOF
1963
- git config --file="$here/14.git/config" core.worktree "$here" &&
1964
- test_repo 14/sub/sub "$here/14/.git"
1965
-'
1966
-
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
-
1984
-test_expect_success '#15: setup' '
1985
- sane_unset GIT_DIR GIT_WORK_TREE &&
1986
- mkdir 15 15/sub 15/sub/sub 15.wt 15.wt/sub 15/wt 15/wt/sub &&
1987
- cd 15 &&
1988
- git init &&
1989
- git config core.worktree non-existent &&
1990
- mv .git ../15.git &&
1991
- echo gitdir: ../15.git >.git &&
1992
- cd ..
1993
-'
1994
-
1995
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
1996
- cat >15/expected <<EOF &&
1997
-setup: git_dir: $here/15.git
1998
-setup: worktree: $here/15
1999
-setup: cwd: $here/15
2000
-setup: prefix: (null)
2001
-EOF
2002
- test_repo 15 .git "$here/15"
2003
-'
2004
-
2005
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
2006
- cat >15/expected <<EOF &&
2007
-setup: git_dir: $here/15.git
2008
-setup: worktree: $here/15
2009
-setup: cwd: $here/15
2010
-setup: prefix: (null)
2011
-EOF
2012
- test_repo 15 .git .
2013
-'
2014
-
2015
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=root at root' '
2016
- cat >15/expected <<EOF &&
2017
-setup: git_dir: $here/15.git
2018
-setup: worktree: $here/15
2019
-setup: cwd: $here/15
2020
-setup: prefix: (null)
2021
-EOF
2022
- test_repo 15 "$here/15/.git" "$here/15"
2023
-'
2024
-
2025
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
2026
- cat >15/expected <<EOF &&
2027
-setup: git_dir: $here/15.git
2028
-setup: worktree: $here/15
2029
-setup: cwd: $here/15
2030
-setup: prefix: (null)
2031
-EOF
2032
- test_repo 15 "$here/15/.git" .
2033
-'
2034
-
2035
-test_expect_success '#15: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
2036
- cat >15/sub/sub/expected <<EOF &&
2037
-setup: git_dir: $here/15.git
2038
-setup: worktree: $here/15
2039
-setup: cwd: $here/15
2040
-setup: prefix: sub/sub/
2041
-EOF
2042
- test_repo 15/sub/sub ../../.git "$here/15"
2043
-'
2044
-
2045
-test_expect_success '#15: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
2046
- cat >15/sub/sub/expected <<EOF &&
2047
-setup: git_dir: $here/15.git
2048
-setup: worktree: $here/15
2049
-setup: cwd: $here/15
2050
-setup: prefix: sub/sub/
2051
-EOF
2052
- test_repo 15/sub/sub ../../.git ../..
2053
-'
2054
-
2055
-test_expect_success '#15: GIT_DIR, GIT_WORKTREE=root in subdir' '
2056
- cat >15/sub/expected <<EOF &&
2057
-setup: git_dir: $here/15.git
2058
-setup: worktree: $here/15
2059
-setup: cwd: $here/15
2060
-setup: prefix: sub/
2061
-EOF
2062
- test_repo 15/sub "$here/15/.git" "$here/15"
2063
-'
2064
-
2065
-test_expect_success '#15: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
2066
- cat >15/sub/sub/expected <<EOF &&
2067
-setup: git_dir: $here/15.git
2068
-setup: worktree: $here/15
2069
-setup: cwd: $here/15
2070
-setup: prefix: sub/sub/
2071
-EOF
2072
- test_repo 15/sub/sub "$here/15/.git" ../..
2073
-'
2074
-
2075
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
2076
- cat >15/expected <<EOF &&
2077
-setup: git_dir: $here/15.git
2078
-setup: worktree: $here/15/wt
2079
-setup: cwd: $here/15
2080
-setup: prefix: (null)
2081
-EOF
2082
- test_repo 15 .git "$here/15/wt"
2083
-'
2084
-
2085
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
2086
- cat >15/expected <<EOF &&
2087
-setup: git_dir: $here/15.git
2088
-setup: worktree: $here/15/wt
2089
-setup: cwd: $here/15
2090
-setup: prefix: (null)
2091
-EOF
2092
- test_repo 15 .git wt
2093
-'
2094
-
2095
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
2096
- cat >15/expected <<EOF &&
2097
-setup: git_dir: $here/15.git
2098
-setup: worktree: $here/15/wt
2099
-setup: cwd: $here/15
2100
-setup: prefix: (null)
2101
-EOF
2102
- test_repo 15 "$here/15/.git" wt
2103
-'
2104
-
2105
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=wt at root' '
2106
- cat >15/expected <<EOF &&
2107
-setup: git_dir: $here/15.git
2108
-setup: worktree: $here/15/wt
2109
-setup: cwd: $here/15
2110
-setup: prefix: (null)
2111
-EOF
2112
- test_repo 15 "$here/15/.git" "$here/15/wt"
2113
-'
2114
-
2115
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
2116
- cat >15/sub/sub/expected <<EOF &&
2117
-setup: git_dir: $here/15.git
2118
-setup: worktree: $here/15/wt
2119
-setup: cwd: $here/15/sub/sub
2120
-setup: prefix: (null)
2121
-EOF
2122
- test_repo 15/sub/sub ../../.git "$here/15/wt"
2123
-'
2124
-
2125
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
2126
- cat >15/sub/sub/expected <<EOF &&
2127
-setup: git_dir: $here/15.git
2128
-setup: worktree: $here/15/wt
2129
-setup: cwd: $here/15/sub/sub
2130
-setup: prefix: (null)
2131
-EOF
2132
- test_repo 15/sub/sub ../../.git ../../wt
2133
-'
2134
-
2135
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
2136
- cat >15/sub/sub/expected <<EOF &&
2137
-setup: git_dir: $here/15.git
2138
-setup: worktree: $here/15/wt
2139
-setup: cwd: $here/15/sub/sub
2140
-setup: prefix: (null)
2141
-EOF
2142
- test_repo 15/sub/sub "$here/15/.git" ../../wt
2143
-'
2144
-
2145
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
2146
- cat >15/sub/sub/expected <<EOF &&
2147
-setup: git_dir: $here/15.git
2148
-setup: worktree: $here/15/wt
2149
-setup: cwd: $here/15/sub/sub
2150
-setup: prefix: (null)
2151
-EOF
2152
- test_repo 15/sub/sub "$here/15/.git" "$here/15/wt"
2153
-'
2154
-
2155
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
2156
- cat >15/expected <<EOF &&
2157
-setup: git_dir: $here/15.git
2158
-setup: worktree: $here
2159
-setup: cwd: $here
2160
-setup: prefix: 15/
2161
-EOF
2162
- test_repo 15 .git "$here"
2163
-'
2164
-
2165
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
2166
- cat >15/expected <<EOF &&
2167
-setup: git_dir: $here/15.git
2168
-setup: worktree: $here
2169
-setup: cwd: $here
2170
-setup: prefix: 15/
2171
-EOF
2172
- test_repo 15 .git ..
2173
-'
2174
-
2175
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
2176
- cat >15/expected <<EOF &&
2177
-setup: git_dir: $here/15.git
2178
-setup: worktree: $here
2179
-setup: cwd: $here
2180
-setup: prefix: 15/
2181
-EOF
2182
- test_repo 15 "$here/15/.git" ..
2183
-'
2184
-
2185
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=.. at root' '
2186
- cat >15/expected <<EOF &&
2187
-setup: git_dir: $here/15.git
2188
-setup: worktree: $here
2189
-setup: cwd: $here
2190
-setup: prefix: 15/
2191
-EOF
2192
- test_repo 15 "$here/15/.git" "$here"
2193
-'
2194
-
2195
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
2196
- cat >15/sub/sub/expected <<EOF &&
2197
-setup: git_dir: $here/15.git
2198
-setup: worktree: $here
2199
-setup: cwd: $here
2200
-setup: prefix: 15/sub/sub/
2201
-EOF
2202
- test_repo 15/sub/sub ../../.git "$here"
2203
-'
2204
-
2205
-test_expect_success '#15: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
2206
- cat >15/sub/sub/expected <<EOF &&
2207
-setup: git_dir: $here/15.git
2208
-setup: worktree: $here
2209
-setup: cwd: $here
2210
-setup: prefix: 15/sub/sub/
2211
-EOF
2212
- test_repo 15/sub/sub ../../.git ../../..
2213
-'
2214
-
2215
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
2216
- cat >15/sub/sub/expected <<EOF &&
2217
-setup: git_dir: $here/15.git
2218
-setup: worktree: $here
2219
-setup: cwd: $here
2220
-setup: prefix: 15/sub/sub/
2221
-EOF
2222
- test_repo 15/sub/sub "$here/15/.git" ../../../
2223
-'
2224
-
2225
-test_expect_success '#15: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
2226
- cat >15/sub/sub/expected <<EOF &&
2227
-setup: git_dir: $here/15.git
2228
-setup: worktree: $here
2229
-setup: cwd: $here
2230
-setup: prefix: 15/sub/sub/
2231
-EOF
2232
- test_repo 15/sub/sub "$here/15/.git" "$here"
2233
-'
2234
-
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
-
2256
-test_expect_success '#16.1: setup' '
2257
- sane_unset GIT_DIR GIT_WORK_TREE &&
2258
- mkdir 16 16/sub &&
2259
- cd 16 &&
2260
- git init &&
2261
- mkdir .git/wt .git/wt/sub &&
2262
- cd ..
2263
-'
2264
-
2265
-test_expect_success '#16.1: at .git' '
2266
- cat >16/.git/expected <<EOF &&
2267
-setup: git_dir: .
2268
-setup: worktree: (null)
2269
-setup: cwd: $here/16/.git
2270
-setup: prefix: (null)
2271
-EOF
2272
- test_repo 16/.git
2273
-'
2274
-
2275
-test_expect_success '#16.1: in .git/wt' '
2276
- cat >16/.git/wt/expected <<EOF &&
2277
-setup: git_dir: $here/16/.git
2278
-setup: worktree: (null)
2279
-setup: cwd: $here/16/.git/wt
2280
-setup: prefix: (null)
2281
-EOF
2282
- test_repo 16/.git/wt
2283
-'
2284
-
2285
-test_expect_success '#16.1: in .git/wt/sub' '
2286
- cat >16/.git/wt/sub/expected <<EOF &&
2287
-setup: git_dir: $here/16/.git
2288
-setup: worktree: (null)
2289
-setup: cwd: $here/16/.git/wt/sub
2290
-setup: prefix: (null)
2291
-EOF
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
-
2316
-test_expect_success '#16.2: setup' '
2317
- git config --file="$here/16/.git/config" core.bare true
2318
-'
2319
-
2320
-test_expect_success '#16.2: at .git' '
2321
- cat >16/.git/expected <<EOF &&
2322
-setup: git_dir: .
2323
-setup: worktree: (null)
2324
-setup: cwd: $here/16/.git
2325
-setup: prefix: (null)
2326
-EOF
2327
- test_repo 16/.git
2328
-'
2329
-
2330
-test_expect_success '#16.2: in .git/wt' '
2331
- cat >16/.git/wt/expected <<EOF &&
2332
-setup: git_dir: $here/16/.git
2333
-setup: worktree: (null)
2334
-setup: cwd: $here/16/.git/wt
2335
-setup: prefix: (null)
2336
-EOF
2337
- test_repo 16/.git/wt
2338
-'
2339
-
2340
-test_expect_success '#16.2: in .git/wt/sub' '
2341
- cat >16/.git/wt/sub/expected <<EOF &&
2342
-setup: git_dir: $here/16/.git
2343
-setup: worktree: (null)
2344
-setup: cwd: $here/16/.git/wt/sub
2345
-setup: prefix: (null)
2346
-EOF
2347
- test_repo 16/.git/wt/sub
2348
-'
2349
-
2350
-test_expect_success '#16.2: at root' '
2351
- cat >16/expected <<EOF &&
2352
-setup: git_dir: .git
2353
-setup: worktree: (null)
2354
-setup: cwd: $here/16
2355
-setup: prefix: (null)
2356
-EOF
2357
- test_repo 16
2358
-'
2359
-
2360
-test_expect_success '#16.2: in subdir' '
2361
- cat >16/sub/expected <<EOF &&
2362
-setup: git_dir: $here/16/.git
2363
-setup: worktree: (null)
2364
-setup: cwd: $here/16/sub
2365
-setup: prefix: (null)
2366
-EOF
2367
- test_repo 16/sub
2368
-'
2369
-
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
-
2387
-test_expect_success '#17.1: setup' '
2388
- sane_unset GIT_DIR GIT_WORK_TREE &&
2389
- mkdir 17 17/sub &&
2390
- cd 17 &&
2391
- git init &&
2392
- mkdir .git/wt .git/wt/sub &&
2393
- GIT_WORK_TREE=non-existent &&
2394
- export GIT_WORK_TREE &&
2395
- cd ..
2396
-'
2397
-
2398
-test_expect_success '#17.1: at .git' '
2399
- cat >17/.git/expected <<EOF &&
2400
-setup: git_dir: .
2401
-setup: worktree: (null)
2402
-setup: cwd: $here/17/.git
2403
-setup: prefix: (null)
2404
-EOF
2405
- test_repo 17/.git
2406
-'
2407
-
2408
-test_expect_success '#17.1: in .git/wt' '
2409
- cat >17/.git/wt/expected <<EOF &&
2410
-setup: git_dir: $here/17/.git
2411
-setup: worktree: (null)
2412
-setup: cwd: $here/17/.git/wt
2413
-setup: prefix: (null)
2414
-EOF
2415
- test_repo 17/.git/wt
2416
-'
2417
-
2418
-test_expect_success '#17.1: in .git/wt/sub' '
2419
- cat >17/.git/wt/sub/expected <<EOF &&
2420
-setup: git_dir: $here/17/.git
2421
-setup: worktree: (null)
2422
-setup: cwd: $here/17/.git/wt/sub
2423
-setup: prefix: (null)
2424
-EOF
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
-
2445
-test_expect_success '#17.2: setup' '
2446
- git config --file="$here/17/.git/config" core.bare true
2447
-'
2448
-
2449
-test_expect_success '#17.2: at .git' '
2450
- cat >17/.git/expected <<EOF &&
2451
-setup: git_dir: .
2452
-setup: worktree: (null)
2453
-setup: cwd: $here/17/.git
2454
-setup: prefix: (null)
2455
-EOF
2456
- test_repo 17/.git
2457
-'
2458
-
2459
-test_expect_success '#17.2: in .git/wt' '
2460
- cat >17/.git/wt/expected <<EOF &&
2461
-setup: git_dir: $here/17/.git
2462
-setup: worktree: (null)
2463
-setup: cwd: $here/17/.git/wt
2464
-setup: prefix: (null)
2465
-EOF
2466
- test_repo 17/.git/wt
2467
-'
2468
-
2469
-test_expect_success '#17.2: in .git/wt/sub' '
2470
- cat >17/.git/wt/sub/expected <<EOF &&
2471
-setup: git_dir: $here/17/.git
2472
-setup: worktree: (null)
2473
-setup: cwd: $here/17/.git/wt/sub
2474
-setup: prefix: (null)
2475
-EOF
2476
- test_repo 17/.git/wt/sub
2477
-'
2478
-
2479
-test_expect_success '#17.2: at root' '
2480
- cat >17/expected <<EOF &&
2481
-setup: git_dir: .git
2482
-setup: worktree: (null)
2483
-setup: cwd: $here/17
2484
-setup: prefix: (null)
2485
-EOF
2486
- test_repo 17
2487
-'
2488
-
2489
-test_expect_success '#17.2: in subdir' '
2490
- cat >17/sub/expected <<EOF &&
2491
-setup: git_dir: $here/17/.git
2492
-setup: worktree: (null)
2493
-setup: cwd: $here/17/sub
2494
-setup: prefix: (null)
2495
-EOF
2496
- test_repo 17/sub
2497
-'
2498
-
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
-
2520
-test_expect_success '#18: setup' '
2521
- sane_unset GIT_DIR GIT_WORK_TREE &&
2522
- mkdir 18 18/sub &&
2523
- cd 18 &&
2524
- git init &&
2525
- mkdir .git/wt .git/wt/sub &&
2526
- git config core.bare true &&
2527
- cd ..
2528
-'
2529
-
2530
-test_expect_success '#18: (rel) at root' '
2531
- cat >18/expected <<EOF &&
2532
-setup: git_dir: .git
2533
-setup: worktree: (null)
2534
-setup: cwd: $here/18
2535
-setup: prefix: (null)
2536
-EOF
2537
- test_repo 18 .git
2538
-'
2539
-
2540
-test_expect_success '#18: at root' '
2541
- cat >18/expected <<EOF &&
2542
-setup: git_dir: $here/18/.git
2543
-setup: worktree: (null)
2544
-setup: cwd: $here/18
2545
-setup: prefix: (null)
2546
-EOF
2547
- test_repo 18 "$here/18/.git"
2548
-'
2549
-
2550
-test_expect_success '#18: (rel) in subdir' '
2551
- cat >18/sub/expected <<EOF &&
2552
-setup: git_dir: ../.git
2553
-setup: worktree: (null)
2554
-setup: cwd: $here/18/sub
2555
-setup: prefix: (null)
2556
-EOF
2557
- test_repo 18/sub ../.git
2558
-'
2559
-
2560
-test_expect_success '#18: in subdir' '
2561
- cat >18/sub/expected <<EOF &&
2562
-setup: git_dir: $here/18/.git
2563
-setup: worktree: (null)
2564
-setup: cwd: $here/18/sub
2565
-setup: prefix: (null)
2566
-EOF
2567
- test_repo 18/sub "$here/18/.git"
2568
-'
2569
-
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
-
2587
-test_expect_success '#19: setup' '
2588
- sane_unset GIT_DIR GIT_WORK_TREE &&
2589
- mkdir 19 19/sub 19/sub/sub 19.wt 19.wt/sub 19/wt 19/wt/sub &&
2590
- cd 19 &&
2591
- git init &&
2592
- git config core.bare true &&
2593
- cd ..
2594
-'
2595
-
2596
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
2597
- cat >19/expected <<EOF &&
2598
-setup: git_dir: .git
2599
-setup: worktree: $here/19
2600
-setup: cwd: $here/19
2601
-setup: prefix: (null)
2602
-EOF
2603
- test_repo 19 .git "$here/19"
2604
-'
2605
-
2606
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
2607
- cat >19/expected <<EOF &&
2608
-setup: git_dir: .git
2609
-setup: worktree: $here/19
2610
-setup: cwd: $here/19
2611
-setup: prefix: (null)
2612
-EOF
2613
- test_repo 19 .git .
2614
-'
2615
-
2616
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=root at root' '
2617
- cat >19/expected <<EOF &&
2618
-setup: git_dir: $here/19/.git
2619
-setup: worktree: $here/19
2620
-setup: cwd: $here/19
2621
-setup: prefix: (null)
2622
-EOF
2623
- test_repo 19 "$here/19/.git" "$here/19"
2624
-'
2625
-
2626
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
2627
- cat >19/expected <<EOF &&
2628
-setup: git_dir: $here/19/.git
2629
-setup: worktree: $here/19
2630
-setup: cwd: $here/19
2631
-setup: prefix: (null)
2632
-EOF
2633
- test_repo 19 "$here/19/.git" .
2634
-'
2635
-
2636
-test_expect_success '#19: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
2637
- cat >19/sub/sub/expected <<EOF &&
2638
-setup: git_dir: $here/19/.git
2639
-setup: worktree: $here/19
2640
-setup: cwd: $here/19
2641
-setup: prefix: sub/sub/
2642
-EOF
2643
- test_repo 19/sub/sub ../../.git "$here/19"
2644
-'
2645
-
2646
-test_expect_success '#19: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
2647
- cat >19/sub/sub/expected <<EOF &&
2648
-setup: git_dir: $here/19/.git
2649
-setup: worktree: $here/19
2650
-setup: cwd: $here/19
2651
-setup: prefix: sub/sub/
2652
-EOF
2653
- test_repo 19/sub/sub ../../.git ../..
2654
-'
2655
-
2656
-test_expect_success '#19: GIT_DIR, GIT_WORKTREE=root in subdir' '
2657
- cat >19/sub/expected <<EOF &&
2658
-setup: git_dir: $here/19/.git
2659
-setup: worktree: $here/19
2660
-setup: cwd: $here/19
2661
-setup: prefix: sub/
2662
-EOF
2663
- test_repo 19/sub "$here/19/.git" "$here/19"
2664
-'
2665
-
2666
-test_expect_success '#19: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
2667
- cat >19/sub/sub/expected <<EOF &&
2668
-setup: git_dir: $here/19/.git
2669
-setup: worktree: $here/19
2670
-setup: cwd: $here/19
2671
-setup: prefix: sub/sub/
2672
-EOF
2673
- test_repo 19/sub/sub "$here/19/.git" ../..
2674
-'
2675
-
2676
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
2677
- cat >19/expected <<EOF &&
2678
-setup: git_dir: .git
2679
-setup: worktree: $here/19/wt
2680
-setup: cwd: $here/19
2681
-setup: prefix: (null)
2682
-EOF
2683
- test_repo 19 .git "$here/19/wt"
2684
-'
2685
-
2686
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
2687
- cat >19/expected <<EOF &&
2688
-setup: git_dir: .git
2689
-setup: worktree: $here/19/wt
2690
-setup: cwd: $here/19
2691
-setup: prefix: (null)
2692
-EOF
2693
- test_repo 19 .git wt
2694
-'
2695
-
2696
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
2697
- cat >19/expected <<EOF &&
2698
-setup: git_dir: $here/19/.git
2699
-setup: worktree: $here/19/wt
2700
-setup: cwd: $here/19
2701
-setup: prefix: (null)
2702
-EOF
2703
- test_repo 19 "$here/19/.git" wt
2704
-'
2705
-
2706
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=wt at root' '
2707
- cat >19/expected <<EOF &&
2708
-setup: git_dir: $here/19/.git
2709
-setup: worktree: $here/19/wt
2710
-setup: cwd: $here/19
2711
-setup: prefix: (null)
2712
-EOF
2713
- test_repo 19 "$here/19/.git" "$here/19/wt"
2714
-'
2715
-
2716
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
2717
- cat >19/sub/sub/expected <<EOF &&
2718
-setup: git_dir: ../../.git
2719
-setup: worktree: $here/19/wt
2720
-setup: cwd: $here/19/sub/sub
2721
-setup: prefix: (null)
2722
-EOF
2723
- test_repo 19/sub/sub ../../.git "$here/19/wt"
2724
-'
2725
-
2726
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
2727
- cat >19/sub/sub/expected <<EOF &&
2728
-setup: git_dir: ../../.git
2729
-setup: worktree: $here/19/wt
2730
-setup: cwd: $here/19/sub/sub
2731
-setup: prefix: (null)
2732
-EOF
2733
- test_repo 19/sub/sub ../../.git ../../wt
2734
-'
2735
-
2736
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
2737
- cat >19/sub/sub/expected <<EOF &&
2738
-setup: git_dir: $here/19/.git
2739
-setup: worktree: $here/19/wt
2740
-setup: cwd: $here/19/sub/sub
2741
-setup: prefix: (null)
2742
-EOF
2743
- test_repo 19/sub/sub "$here/19/.git" ../../wt
2744
-'
2745
-
2746
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
2747
- cat >19/sub/sub/expected <<EOF &&
2748
-setup: git_dir: $here/19/.git
2749
-setup: worktree: $here/19/wt
2750
-setup: cwd: $here/19/sub/sub
2751
-setup: prefix: (null)
2752
-EOF
2753
- test_repo 19/sub/sub "$here/19/.git" "$here/19/wt"
2754
-'
2755
-
2756
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
2757
- cat >19/expected <<EOF &&
2758
-setup: git_dir: $here/19/.git
2759
-setup: worktree: $here
2760
-setup: cwd: $here
2761
-setup: prefix: 19/
2762
-EOF
2763
- test_repo 19 .git "$here"
2764
-'
2765
-
2766
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
2767
- cat >19/expected <<EOF &&
2768
-setup: git_dir: $here/19/.git
2769
-setup: worktree: $here
2770
-setup: cwd: $here
2771
-setup: prefix: 19/
2772
-EOF
2773
- test_repo 19 .git ..
2774
-'
2775
-
2776
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
2777
- cat >19/expected <<EOF &&
2778
-setup: git_dir: $here/19/.git
2779
-setup: worktree: $here
2780
-setup: cwd: $here
2781
-setup: prefix: 19/
2782
-EOF
2783
- test_repo 19 "$here/19/.git" ..
2784
-'
2785
-
2786
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=.. at root' '
2787
- cat >19/expected <<EOF &&
2788
-setup: git_dir: $here/19/.git
2789
-setup: worktree: $here
2790
-setup: cwd: $here
2791
-setup: prefix: 19/
2792
-EOF
2793
- test_repo 19 "$here/19/.git" "$here"
2794
-'
2795
-
2796
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
2797
- cat >19/sub/sub/expected <<EOF &&
2798
-setup: git_dir: $here/19/.git
2799
-setup: worktree: $here
2800
-setup: cwd: $here
2801
-setup: prefix: 19/sub/sub/
2802
-EOF
2803
- test_repo 19/sub/sub ../../.git "$here"
2804
-'
2805
-
2806
-test_expect_success '#19: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
2807
- cat >19/sub/sub/expected <<EOF &&
2808
-setup: git_dir: $here/19/.git
2809
-setup: worktree: $here
2810
-setup: cwd: $here
2811
-setup: prefix: 19/sub/sub/
2812
-EOF
2813
- test_repo 19/sub/sub ../../.git ../../..
2814
-'
2815
-
2816
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
2817
- cat >19/sub/sub/expected <<EOF &&
2818
-setup: git_dir: $here/19/.git
2819
-setup: worktree: $here
2820
-setup: cwd: $here
2821
-setup: prefix: 19/sub/sub/
2822
-EOF
2823
- test_repo 19/sub/sub "$here/19/.git" ../../../
2824
-'
2825
-
2826
-test_expect_success '#19: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
2827
- cat >19/sub/sub/expected <<EOF &&
2828
-setup: git_dir: $here/19/.git
2829
-setup: worktree: $here
2830
-setup: cwd: $here
2831
-setup: prefix: 19/sub/sub/
2832
-EOF
2833
- test_repo 19/sub/sub "$here/19/.git" "$here"
2834
-'
2835
-
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
-
2853
-test_expect_success '#20.1: setup' '
2854
- sane_unset GIT_DIR GIT_WORK_TREE &&
2855
- mkdir 20 20/sub &&
2856
- cd 20 &&
2857
- git init &&
2858
- git config core.worktree non-existent &&
2859
- mkdir .git/wt .git/wt/sub &&
2860
- cd ..
2861
-'
2862
-
2863
-test_expect_success '#20.1: at .git' '
2864
- cat >20/.git/expected <<EOF &&
2865
-setup: git_dir: .
2866
-setup: worktree: (null)
2867
-setup: cwd: $here/20/.git
2868
-setup: prefix: (null)
2869
-EOF
2870
- test_repo 20/.git
2871
-'
2872
-
2873
-test_expect_success '#20.1: in .git/wt' '
2874
- cat >20/.git/wt/expected <<EOF &&
2875
-setup: git_dir: $here/20/.git
2876
-setup: worktree: (null)
2877
-setup: cwd: $here/20/.git/wt
2878
-setup: prefix: (null)
2879
-EOF
2880
- test_repo 20/.git/wt
2881
-'
2882
-
2883
-test_expect_success '#20.1: in .git/wt/sub' '
2884
- cat >20/.git/wt/sub/expected <<EOF &&
2885
-setup: git_dir: $here/20/.git
2886
-setup: worktree: (null)
2887
-setup: cwd: $here/20/.git/wt/sub
2888
-setup: prefix: (null)
2889
-EOF
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
-
2910
-test_expect_success '#20.2: setup' '
2911
- git config --file="$here/20/.git/config" core.bare true
2912
-'
2913
-
2914
-test_expect_success '#20.2: at .git' '
2915
- cat >20/.git/expected <<EOF &&
2916
-setup: git_dir: .
2917
-setup: worktree: (null)
2918
-setup: cwd: $here/20/.git
2919
-setup: prefix: (null)
2920
-EOF
2921
- test_repo 20/.git
2922
-'
2923
-
2924
-test_expect_success '#20.2: in .git/wt' '
2925
- cat >20/.git/wt/expected <<EOF &&
2926
-setup: git_dir: $here/20/.git
2927
-setup: worktree: (null)
2928
-setup: cwd: $here/20/.git/wt
2929
-setup: prefix: (null)
2930
-EOF
2931
- test_repo 20/.git/wt
2932
-'
2933
-
2934
-test_expect_success '#20.2: in .git/wt/sub' '
2935
- cat >20/.git/wt/sub/expected <<EOF &&
2936
-setup: git_dir: $here/20/.git
2937
-setup: worktree: (null)
2938
-setup: cwd: $here/20/.git/wt/sub
2939
-setup: prefix: (null)
2940
-EOF
2941
- test_repo 20/.git/wt/sub
2942
-'
2943
-
2944
-test_expect_success '#20.2: at root' '
2945
- cat >20/expected <<EOF &&
2946
-setup: git_dir: .git
2947
-setup: worktree: (null)
2948
-setup: cwd: $here/20
2949
-setup: prefix: (null)
2950
-EOF
2951
- test_repo 20
2952
-'
2953
-
2954
-test_expect_success '#20.2: in subdir' '
2955
- cat >20/sub/expected <<EOF &&
2956
-setup: git_dir: $here/20/.git
2957
-setup: worktree: (null)
2958
-setup: cwd: $here/20/sub
2959
-setup: prefix: (null)
2960
-EOF
2961
- test_repo 20/sub
2962
-'
2963
-
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
-
2981
-test_expect_success '#21.1: setup' '
2982
- sane_unset GIT_DIR GIT_WORK_TREE &&
2983
- mkdir 21 21/sub &&
2984
- cd 21 &&
2985
- git init &&
2986
- git config core.worktree non-existent &&
2987
- GIT_WORK_TREE=non-existent-too &&
2988
- export GIT_WORK_TREE &&
2989
- mkdir .git/wt .git/wt/sub &&
2990
- cd ..
2991
-'
2992
-
2993
-test_expect_success '#21.1: at .git' '
2994
- cat >21/.git/expected <<EOF &&
2995
-setup: git_dir: .
2996
-setup: worktree: (null)
2997
-setup: cwd: $here/21/.git
2998
-setup: prefix: (null)
2999
-EOF
3000
- test_repo 21/.git
3001
-'
3002
-
3003
-test_expect_success '#21.1: in .git/wt' '
3004
- cat >21/.git/wt/expected <<EOF &&
3005
-setup: git_dir: $here/21/.git
3006
-setup: worktree: (null)
3007
-setup: cwd: $here/21/.git/wt
3008
-setup: prefix: (null)
3009
-EOF
3010
- test_repo 21/.git/wt
3011
-'
3012
-
3013
-test_expect_success '#21.1: in .git/wt/sub' '
3014
- cat >21/.git/wt/sub/expected <<EOF &&
3015
-setup: git_dir: $here/21/.git
3016
-setup: worktree: (null)
3017
-setup: cwd: $here/21/.git/wt/sub
3018
-setup: prefix: (null)
3019
-EOF
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
-
3040
-test_expect_success '#21.2: setup' '
3041
- git config --file="$here/21/.git/config" core.bare true
3042
-'
3043
-
3044
-test_expect_success '#21.2: at .git' '
3045
- cat >21/.git/expected <<EOF &&
3046
-setup: git_dir: .
3047
-setup: worktree: (null)
3048
-setup: cwd: $here/21/.git
3049
-setup: prefix: (null)
3050
-EOF
3051
- test_repo 21/.git
3052
-'
3053
-
3054
-test_expect_success '#21.2: in .git/wt' '
3055
- cat >21/.git/wt/expected <<EOF &&
3056
-setup: git_dir: $here/21/.git
3057
-setup: worktree: (null)
3058
-setup: cwd: $here/21/.git/wt
3059
-setup: prefix: (null)
3060
-EOF
3061
- test_repo 21/.git/wt
3062
-'
3063
-
3064
-test_expect_success '#21.2: in .git/wt/sub' '
3065
- cat >21/.git/wt/sub/expected <<EOF &&
3066
-setup: git_dir: $here/21/.git
3067
-setup: worktree: (null)
3068
-setup: cwd: $here/21/.git/wt/sub
3069
-setup: prefix: (null)
3070
-EOF
3071
- test_repo 21/.git/wt/sub
3072
-'
3073
-
3074
-test_expect_success '#21.2: at root' '
3075
- cat >21/expected <<EOF &&
3076
-setup: git_dir: .git
3077
-setup: worktree: (null)
3078
-setup: cwd: $here/21
3079
-setup: prefix: (null)
3080
-EOF
3081
- test_repo 21
3082
-'
3083
-
3084
-test_expect_success '#21.2: in subdir' '
3085
- cat >21/sub/expected <<EOF &&
3086
-setup: git_dir: $here/21/.git
3087
-setup: worktree: (null)
3088
-setup: cwd: $here/21/sub
3089
-setup: prefix: (null)
3090
-EOF
3091
- test_repo 21/sub
3092
-'
3093
-
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
-
3117
-test_expect_success '#22.1: setup' '
3118
- sane_unset GIT_DIR GIT_WORK_TREE &&
3119
- mkdir 22 &&
3120
- cd 22 &&
3121
- git init &&
3122
- mkdir .git/sub .git/wt .git/wt/sub &&
3123
- cd ..
3124
-'
3125
-
3126
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=. at .git' '
3127
- cat >22/.git/expected <<EOF &&
3128
-setup: git_dir: .
3129
-setup: worktree: $here/22/.git
3130
-setup: cwd: $here/22/.git
3131
-setup: prefix: (null)
3132
-EOF
3133
- git config --file="$here/22/.git/config" core.worktree "$here/22/.git" &&
3134
- test_repo 22/.git .
3135
-'
3136
-
3137
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=.(rel) at .git' '
3138
- cat >22/.git/expected <<EOF &&
3139
-setup: git_dir: .
3140
-setup: worktree: $here/22/.git
3141
-setup: cwd: $here/22/.git
3142
-setup: prefix: (null)
3143
-EOF
3144
- git config --file="$here/22/.git/config" core.worktree . &&
3145
- test_repo 22/.git .
3146
-'
3147
-
3148
-test_expect_success '#22.1: GIT_DIR, core.worktree=. at .git' '
3149
- cat >22/.git/expected <<EOF &&
3150
-setup: git_dir: $here/22/.git
3151
-setup: worktree: $here/22/.git
3152
-setup: cwd: $here/22/.git
3153
-setup: prefix: (null)
3154
-EOF
3155
- git config --file="$here/22/.git/config" core.worktree "$here/22/.git" &&
3156
- test_repo 22/.git "$here/22/.git"
3157
-'
3158
-
3159
-test_expect_success '#22.1: GIT_DIR, core.worktree=.(rel) at root' '
3160
- cat >22/.git/expected <<EOF &&
3161
-setup: git_dir: $here/22/.git
3162
-setup: worktree: $here/22/.git
3163
-setup: cwd: $here/22/.git
3164
-setup: prefix: (null)
3165
-EOF
3166
- git config --file="$here/22/.git/config" core.worktree . &&
3167
- test_repo 22/.git "$here/22/.git"
3168
-'
3169
-
3170
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=. in .git/sub' '
3171
- cat >22/.git/sub/expected <<EOF &&
3172
-setup: git_dir: $here/22/.git
3173
-setup: worktree: $here/22/.git
3174
-setup: cwd: $here/22/.git
3175
-setup: prefix: sub/
3176
-EOF
3177
- git config --file="$here/22/.git/config" core.worktree "$here/22/.git" &&
3178
- test_repo 22/.git/sub ..
3179
-'
3180
-
3181
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=.(rel) in .git/sub' '
3182
- cat >22/.git/sub/expected <<EOF &&
3183
-setup: git_dir: $here/22/.git
3184
-setup: worktree: $here/22/.git
3185
-setup: cwd: $here/22/.git
3186
-setup: prefix: sub/
3187
-EOF
3188
- git config --file="$here/22/.git/config" core.worktree . &&
3189
- test_repo 22/.git/sub/ ..
3190
-'
3191
-
3192
-test_expect_success '#22.1: GIT_DIR, core.worktree=. in .git/sub' '
3193
- cat >22/.git/sub/expected <<EOF &&
3194
-setup: git_dir: $here/22/.git
3195
-setup: worktree: $here/22/.git
3196
-setup: cwd: $here/22/.git
3197
-setup: prefix: sub/
3198
-EOF
3199
- git config --file="$here/22/.git/config" core.worktree "$here/22/.git" &&
3200
- test_repo 22/.git/sub "$here/22/.git"
3201
-'
3202
-
3203
-test_expect_success '#22.1: GIT_DIR, core.worktree=.(rel) in .git/sub' '
3204
- cat >22/.git/sub/expected <<EOF &&
3205
-setup: git_dir: $here/22/.git
3206
-setup: worktree: $here/22/.git
3207
-setup: cwd: $here/22/.git
3208
-setup: prefix: sub/
3209
-EOF
3210
- git config --file="$here/22/.git/config" core.worktree . &&
3211
- test_repo 22/.git/sub "$here/22/.git"
3212
-'
3213
-
3214
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=wt at .git' '
3215
- cat >22/.git/expected <<EOF &&
3216
-setup: git_dir: .
3217
-setup: worktree: $here/22/.git/wt
3218
-setup: cwd: $here/22/.git
3219
-setup: prefix: (null)
3220
-EOF
3221
- git config --file="$here/22/.git/config" core.worktree "$here/22/.git/wt" &&
3222
- test_repo 22/.git .
3223
-'
3224
-
3225
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=wt(rel) at .git' '
3226
- cat >22/.git/expected <<EOF &&
3227
-setup: git_dir: .
3228
-setup: worktree: $here/22/.git/wt
3229
-setup: cwd: $here/22/.git
3230
-setup: prefix: (null)
3231
-EOF
3232
- git config --file="$here/22/.git/config" core.worktree wt &&
3233
- test_repo 22/.git .
3234
-'
3235
-
3236
-test_expect_success '#22.1: GIT_DIR, core.worktree=wt(rel) at .git' '
3237
- cat >22/.git/expected <<EOF &&
3238
-setup: git_dir: $here/22/.git
3239
-setup: worktree: $here/22/.git/wt
3240
-setup: cwd: $here/22/.git
3241
-setup: prefix: (null)
3242
-EOF
3243
- git config --file="$here/22/.git/config" core.worktree wt &&
3244
- test_repo 22/.git "$here/22/.git"
3245
-'
3246
-
3247
-test_expect_success '#22.1: GIT_DIR, core.worktree=wt at .git' '
3248
- cat >22/.git/expected <<EOF &&
3249
-setup: git_dir: $here/22/.git
3250
-setup: worktree: $here/22/.git/wt
3251
-setup: cwd: $here/22/.git
3252
-setup: prefix: (null)
3253
-EOF
3254
- git config --file="$here/22/.git/config" core.worktree "$here/22/.git/wt" &&
3255
- test_repo 22/.git "$here/22/.git"
3256
-'
3257
-
3258
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=wt in .git/sub' '
3259
- cat >22/.git/sub/expected <<EOF &&
3260
-setup: git_dir: ..
3261
-setup: worktree: $here/22/.git/wt
3262
-setup: cwd: $here/22/.git/sub
3263
-setup: prefix: (null)
3264
-EOF
3265
- git config --file="$here/22/.git/config" core.worktree "$here/22/.git/wt" &&
3266
- test_repo 22/.git/sub ..
3267
-'
3268
-
3269
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=wt(rel) in .git/sub' '
3270
- cat >22/.git/sub/expected <<EOF &&
3271
-setup: git_dir: ..
3272
-setup: worktree: $here/22/.git/wt
3273
-setup: cwd: $here/22/.git/sub
3274
-setup: prefix: (null)
3275
-EOF
3276
- git config --file="$here/22/.git/config" core.worktree wt &&
3277
- test_repo 22/.git/sub ..
3278
-'
3279
-
3280
-test_expect_success '#22.1: GIT_DIR, core.worktree=wt(rel) in .git/sub' '
3281
- cat >22/.git/sub/expected <<EOF &&
3282
-setup: git_dir: $here/22/.git
3283
-setup: worktree: $here/22/.git/wt
3284
-setup: cwd: $here/22/.git/sub
3285
-setup: prefix: (null)
3286
-EOF
3287
- git config --file="$here/22/.git/config" core.worktree wt &&
3288
- test_repo 22/.git/sub "$here/22/.git"
3289
-'
3290
-
3291
-test_expect_success '#22.1: GIT_DIR, core.worktree=wt in .git/sub' '
3292
- cat >22/.git/sub/expected <<EOF &&
3293
-setup: git_dir: $here/22/.git
3294
-setup: worktree: $here/22/.git/wt
3295
-setup: cwd: $here/22/.git/sub
3296
-setup: prefix: (null)
3297
-EOF
3298
- git config --file="$here/22/.git/config" core.worktree "$here/22/.git/wt" &&
3299
- test_repo 22/.git/sub "$here/22/.git"
3300
-'
3301
-
3302
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=.. at .git' '
3303
- cat >22/.git/expected <<EOF &&
3304
-setup: git_dir: $here/22/.git
3305
-setup: worktree: $here/22
3306
-setup: cwd: $here/22
3307
-setup: prefix: .git/
3308
-EOF
3309
- git config --file="$here/22/.git/config" core.worktree "$here/22" &&
3310
- test_repo 22/.git .
3311
-'
3312
-
3313
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=..(rel) at .git' '
3314
- cat >22/.git/expected <<EOF &&
3315
-setup: git_dir: $here/22/.git
3316
-setup: worktree: $here/22
3317
-setup: cwd: $here/22
3318
-setup: prefix: .git/
3319
-EOF
3320
- git config --file="$here/22/.git/config" core.worktree .. &&
3321
- test_repo 22/.git .
3322
-'
3323
-
3324
-test_expect_success '#22.1: GIT_DIR, core.worktree=..(rel) at .git' '
3325
- cat >22/.git/expected <<EOF &&
3326
-setup: git_dir: $here/22/.git
3327
-setup: worktree: $here/22
3328
-setup: cwd: $here/22
3329
-setup: prefix: .git/
3330
-EOF
3331
- git config --file="$here/22/.git/config" core.worktree .. &&
3332
- test_repo 22/.git "$here/22/.git"
3333
-'
3334
-
3335
-test_expect_success '#22.1: GIT_DIR, core.worktree=.. at .git' '
3336
- cat >22/.git/expected <<EOF &&
3337
-setup: git_dir: $here/22/.git
3338
-setup: worktree: $here/22
3339
-setup: cwd: $here/22
3340
-setup: prefix: .git/
3341
-EOF
3342
- git config --file="$here/22/.git/config" core.worktree "$here/22" &&
3343
- test_repo 22/.git "$here/22/.git"
3344
-'
3345
-
3346
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=.. in .git/sub' '
3347
- cat >22/.git/sub/expected <<EOF &&
3348
-setup: git_dir: $here/22/.git
3349
-setup: worktree: $here/22
3350
-setup: cwd: $here/22
3351
-setup: prefix: .git/sub/
3352
-EOF
3353
- git config --file="$here/22/.git/config" core.worktree "$here/22" &&
3354
- test_repo 22/.git/sub ..
3355
-'
3356
-
3357
-test_expect_success '#22.1: GIT_DIR(rel), core.worktree=..(rel) in .git/sub' '
3358
- cat >22/.git/sub/expected <<EOF &&
3359
-setup: git_dir: $here/22/.git
3360
-setup: worktree: $here/22
3361
-setup: cwd: $here/22
3362
-setup: prefix: .git/sub/
3363
-EOF
3364
- git config --file="$here/22/.git/config" core.worktree .. &&
3365
- test_repo 22/.git/sub ..
3366
-'
3367
-
3368
-test_expect_success '#22.1: GIT_DIR, core.worktree=..(rel) in .git/sub' '
3369
- cat >22/.git/sub/expected <<EOF &&
3370
-setup: git_dir: $here/22/.git
3371
-setup: worktree: $here/22
3372
-setup: cwd: $here/22
3373
-setup: prefix: .git/sub/
3374
-EOF
3375
- git config --file="$here/22/.git/config" core.worktree .. &&
3376
- test_repo 22/.git/sub "$here/22/.git"
3377
-'
3378
-
3379
-test_expect_success '#22.1: GIT_DIR, core.worktree=.. in .git/sub' '
3380
- cat >22/.git/sub/expected <<EOF &&
3381
-setup: git_dir: $here/22/.git
3382
-setup: worktree: $here/22
3383
-setup: cwd: $here/22
3384
-setup: prefix: .git/sub/
3385
-EOF
3386
- git config --file="$here/22/.git/config" core.worktree "$here/22" &&
3387
- test_repo 22/.git/sub "$here/22/.git"
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
-
3407
-test_expect_success '#22.2: setup' '
3408
- git config --file="$here/22/.git/config" core.bare true
3409
-'
3410
-
3411
-test_expect_success '#22.2: at .git' '
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
-
3421
-test_expect_success '#22.2: at root' '
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
-
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
-
3448
-test_expect_success '#23: setup' '
3449
- sane_unset GIT_DIR GIT_WORK_TREE &&
3450
- mkdir 23 23/sub 23/sub/sub 23.wt 23.wt/sub 23/wt 23/wt/sub &&
3451
- cd 23 &&
3452
- git init &&
3453
- git config core.bare true &&
3454
- git config core.worktree non-existent &&
3455
- cd ..
3456
-'
3457
-
3458
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
3459
- cat >23/expected <<EOF &&
3460
-setup: git_dir: .git
3461
-setup: worktree: $here/23
3462
-setup: cwd: $here/23
3463
-setup: prefix: (null)
3464
-EOF
3465
- test_repo 23 .git "$here/23"
3466
-'
3467
-
3468
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
3469
- cat >23/expected <<EOF &&
3470
-setup: git_dir: .git
3471
-setup: worktree: $here/23
3472
-setup: cwd: $here/23
3473
-setup: prefix: (null)
3474
-EOF
3475
- test_repo 23 .git .
3476
-'
3477
-
3478
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=root at root' '
3479
- cat >23/expected <<EOF &&
3480
-setup: git_dir: $here/23/.git
3481
-setup: worktree: $here/23
3482
-setup: cwd: $here/23
3483
-setup: prefix: (null)
3484
-EOF
3485
- test_repo 23 "$here/23/.git" "$here/23"
3486
-'
3487
-
3488
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
3489
- cat >23/expected <<EOF &&
3490
-setup: git_dir: $here/23/.git
3491
-setup: worktree: $here/23
3492
-setup: cwd: $here/23
3493
-setup: prefix: (null)
3494
-EOF
3495
- test_repo 23 "$here/23/.git" .
3496
-'
3497
-
3498
-test_expect_success '#23: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
3499
- cat >23/sub/sub/expected <<EOF &&
3500
-setup: git_dir: $here/23/.git
3501
-setup: worktree: $here/23
3502
-setup: cwd: $here/23
3503
-setup: prefix: sub/sub/
3504
-EOF
3505
- test_repo 23/sub/sub ../../.git "$here/23"
3506
-'
3507
-
3508
-test_expect_success '#23: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
3509
- cat >23/sub/sub/expected <<EOF &&
3510
-setup: git_dir: $here/23/.git
3511
-setup: worktree: $here/23
3512
-setup: cwd: $here/23
3513
-setup: prefix: sub/sub/
3514
-EOF
3515
- test_repo 23/sub/sub ../../.git ../..
3516
-'
3517
-
3518
-test_expect_success '#23: GIT_DIR, GIT_WORKTREE=root in subdir' '
3519
- cat >23/sub/expected <<EOF &&
3520
-setup: git_dir: $here/23/.git
3521
-setup: worktree: $here/23
3522
-setup: cwd: $here/23
3523
-setup: prefix: sub/
3524
-EOF
3525
- test_repo 23/sub "$here/23/.git" "$here/23"
3526
-'
3527
-
3528
-test_expect_success '#23: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
3529
- cat >23/sub/sub/expected <<EOF &&
3530
-setup: git_dir: $here/23/.git
3531
-setup: worktree: $here/23
3532
-setup: cwd: $here/23
3533
-setup: prefix: sub/sub/
3534
-EOF
3535
- test_repo 23/sub/sub "$here/23/.git" ../..
3536
-'
3537
-
3538
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
3539
- cat >23/expected <<EOF &&
3540
-setup: git_dir: .git
3541
-setup: worktree: $here/23/wt
3542
-setup: cwd: $here/23
3543
-setup: prefix: (null)
3544
-EOF
3545
- test_repo 23 .git "$here/23/wt"
3546
-'
3547
-
3548
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
3549
- cat >23/expected <<EOF &&
3550
-setup: git_dir: .git
3551
-setup: worktree: $here/23/wt
3552
-setup: cwd: $here/23
3553
-setup: prefix: (null)
3554
-EOF
3555
- test_repo 23 .git wt
3556
-'
3557
-
3558
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
3559
- cat >23/expected <<EOF &&
3560
-setup: git_dir: $here/23/.git
3561
-setup: worktree: $here/23/wt
3562
-setup: cwd: $here/23
3563
-setup: prefix: (null)
3564
-EOF
3565
- test_repo 23 "$here/23/.git" wt
3566
-'
3567
-
3568
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt at root' '
3569
- cat >23/expected <<EOF &&
3570
-setup: git_dir: $here/23/.git
3571
-setup: worktree: $here/23/wt
3572
-setup: cwd: $here/23
3573
-setup: prefix: (null)
3574
-EOF
3575
- test_repo 23 "$here/23/.git" "$here/23/wt"
3576
-'
3577
-
3578
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
3579
- cat >23/sub/sub/expected <<EOF &&
3580
-setup: git_dir: ../../.git
3581
-setup: worktree: $here/23/wt
3582
-setup: cwd: $here/23/sub/sub
3583
-setup: prefix: (null)
3584
-EOF
3585
- test_repo 23/sub/sub ../../.git "$here/23/wt"
3586
-'
3587
-
3588
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
3589
- cat >23/sub/sub/expected <<EOF &&
3590
-setup: git_dir: ../../.git
3591
-setup: worktree: $here/23/wt
3592
-setup: cwd: $here/23/sub/sub
3593
-setup: prefix: (null)
3594
-EOF
3595
- test_repo 23/sub/sub ../../.git ../../wt
3596
-'
3597
-
3598
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
3599
- cat >23/sub/sub/expected <<EOF &&
3600
-setup: git_dir: $here/23/.git
3601
-setup: worktree: $here/23/wt
3602
-setup: cwd: $here/23/sub/sub
3603
-setup: prefix: (null)
3604
-EOF
3605
- test_repo 23/sub/sub "$here/23/.git" ../../wt
3606
-'
3607
-
3608
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
3609
- cat >23/sub/sub/expected <<EOF &&
3610
-setup: git_dir: $here/23/.git
3611
-setup: worktree: $here/23/wt
3612
-setup: cwd: $here/23/sub/sub
3613
-setup: prefix: (null)
3614
-EOF
3615
- test_repo 23/sub/sub "$here/23/.git" "$here/23/wt"
3616
-'
3617
-
3618
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
3619
- cat >23/expected <<EOF &&
3620
-setup: git_dir: $here/23/.git
3621
-setup: worktree: $here
3622
-setup: cwd: $here
3623
-setup: prefix: 23/
3624
-EOF
3625
- test_repo 23 .git "$here"
3626
-'
3627
-
3628
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
3629
- cat >23/expected <<EOF &&
3630
-setup: git_dir: $here/23/.git
3631
-setup: worktree: $here
3632
-setup: cwd: $here
3633
-setup: prefix: 23/
3634
-EOF
3635
- test_repo 23 .git ..
3636
-'
3637
-
3638
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
3639
- cat >23/expected <<EOF &&
3640
-setup: git_dir: $here/23/.git
3641
-setup: worktree: $here
3642
-setup: cwd: $here
3643
-setup: prefix: 23/
3644
-EOF
3645
- test_repo 23 "$here/23/.git" ..
3646
-'
3647
-
3648
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=.. at root' '
3649
- cat >23/expected <<EOF &&
3650
-setup: git_dir: $here/23/.git
3651
-setup: worktree: $here
3652
-setup: cwd: $here
3653
-setup: prefix: 23/
3654
-EOF
3655
- test_repo 23 "$here/23/.git" "$here"
3656
-'
3657
-
3658
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
3659
- cat >23/sub/sub/expected <<EOF &&
3660
-setup: git_dir: $here/23/.git
3661
-setup: worktree: $here
3662
-setup: cwd: $here
3663
-setup: prefix: 23/sub/sub/
3664
-EOF
3665
- test_repo 23/sub/sub ../../.git "$here"
3666
-'
3667
-
3668
-test_expect_success '#23: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
3669
- cat >23/sub/sub/expected <<EOF &&
3670
-setup: git_dir: $here/23/.git
3671
-setup: worktree: $here
3672
-setup: cwd: $here
3673
-setup: prefix: 23/sub/sub/
3674
-EOF
3675
- test_repo 23/sub/sub ../../.git ../../..
3676
-'
3677
-
3678
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
3679
- cat >23/sub/sub/expected <<EOF &&
3680
-setup: git_dir: $here/23/.git
3681
-setup: worktree: $here
3682
-setup: cwd: $here
3683
-setup: prefix: 23/sub/sub/
3684
-EOF
3685
- test_repo 23/sub/sub "$here/23/.git" ../../../
3686
-'
3687
-
3688
-test_expect_success '#23: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
3689
- cat >23/sub/sub/expected <<EOF &&
3690
-setup: git_dir: $here/23/.git
3691
-setup: worktree: $here
3692
-setup: cwd: $here
3693
-setup: prefix: 23/sub/sub/
3694
-EOF
3695
- test_repo 23/sub/sub "$here/23/.git" "$here"
3696
-'
3697
-
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
-
3715
-test_expect_success '#24: setup' '
3716
- sane_unset GIT_DIR GIT_WORK_TREE &&
3717
- mkdir 24 24/sub &&
3718
- cd 24 &&
3719
- git init &&
3720
- git config core.bare true &&
3721
- mv .git ../24.git &&
3722
- echo gitdir: ../24.git >.git &&
3723
- cd ..
3724
-'
3725
-
3726
-test_expect_success '#24: at root' '
3727
- cat >24/expected <<EOF &&
3728
-setup: git_dir: $here/24.git
3729
-setup: worktree: (null)
3730
-setup: cwd: $here/24
3731
-setup: prefix: (null)
3732
-EOF
3733
- test_repo 24
3734
-'
3735
-
3736
-test_expect_success '#24: in subdir' '
3737
- cat >24/sub/expected <<EOF &&
3738
-setup: git_dir: $here/24.git
3739
-setup: worktree: (null)
3740
-setup: cwd: $here/24/sub
3741
-setup: prefix: (null)
3742
-EOF
3743
- test_repo 24/sub
3744
-'
3745
-
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
-
3763
-test_expect_success '#25: setup' '
3764
- sane_unset GIT_DIR GIT_WORK_TREE &&
3765
- mkdir 25 25/sub &&
3766
- cd 25 &&
3767
- git init &&
3768
- git config core.bare true &&
3769
- GIT_WORK_TREE=non-existent &&
3770
- export GIT_WORK_TREE &&
3771
- mv .git ../25.git &&
3772
- echo gitdir: ../25.git >.git &&
3773
- cd ..
3774
-'
3775
-
3776
-test_expect_success '#25: at root' '
3777
- cat >25/expected <<EOF &&
3778
-setup: git_dir: $here/25.git
3779
-setup: worktree: (null)
3780
-setup: cwd: $here/25
3781
-setup: prefix: (null)
3782
-EOF
3783
- test_repo 25
3784
-'
3785
-
3786
-test_expect_success '#25: in subdir' '
3787
- cat >25/sub/expected <<EOF &&
3788
-setup: git_dir: $here/25.git
3789
-setup: worktree: (null)
3790
-setup: cwd: $here/25/sub
3791
-setup: prefix: (null)
3792
-EOF
3793
- test_repo 25/sub
3794
-'
3795
-
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
-
3813
-test_expect_success '#26: setup' '
3814
- sane_unset GIT_DIR GIT_WORK_TREE &&
3815
- mkdir 26 26/sub &&
3816
- cd 26 &&
3817
- git init &&
3818
- git config core.bare true &&
3819
- mv .git ../26.git &&
3820
- echo gitdir: ../26.git >.git &&
3821
- cd ..
3822
-'
3823
-
3824
-test_expect_success '#26: (rel) at root' '
3825
- cat >26/expected <<EOF &&
3826
-setup: git_dir: $here/26.git
3827
-setup: worktree: (null)
3828
-setup: cwd: $here/26
3829
-setup: prefix: (null)
3830
-EOF
3831
- test_repo 26 .git
3832
-'
3833
-
3834
-test_expect_success '#26: at root' '
3835
- cat >26/expected <<EOF &&
3836
-setup: git_dir: $here/26.git
3837
-setup: worktree: (null)
3838
-setup: cwd: $here/26
3839
-setup: prefix: (null)
3840
-EOF
3841
- test_repo 26 "$here/26/.git"
3842
-'
3843
-
3844
-test_expect_success '#26: (rel) in subdir' '
3845
- cat >26/sub/expected <<EOF &&
3846
-setup: git_dir: $here/26.git
3847
-setup: worktree: (null)
3848
-setup: cwd: $here/26/sub
3849
-setup: prefix: (null)
3850
-EOF
3851
- test_repo 26/sub ../.git
3852
-'
3853
-
3854
-test_expect_success '#26: in subdir' '
3855
- cat >26/sub/expected <<EOF &&
3856
-setup: git_dir: $here/26.git
3857
-setup: worktree: (null)
3858
-setup: cwd: $here/26/sub
3859
-setup: prefix: (null)
3860
-EOF
3861
- test_repo 26/sub "$here/26/.git"
3862
-'
3863
-
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
-
3881
-test_expect_success '#27: setup' '
3882
- sane_unset GIT_DIR GIT_WORK_TREE &&
3883
- mkdir 27 27/sub 27/sub/sub 27.wt 27.wt/sub 27/wt 27/wt/sub &&
3884
- cd 27 &&
3885
- git init &&
3886
- git config core.bare true &&
3887
- mv .git ../27.git &&
3888
- echo gitdir: ../27.git >.git &&
3889
- cd ..
3890
-'
3891
-
3892
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
3893
- cat >27/expected <<EOF &&
3894
-setup: git_dir: $here/27.git
3895
-setup: worktree: $here/27
3896
-setup: cwd: $here/27
3897
-setup: prefix: (null)
3898
-EOF
3899
- test_repo 27 .git "$here/27"
3900
-'
3901
-
3902
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
3903
- cat >27/expected <<EOF &&
3904
-setup: git_dir: $here/27.git
3905
-setup: worktree: $here/27
3906
-setup: cwd: $here/27
3907
-setup: prefix: (null)
3908
-EOF
3909
- test_repo 27 .git .
3910
-'
3911
-
3912
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=root at root' '
3913
- cat >27/expected <<EOF &&
3914
-setup: git_dir: $here/27.git
3915
-setup: worktree: $here/27
3916
-setup: cwd: $here/27
3917
-setup: prefix: (null)
3918
-EOF
3919
- test_repo 27 "$here/27/.git" "$here/27"
3920
-'
3921
-
3922
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
3923
- cat >27/expected <<EOF &&
3924
-setup: git_dir: $here/27.git
3925
-setup: worktree: $here/27
3926
-setup: cwd: $here/27
3927
-setup: prefix: (null)
3928
-EOF
3929
- test_repo 27 "$here/27/.git" .
3930
-'
3931
-
3932
-test_expect_success '#27: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
3933
- cat >27/sub/sub/expected <<EOF &&
3934
-setup: git_dir: $here/27.git
3935
-setup: worktree: $here/27
3936
-setup: cwd: $here/27
3937
-setup: prefix: sub/sub/
3938
-EOF
3939
- test_repo 27/sub/sub ../../.git "$here/27"
3940
-'
3941
-
3942
-test_expect_success '#27: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
3943
- cat >27/sub/sub/expected <<EOF &&
3944
-setup: git_dir: $here/27.git
3945
-setup: worktree: $here/27
3946
-setup: cwd: $here/27
3947
-setup: prefix: sub/sub/
3948
-EOF
3949
- test_repo 27/sub/sub ../../.git ../..
3950
-'
3951
-
3952
-test_expect_success '#27: GIT_DIR, GIT_WORKTREE=root in subdir' '
3953
- cat >27/sub/expected <<EOF &&
3954
-setup: git_dir: $here/27.git
3955
-setup: worktree: $here/27
3956
-setup: cwd: $here/27
3957
-setup: prefix: sub/
3958
-EOF
3959
- test_repo 27/sub "$here/27/.git" "$here/27"
3960
-'
3961
-
3962
-test_expect_success '#27: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
3963
- cat >27/sub/sub/expected <<EOF &&
3964
-setup: git_dir: $here/27.git
3965
-setup: worktree: $here/27
3966
-setup: cwd: $here/27
3967
-setup: prefix: sub/sub/
3968
-EOF
3969
- test_repo 27/sub/sub "$here/27/.git" ../..
3970
-'
3971
-
3972
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
3973
- cat >27/expected <<EOF &&
3974
-setup: git_dir: $here/27.git
3975
-setup: worktree: $here/27/wt
3976
-setup: cwd: $here/27
3977
-setup: prefix: (null)
3978
-EOF
3979
- test_repo 27 .git "$here/27/wt"
3980
-'
3981
-
3982
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
3983
- cat >27/expected <<EOF &&
3984
-setup: git_dir: $here/27.git
3985
-setup: worktree: $here/27/wt
3986
-setup: cwd: $here/27
3987
-setup: prefix: (null)
3988
-EOF
3989
- test_repo 27 .git wt
3990
-'
3991
-
3992
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
3993
- cat >27/expected <<EOF &&
3994
-setup: git_dir: $here/27.git
3995
-setup: worktree: $here/27/wt
3996
-setup: cwd: $here/27
3997
-setup: prefix: (null)
3998
-EOF
3999
- test_repo 27 "$here/27/.git" wt
4000
-'
4001
-
4002
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=wt at root' '
4003
- cat >27/expected <<EOF &&
4004
-setup: git_dir: $here/27.git
4005
-setup: worktree: $here/27/wt
4006
-setup: cwd: $here/27
4007
-setup: prefix: (null)
4008
-EOF
4009
- test_repo 27 "$here/27/.git" "$here/27/wt"
4010
-'
4011
-
4012
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
4013
- cat >27/sub/sub/expected <<EOF &&
4014
-setup: git_dir: $here/27.git
4015
-setup: worktree: $here/27/wt
4016
-setup: cwd: $here/27/sub/sub
4017
-setup: prefix: (null)
4018
-EOF
4019
- test_repo 27/sub/sub ../../.git "$here/27/wt"
4020
-'
4021
-
4022
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) in subdir' '
4023
- cat >27/sub/sub/expected <<EOF &&
4024
-setup: git_dir: $here/27.git
4025
-setup: worktree: $here/27/wt
4026
-setup: cwd: $here/27/sub/sub
4027
-setup: prefix: (null)
4028
-EOF
4029
- test_repo 27/sub/sub ../../.git ../../wt
4030
-'
4031
-
4032
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=wt(rel) in subdir' '
4033
- cat >27/sub/sub/expected <<EOF &&
4034
-setup: git_dir: $here/27.git
4035
-setup: worktree: $here/27/wt
4036
-setup: cwd: $here/27/sub/sub
4037
-setup: prefix: (null)
4038
-EOF
4039
- test_repo 27/sub/sub "$here/27/.git" ../../wt
4040
-'
4041
-
4042
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=wt in subdir' '
4043
- cat >27/sub/sub/expected <<EOF &&
4044
-setup: git_dir: $here/27.git
4045
-setup: worktree: $here/27/wt
4046
-setup: cwd: $here/27/sub/sub
4047
-setup: prefix: (null)
4048
-EOF
4049
- test_repo 27/sub/sub "$here/27/.git" "$here/27/wt"
4050
-'
4051
-
4052
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=.. at root' '
4053
- cat >27/expected <<EOF &&
4054
-setup: git_dir: $here/27.git
4055
-setup: worktree: $here
4056
-setup: cwd: $here
4057
-setup: prefix: 27/
4058
-EOF
4059
- test_repo 27 .git "$here"
4060
-'
4061
-
4062
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=..(rel) at root' '
4063
- cat >27/expected <<EOF &&
4064
-setup: git_dir: $here/27.git
4065
-setup: worktree: $here
4066
-setup: cwd: $here
4067
-setup: prefix: 27/
4068
-EOF
4069
- test_repo 27 .git ..
4070
-'
4071
-
4072
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=..(rel) at root' '
4073
- cat >27/expected <<EOF &&
4074
-setup: git_dir: $here/27.git
4075
-setup: worktree: $here
4076
-setup: cwd: $here
4077
-setup: prefix: 27/
4078
-EOF
4079
- test_repo 27 "$here/27/.git" ..
4080
-'
4081
-
4082
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=.. at root' '
4083
- cat >27/expected <<EOF &&
4084
-setup: git_dir: $here/27.git
4085
-setup: worktree: $here
4086
-setup: cwd: $here
4087
-setup: prefix: 27/
4088
-EOF
4089
- test_repo 27 "$here/27/.git" "$here"
4090
-'
4091
-
4092
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=.. in subdir' '
4093
- cat >27/sub/sub/expected <<EOF &&
4094
-setup: git_dir: $here/27.git
4095
-setup: worktree: $here
4096
-setup: cwd: $here
4097
-setup: prefix: 27/sub/sub/
4098
-EOF
4099
- test_repo 27/sub/sub ../../.git "$here"
4100
-'
4101
-
4102
-test_expect_success '#27: GIT_DIR(rel), GIT_WORK_TREE=..(rel) in subdir' '
4103
- cat >27/sub/sub/expected <<EOF &&
4104
-setup: git_dir: $here/27.git
4105
-setup: worktree: $here
4106
-setup: cwd: $here
4107
-setup: prefix: 27/sub/sub/
4108
-EOF
4109
- test_repo 27/sub/sub ../../.git ../../..
4110
-'
4111
-
4112
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=..(rel) in subdir' '
4113
- cat >27/sub/sub/expected <<EOF &&
4114
-setup: git_dir: $here/27.git
4115
-setup: worktree: $here
4116
-setup: cwd: $here
4117
-setup: prefix: 27/sub/sub/
4118
-EOF
4119
- test_repo 27/sub/sub "$here/27/.git" ../../../
4120
-'
4121
-
4122
-test_expect_success '#27: GIT_DIR, GIT_WORK_TREE=.. in subdir' '
4123
- cat >27/sub/sub/expected <<EOF &&
4124
-setup: git_dir: $here/27.git
4125
-setup: worktree: $here
4126
-setup: cwd: $here
4127
-setup: prefix: 27/sub/sub/
4128
-EOF
4129
- test_repo 27/sub/sub "$here/27/.git" "$here"
4130
-'
4131
-
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
-
4149
-test_expect_success '#28: setup' '
4150
- sane_unset GIT_DIR GIT_WORK_TREE &&
4151
- mkdir 28 28/sub &&
4152
- cd 28 &&
4153
- git init &&
4154
- git config core.bare true &&
4155
- git config core.worktree non-existent &&
4156
- mv .git ../28.git &&
4157
- echo gitdir: ../28.git >.git &&
4158
- cd ..
4159
-'
4160
-
4161
-test_expect_success '#28: at root' '
4162
- cat >28/expected <<EOF &&
4163
-setup: git_dir: $here/28.git
4164
-setup: worktree: (null)
4165
-setup: cwd: $here/28
4166
-setup: prefix: (null)
4167
-EOF
4168
- test_repo 28
4169
-'
4170
-
4171
-test_expect_success '#28: in subdir' '
4172
- cat >28/sub/expected <<EOF &&
4173
-setup: git_dir: $here/28.git
4174
-setup: worktree: (null)
4175
-setup: cwd: $here/28/sub
4176
-setup: prefix: (null)
4177
-EOF
4178
- test_repo 28/sub
4179
-'
4180
-
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
-
4198
-test_expect_success '#29: setup' '
4199
- sane_unset GIT_DIR GIT_WORK_TREE &&
4200
- mkdir 29 29/sub &&
4201
- cd 29 &&
4202
- git init &&
4203
- git config core.bare true &&
4204
- GIT_WORK_TREE=non-existent &&
4205
- export GIT_WORK_TREE &&
4206
- mv .git ../29.git &&
4207
- echo gitdir: ../29.git >.git &&
4208
- cd ..
4209
-'
4210
-
4211
-test_expect_success '#29: at root' '
4212
- cat >29/expected <<EOF &&
4213
-setup: git_dir: $here/29.git
4214
-setup: worktree: (null)
4215
-setup: cwd: $here/29
4216
-setup: prefix: (null)
4217
-EOF
4218
- test_repo 29
4219
-'
4220
-
4221
-test_expect_success '#29: in subdir' '
4222
- cat >29/sub/expected <<EOF &&
4223
-setup: git_dir: $here/29.git
4224
-setup: worktree: (null)
4225
-setup: cwd: $here/29/sub
4226
-setup: prefix: (null)
4227
-EOF
4228
- test_repo 29/sub
4229
-'
4230
-
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
-
4248
-test_expect_success '#30: setup' '
4249
- sane_unset GIT_DIR GIT_WORK_TREE &&
4250
- mkdir 30 &&
4251
- cd 30 &&
4252
- git init &&
4253
- git config core.bare true &&
4254
- git config core.worktree non-existent &&
4255
- mv .git ../30.git &&
4256
- echo gitdir: ../30.git >.git &&
4257
- cd ..
4258
-'
4259
-
4260
-test_expect_success '#30: at root' '
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
-
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
-
748
+# Case #31: GIT_DIR + GIT_WORK_TREE(+core.worktree) suppresses
749
+# bareness (gitfile version).
750
test_expect_success '#31: setup' '
4288
- sane_unset GIT_DIR GIT_WORK_TREE &&
4289
- mkdir 31 31/sub 31/sub/sub 31.wt 31.wt/sub 31/wt 31/wt/sub &&
4290
- cd 31 &&
4291
- git init &&
4292
- git config core.bare true &&
4293
- git config core.worktree non-existent &&
4294
- mv .git ../31.git &&
4295
- echo gitdir: ../31.git >.git &&
4296
- cd ..
4297
-'
4298
-
4299
-test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=root at root' '
4300
- cat >31/expected <<EOF &&
4301
-setup: git_dir: $here/31.git
4302
-setup: worktree: $here/31
4303
-setup: cwd: $here/31
4304
-setup: prefix: (null)
4305
-EOF
4306
- test_repo 31 .git "$here/31"
4307
-'
4308
-
4309
-test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=root(rel) at root' '
4310
- cat >31/expected <<EOF &&
4311
-setup: git_dir: $here/31.git
4312
-setup: worktree: $here/31
4313
-setup: cwd: $here/31
4314
-setup: prefix: (null)
4315
-EOF
4316
- test_repo 31 .git .
4317
-'
4318
-
4319
-test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=root at root' '
4320
- cat >31/expected <<EOF &&
4321
-setup: git_dir: $here/31.git
4322
-setup: worktree: $here/31
4323
-setup: cwd: $here/31
4324
-setup: prefix: (null)
4325
-EOF
4326
- test_repo 31 "$here/31/.git" "$here/31"
4327
-'
4328
-
4329
-test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=root(rel) at root' '
4330
- cat >31/expected <<EOF &&
4331
-setup: git_dir: $here/31.git
4332
-setup: worktree: $here/31
4333
-setup: cwd: $here/31
4334
-setup: prefix: (null)
4335
-EOF
4336
- test_repo 31 "$here/31/.git" .
4337
-'
4338
-
4339
-test_expect_success '#31: GIT_DIR(rel), GIT_WORKTREE=root in subdir' '
4340
- cat >31/sub/sub/expected <<EOF &&
4341
-setup: git_dir: $here/31.git
4342
-setup: worktree: $here/31
4343
-setup: cwd: $here/31
4344
-setup: prefix: sub/sub/
4345
-EOF
4346
- test_repo 31/sub/sub ../../.git "$here/31"
4347
-'
4348
-
4349
-test_expect_success '#31: GIT_DIR(rel), GIT_WORKTREE=root(rel) in subdir' '
4350
- cat >31/sub/sub/expected <<EOF &&
4351
-setup: git_dir: $here/31.git
4352
-setup: worktree: $here/31
4353
-setup: cwd: $here/31
4354
-setup: prefix: sub/sub/
4355
-EOF
4356
- test_repo 31/sub/sub ../../.git ../..
4357
-'
4358
-
4359
-test_expect_success '#31: GIT_DIR, GIT_WORKTREE=root in subdir' '
4360
- cat >31/sub/expected <<EOF &&
4361
-setup: git_dir: $here/31.git
4362
-setup: worktree: $here/31
4363
-setup: cwd: $here/31
4364
-setup: prefix: sub/
4365
-EOF
4366
- test_repo 31/sub "$here/31/.git" "$here/31"
4367
-'
4368
-
4369
-test_expect_success '#31: GIT_DIR, GIT_WORKTREE=root(rel) in subdir' '
4370
- cat >31/sub/sub/expected <<EOF &&
4371
-setup: git_dir: $here/31.git
4372
-setup: worktree: $here/31
4373
-setup: cwd: $here/31
4374
-setup: prefix: sub/sub/
4375
-EOF
4376
- test_repo 31/sub/sub "$here/31/.git" ../..
4377
-'
4378
-
4379
-test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=wt at root' '
4380
- cat >31/expected <<EOF &&
4381
-setup: git_dir: $here/31.git
4382
-setup: worktree: $here/31/wt
4383
-setup: cwd: $here/31
4384
-setup: prefix: (null)
4385
-EOF
4386
- test_repo 31 .git "$here/31/wt"
4387
-'
4388
-
4389
-test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=wt(rel) at root' '
4390
- cat >31/expected <<EOF &&
4391
-setup: git_dir: $here/31.git
4392
-setup: worktree: $here/31/wt
4393
-setup: cwd: $here/31
4394
-setup: prefix: (null)
4395
-EOF
4396
- test_repo 31 .git wt
4397
-'
4398
-
4399
-test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=wt(rel) at root' '
4400
- cat >31/expected <<EOF &&
4401
-setup: git_dir: $here/31.git
4402
-setup: worktree: $here/31/wt
4403
-setup: cwd: $here/31
4404
-setup: prefix: (null)
4405
-EOF
4406
- test_repo 31 "$here/31/.git" wt
4407
-'
4408
-
4409
-test_expect_success '#31: GIT_DIR, GIT_WORK_TREE=wt at root' '
4410
- cat >31/expected <<EOF &&
4411
-setup: git_dir: $here/31.git
4412
-setup: worktree: $here/31/wt
4413
-setup: cwd: $here/31
4414
-setup: prefix: (null)
4415
-EOF
4416
- test_repo 31 "$here/31/.git" "$here/31/wt"
4417
-'
4418
-
4419
-test_expect_success '#31: GIT_DIR(rel), GIT_WORK_TREE=wt in subdir' '
4420
- cat >31/sub/sub/expected <<EOF &&
4421
-setup: git_dir: $here/31.git
4422
-setup: worktree: $here/31/wt
4423
-setup: cwd: $here/31/sub/sub
4424
-setup: prefix: (null)
4425
-EOF
4426
- test_repo 31/sub/sub ../../.git "$here/31/wt"
This file is too large to show in full.