]> git.ipfire.org Git - thirdparty/git.git/blob - t/t5410-receive-pack-alternates.sh
The third batch
[thirdparty/git.git] / t / t5410-receive-pack-alternates.sh
1 #!/bin/sh
2
3 test_description='git receive-pack with alternate ref filtering'
4
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
10
11 test_expect_success 'setup' '
12 test_commit base &&
13 git clone -s --bare . fork &&
14 git checkout -b public/branch main &&
15 test_commit public &&
16 git checkout -b private/branch main &&
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
30 test_config -C fork core.alternateRefsCommand ./alternate-refs &&
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
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
45 test_done