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