blob: 7a45d4c311ed345fc0126355642e9e1e4e68d292 [file] [log] [blame]
Taylor Blau89284c12018-10-08 11:09:28 -07001#!/bin/sh
2
3test_description='git receive-pack with alternate ref filtering'
4
Johannes Schindelin966b4be2020-11-18 23:44:29 +00005GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
Johannes Schindelin334afbc2020-11-18 23:44:19 +00006export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
Ævar Arnfjörð Bjarmason9081a422021-11-16 19:27:38 +01008TEST_PASSES_SANITIZE_LEAK=true
Taylor Blau89284c12018-10-08 11:09:28 -07009. ./test-lib.sh
10
11test_expect_success 'setup' '
12 test_commit base &&
13 git clone -s --bare . fork &&
Johannes Schindelin966b4be2020-11-18 23:44:29 +000014 git checkout -b public/branch main &&
Taylor Blau89284c12018-10-08 11:09:28 -070015 test_commit public &&
Johannes Schindelin966b4be2020-11-18 23:44:29 +000016 git checkout -b private/branch main &&
Taylor Blau89284c12018-10-08 11:09:28 -070017 test_commit private
18'
19
20extract_haves () {
21 depacketize | perl -lne '/^(\S+) \.have/ and print $1'
22}
23
24test_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
Jeff Kinge6641d22018-10-24 03:37:06 -040030 test_config -C fork core.alternateRefsCommand ./alternate-refs &&
Taylor Blau89284c12018-10-08 11:09:28 -070031 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
Taylor Blau40f327f2018-10-08 11:09:30 -070037test_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
Taylor Blau89284c12018-10-08 11:09:28 -070045test_done