]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5615-alternate-env.sh
Sync with Git 2.45.1
[thirdparty/git.git] / t / t5615-alternate-env.sh
CommitLineData
37a95862
JK
1#!/bin/sh
2
3test_description='handling of alternates in environment variables'
288a4806
ÆAB
4
5TEST_PASSES_SANITIZE_LEAK=true
37a95862
JK
6. ./test-lib.sh
7
8check_obj () {
9 alt=$1; shift
10 while read obj expect
11 do
9be795fb
JK
12 echo "$obj" >&5 &&
13 echo "$obj $expect" >&6
14 done 5>input 6>expect &&
37a95862
JK
15 GIT_ALTERNATE_OBJECT_DIRECTORIES=$alt \
16 git "$@" cat-file --batch-check='%(objectname) %(objecttype)' \
17 <input >actual &&
18 test_cmp expect actual
19}
20
21test_expect_success 'create alternate repositories' '
22 git init --bare one.git &&
23 one=$(echo one | git -C one.git hash-object -w --stdin) &&
24 git init --bare two.git &&
25 two=$(echo two | git -C two.git hash-object -w --stdin)
26'
27
28test_expect_success 'objects inaccessible without alternates' '
29 check_obj "" <<-EOF
30 $one missing
31 $two missing
32 EOF
33'
34
35test_expect_success 'access alternate via absolute path' '
71dd5047 36 check_obj "$PWD/one.git/objects" <<-EOF
37a95862
JK
37 $one blob
38 $two missing
39 EOF
40'
41
42test_expect_success 'access multiple alternates' '
71dd5047 43 check_obj "$PWD/one.git/objects:$PWD/two.git/objects" <<-EOF
37a95862
JK
44 $one blob
45 $two blob
46 EOF
47'
48
49# bare paths are relative from $GIT_DIR
50test_expect_success 'access alternate via relative path (bare)' '
51 git init --bare bare.git &&
52 check_obj "../one.git/objects" -C bare.git <<-EOF
53 $one blob
54 EOF
55'
56
57# non-bare paths are relative to top of worktree
58test_expect_success 'access alternate via relative path (worktree)' '
59 git init worktree &&
60 check_obj "../one.git/objects" -C worktree <<-EOF
61 $one blob
62 EOF
63'
64
65# path is computed after moving to top-level of worktree
66test_expect_success 'access alternate via relative path (subdir)' '
67 mkdir subdir &&
68 check_obj "one.git/objects" -C subdir <<-EOF
69 $one blob
70 EOF
71'
72
cf3c6352
JK
73# set variables outside test to avoid quote insanity; the \057 is '/',
74# which doesn't need quoting, but just confirms that de-quoting
75# is working.
76quoted='"one.git\057objects"'
77unquoted='two.git/objects'
78test_expect_success 'mix of quoted and unquoted alternates' '
79 check_obj "$quoted:$unquoted" <<-EOF
80 $one blob
81 $two blob
37e61153 82 EOF
cf3c6352
JK
83'
84
5e74824f 85test_expect_success !MINGW 'broken quoting falls back to interpreting raw' '
cf3c6352
JK
86 mv one.git \"one.git &&
87 check_obj \"one.git/objects <<-EOF
88 $one blob
89 EOF
90'
91
37a95862 92test_done