transport.c: introduce core.alternateRefsCommand
When in a repository containing one or more alternates, Git would
sometimes like to list references from those alternates. For example,
'git receive-pack' lists the "tips" pointed to by references in those
alternates as special ".have" references.
Listing ".have" references is designed to make pushing changes from
upstream to a fork a lightweight operation, by advertising to the pusher
that the fork already has the objects (via its alternate). Thus, the
client can avoid sending them.
However, when the alternate (upstream, in the previous example) has a
pathologically large number of references, the initial advertisement is
too expensive. In fact, it can dominate any such optimization where the
pusher avoids sending certain objects.
Introduce "core.alternateRefsCommand" in order to provide a facility to
limit or filter alternate references. This can be used, for example, to
filter out references the alternate does not wish to send (for space
concerns, or otherwise) during the initial advertisement.
Let the repository that has alternates configure this command to avoid
trusting the alternate to provide us a safe command to run in the shell.
To find the alternate, pass its absolute path as the first argument.
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-10-08 21:09:28 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='git receive-pack with alternate ref filtering'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success 'setup' '
|
|
|
|
test_commit base &&
|
|
|
|
git clone -s --bare . fork &&
|
|
|
|
git checkout -b public/branch master &&
|
|
|
|
test_commit public &&
|
|
|
|
git checkout -b private/branch master &&
|
|
|
|
test_commit private
|
|
|
|
'
|
|
|
|
|
|
|
|
extract_haves () {
|
|
|
|
depacketize | perl -lne '/^(\S+) \.have/ and print $1'
|
|
|
|
}
|
|
|
|
|
|
|
|
test_expect_success 'with core.alternateRefsCommand' '
|
|
|
|
write_script fork/alternate-refs <<-\EOF &&
|
|
|
|
git --git-dir="$1" for-each-ref \
|
|
|
|
--format="%(objectname)" \
|
|
|
|
refs/heads/public/
|
|
|
|
EOF
|
2018-10-24 10:37:06 +03:00
|
|
|
test_config -C fork core.alternateRefsCommand ./alternate-refs &&
|
transport.c: introduce core.alternateRefsCommand
When in a repository containing one or more alternates, Git would
sometimes like to list references from those alternates. For example,
'git receive-pack' lists the "tips" pointed to by references in those
alternates as special ".have" references.
Listing ".have" references is designed to make pushing changes from
upstream to a fork a lightweight operation, by advertising to the pusher
that the fork already has the objects (via its alternate). Thus, the
client can avoid sending them.
However, when the alternate (upstream, in the previous example) has a
pathologically large number of references, the initial advertisement is
too expensive. In fact, it can dominate any such optimization where the
pusher avoids sending certain objects.
Introduce "core.alternateRefsCommand" in order to provide a facility to
limit or filter alternate references. This can be used, for example, to
filter out references the alternate does not wish to send (for space
concerns, or otherwise) during the initial advertisement.
Let the repository that has alternates configure this command to avoid
trusting the alternate to provide us a safe command to run in the shell.
To find the alternate, pass its absolute path as the first argument.
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-10-08 21:09:28 +03:00
|
|
|
git rev-parse public/branch >expect &&
|
|
|
|
printf "0000" | git receive-pack fork >actual &&
|
|
|
|
extract_haves <actual >actual.haves &&
|
|
|
|
test_cmp expect actual.haves
|
|
|
|
'
|
|
|
|
|
2018-10-08 21:09:30 +03:00
|
|
|
test_expect_success 'with core.alternateRefsPrefixes' '
|
|
|
|
test_config -C fork core.alternateRefsPrefixes "refs/heads/private" &&
|
|
|
|
git rev-parse private/branch >expect &&
|
|
|
|
printf "0000" | git receive-pack fork >actual &&
|
|
|
|
extract_haves <actual >actual.haves &&
|
|
|
|
test_cmp expect actual.haves
|
|
|
|
'
|
|
|
|
|
transport.c: introduce core.alternateRefsCommand
When in a repository containing one or more alternates, Git would
sometimes like to list references from those alternates. For example,
'git receive-pack' lists the "tips" pointed to by references in those
alternates as special ".have" references.
Listing ".have" references is designed to make pushing changes from
upstream to a fork a lightweight operation, by advertising to the pusher
that the fork already has the objects (via its alternate). Thus, the
client can avoid sending them.
However, when the alternate (upstream, in the previous example) has a
pathologically large number of references, the initial advertisement is
too expensive. In fact, it can dominate any such optimization where the
pusher avoids sending certain objects.
Introduce "core.alternateRefsCommand" in order to provide a facility to
limit or filter alternate references. This can be used, for example, to
filter out references the alternate does not wish to send (for space
concerns, or otherwise) during the initial advertisement.
Let the repository that has alternates configure this command to avoid
trusting the alternate to provide us a safe command to run in the shell.
To find the alternate, pass its absolute path as the first argument.
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-10-08 21:09:28 +03:00
|
|
|
test_done
|