clone: use free() instead of UNLEAK()
[git.git] / t / t5615-alternate-env.sh
blob83513e46a3556baa014c76f613a4da5504b8b548
1 #!/bin/sh
3 test_description='handling of alternates in environment variables'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 check_obj () {
9 alt=$1; shift
10 while read obj expect
12 echo "$obj" >&5 &&
13 echo "$obj $expect" >&6
14 done 5>input 6>expect &&
15 GIT_ALTERNATE_OBJECT_DIRECTORIES=$alt \
16 git "$@" cat-file --batch-check='%(objectname) %(objecttype)' \
17 <input >actual &&
18 test_cmp expect actual
21 test_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)
28 test_expect_success 'objects inaccessible without alternates' '
29 check_obj "" <<-EOF
30 $one missing
31 $two missing
32 EOF
35 test_expect_success 'access alternate via absolute path' '
36 check_obj "$PWD/one.git/objects" <<-EOF
37 $one blob
38 $two missing
39 EOF
42 test_expect_success 'access multiple alternates' '
43 check_obj "$PWD/one.git/objects:$PWD/two.git/objects" <<-EOF
44 $one blob
45 $two blob
46 EOF
49 # bare paths are relative from $GIT_DIR
50 test_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
57 # non-bare paths are relative to top of worktree
58 test_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
65 # path is computed after moving to top-level of worktree
66 test_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
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.
76 quoted='"one.git\057objects"'
77 unquoted='two.git/objects'
78 test_expect_success 'mix of quoted and unquoted alternates' '
79 check_obj "$quoted:$unquoted" <<-EOF
80 $one blob
81 $two blob
82 EOF
85 test_expect_success !MINGW 'broken quoting falls back to interpreting raw' '
86 mv one.git \"one.git &&
87 check_obj \"one.git/objects <<-EOF
88 $one blob
89 EOF
92 test_done