1
0
mirror of https://github.com/git/git synced 2024-07-05 00:58:49 +00:00

Merge branch 'ew/fetch-hiderefs'

A new "fetch.hideRefs" option can be used to exclude specified refs
from "rev-list --objects --stdin --not --all" traversal for
checking object connectivity, most useful when there are many
unrelated histories in a single repository.

* ew/fetch-hiderefs:
  fetch: support hideRefs to speed up connectivity checks
This commit is contained in:
Junio C Hamano 2023-03-17 14:03:10 -07:00
commit 4d87411ffe
8 changed files with 26 additions and 12 deletions

View File

@ -197,10 +197,11 @@ respectively, and they must begin with `refs/` when applied to `--glob`
or `--all`. If a trailing '/{asterisk}' is intended, it must be given
explicitly.
--exclude-hidden=[receive|uploadpack]::
Do not include refs that would be hidden by `git-receive-pack` or
`git-upload-pack` by consulting the appropriate `receive.hideRefs` or
`uploadpack.hideRefs` configuration along with `transfer.hideRefs` (see
--exclude-hidden=[fetch|receive|uploadpack]::
Do not include refs that would be hidden by `git-fetch`,
`git-receive-pack` or `git-upload-pack` by consulting the appropriate
`fetch.hideRefs`, `receive.hideRefs` or `uploadpack.hideRefs`
configuration along with `transfer.hideRefs` (see
linkgit:git-config[1]). This option affects the next pseudo-ref option
`--all` or `--glob` and is cleared after processing them.

View File

@ -195,10 +195,11 @@ respectively, and they must begin with `refs/` when applied to `--glob`
or `--all`. If a trailing '/{asterisk}' is intended, it must be given
explicitly.
--exclude-hidden=[receive|uploadpack]::
Do not include refs that would be hidden by `git-receive-pack` or
`git-upload-pack` by consulting the appropriate `receive.hideRefs` or
`uploadpack.hideRefs` configuration along with `transfer.hideRefs` (see
--exclude-hidden=[fetch|receive|uploadpack]::
Do not include refs that would be hidden by `git-fetch`,
`git-receive-pack` or `git-upload-pack` by consulting the appropriate
`fetch.hideRefs`, `receive.hideRefs` or `uploadpack.hideRefs`
configuration along with `transfer.hideRefs` (see
linkgit:git-config[1]). This option affects the next pseudo-ref option
`--all` or `--glob` and is cleared after processing them.

View File

@ -1133,6 +1133,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
if (!connectivity_checked) {
struct check_connected_options opt = CHECK_CONNECTED_INIT;
opt.exclude_hidden_refs_section = "fetch";
rm = ref_map;
if (check_connected(iterate_ref_map, &rm, &opt)) {
rc = error(_("%s did not send all necessary objects\n"), url);
@ -1326,6 +1327,7 @@ static int check_exist_and_connected(struct ref *ref_map)
}
opt.quiet = 1;
opt.exclude_hidden_refs_section = "fetch";
return check_connected(iterate_ref_map, &rm, &opt);
}

View File

@ -39,7 +39,7 @@ static const char rev_list_usage[] =
" --tags\n"
" --remotes\n"
" --stdin\n"
" --exclude-hidden=[receive|uploadpack]\n"
" --exclude-hidden=[fetch|receive|uploadpack]\n"
" --quiet\n"
" ordering output:\n"
" --topo-order\n"

View File

@ -1576,7 +1576,8 @@ void exclude_hidden_refs(struct ref_exclusions *exclusions, const char *section)
{
struct exclude_hidden_refs_cb cb;
if (strcmp(section, "receive") && strcmp(section, "uploadpack"))
if (strcmp(section, "fetch") && strcmp(section, "receive") &&
strcmp(section, "uploadpack"))
die(_("unsupported section for hidden refs: %s"), section);
if (exclusions->hidden_refs_configured)

View File

@ -1171,6 +1171,15 @@ test_expect_success '--no-show-forced-updates' '
)
'
for section in fetch transfer
do
test_expect_success "$section.hideRefs affects connectivity check" '
GIT_TRACE="$PWD"/trace git -c $section.hideRefs=refs -c \
$section.hideRefs="!refs/tags/" fetch &&
grep "git rev-list .*--exclude-hidden=fetch" trace
'
done
setup_negotiation_tip () {
SERVER="$1"
URL="$2"

View File

@ -187,7 +187,7 @@ test_expect_success 'rev-parse --exclude=ref with --remotes=glob' '
compare rev-parse "--exclude=upstream/x --remotes=upstream/*" "upstream/one upstream/two"
'
for section in receive uploadpack
for section in fetch receive uploadpack
do
test_expect_success "rev-parse --exclude-hidden=$section with --all" '
compare "-c transfer.hideRefs=refs/remotes/ rev-parse" "--branches --tags" "--exclude-hidden=$section --all"

View File

@ -22,7 +22,7 @@ test_expect_success 'invalid section' '
test_cmp expected err
'
for section in receive uploadpack
for section in fetch receive uploadpack
do
test_expect_success "$section: passed multiple times" '
echo "fatal: --exclude-hidden= passed more than once" >expected &&