]>
Commit | Line | Data |
---|---|---|
89284c1d TB |
1 | #!/bin/sh |
2 | ||
3 | test_description='git receive-pack with alternate ref filtering' | |
4 | ||
966b4be2 | 5 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
6 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
7 | ||
9081a421 | 8 | TEST_PASSES_SANITIZE_LEAK=true |
89284c1d TB |
9 | . ./test-lib.sh |
10 | ||
11 | test_expect_success 'setup' ' | |
12 | test_commit base && | |
13 | git clone -s --bare . fork && | |
966b4be2 | 14 | git checkout -b public/branch main && |
89284c1d | 15 | test_commit public && |
966b4be2 | 16 | git checkout -b private/branch main && |
89284c1d TB |
17 | test_commit private |
18 | ' | |
19 | ||
20 | extract_haves () { | |
21 | depacketize | perl -lne '/^(\S+) \.have/ and print $1' | |
22 | } | |
23 | ||
24 | test_expect_success 'with core.alternateRefsCommand' ' | |
25 | write_script fork/alternate-refs <<-\EOF && | |
26 | git --git-dir="$1" for-each-ref \ | |
27 | --format="%(objectname)" \ | |
28 | refs/heads/public/ | |
29 | EOF | |
e6641d2f | 30 | test_config -C fork core.alternateRefsCommand ./alternate-refs && |
89284c1d TB |
31 | git rev-parse public/branch >expect && |
32 | printf "0000" | git receive-pack fork >actual && | |
33 | extract_haves <actual >actual.haves && | |
34 | test_cmp expect actual.haves | |
35 | ' | |
36 | ||
40f327fa TB |
37 | test_expect_success 'with core.alternateRefsPrefixes' ' |
38 | test_config -C fork core.alternateRefsPrefixes "refs/heads/private" && | |
39 | git rev-parse private/branch >expect && | |
40 | printf "0000" | git receive-pack fork >actual && | |
41 | extract_haves <actual >actual.haves && | |
42 | test_cmp expect actual.haves | |
43 | ' | |
44 | ||
89284c1d | 45 | test_done |