Taylor Blau | 89284c1 | 2018-10-08 11:09:28 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='git receive-pack with alternate ref filtering' |
| 4 | |
Johannes Schindelin | 966b4be | 2020-11-18 23:44:29 +0000 | [diff] [blame] | 5 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
Johannes Schindelin | 334afbc | 2020-11-18 23:44:19 +0000 | [diff] [blame] | 6 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
| 7 | |
Ævar Arnfjörð Bjarmason | 9081a42 | 2021-11-16 19:27:38 +0100 | [diff] [blame] | 8 | TEST_PASSES_SANITIZE_LEAK=true |
Taylor Blau | 89284c1 | 2018-10-08 11:09:28 -0700 | [diff] [blame] | 9 | . ./test-lib.sh |
| 10 | |
| 11 | test_expect_success 'setup' ' |
| 12 | test_commit base && |
| 13 | git clone -s --bare . fork && |
Johannes Schindelin | 966b4be | 2020-11-18 23:44:29 +0000 | [diff] [blame] | 14 | git checkout -b public/branch main && |
Taylor Blau | 89284c1 | 2018-10-08 11:09:28 -0700 | [diff] [blame] | 15 | test_commit public && |
Johannes Schindelin | 966b4be | 2020-11-18 23:44:29 +0000 | [diff] [blame] | 16 | git checkout -b private/branch main && |
Taylor Blau | 89284c1 | 2018-10-08 11:09:28 -0700 | [diff] [blame] | 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 |
Jeff King | e6641d2 | 2018-10-24 03:37:06 -0400 | [diff] [blame] | 30 | test_config -C fork core.alternateRefsCommand ./alternate-refs && |
Taylor Blau | 89284c1 | 2018-10-08 11:09:28 -0700 | [diff] [blame] | 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 | |
Taylor Blau | 40f327f | 2018-10-08 11:09:30 -0700 | [diff] [blame] | 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 | |
Taylor Blau | 89284c1 | 2018-10-08 11:09:28 -0700 | [diff] [blame] | 45 | test_done |