Skip to content

Commit 4d87411

Browse files
committed
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
2 parents 92c56da + c6ce27a commit 4d87411

File tree

8 files changed

+26
-12
lines changed

8 files changed

+26
-12
lines changed

Documentation/git-rev-parse.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,11 @@ respectively, and they must begin with `refs/` when applied to `--glob`
197197
or `--all`. If a trailing '/{asterisk}' is intended, it must be given
198198
explicitly.
199199

200-
--exclude-hidden=[receive|uploadpack]::
201-
Do not include refs that would be hidden by `git-receive-pack` or
202-
`git-upload-pack` by consulting the appropriate `receive.hideRefs` or
203-
`uploadpack.hideRefs` configuration along with `transfer.hideRefs` (see
200+
--exclude-hidden=[fetch|receive|uploadpack]::
201+
Do not include refs that would be hidden by `git-fetch`,
202+
`git-receive-pack` or `git-upload-pack` by consulting the appropriate
203+
`fetch.hideRefs`, `receive.hideRefs` or `uploadpack.hideRefs`
204+
configuration along with `transfer.hideRefs` (see
204205
linkgit:git-config[1]). This option affects the next pseudo-ref option
205206
`--all` or `--glob` and is cleared after processing them.
206207

Documentation/rev-list-options.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,11 @@ respectively, and they must begin with `refs/` when applied to `--glob`
195195
or `--all`. If a trailing '/{asterisk}' is intended, it must be given
196196
explicitly.
197197

198-
--exclude-hidden=[receive|uploadpack]::
199-
Do not include refs that would be hidden by `git-receive-pack` or
200-
`git-upload-pack` by consulting the appropriate `receive.hideRefs` or
201-
`uploadpack.hideRefs` configuration along with `transfer.hideRefs` (see
198+
--exclude-hidden=[fetch|receive|uploadpack]::
199+
Do not include refs that would be hidden by `git-fetch`,
200+
`git-receive-pack` or `git-upload-pack` by consulting the appropriate
201+
`fetch.hideRefs`, `receive.hideRefs` or `uploadpack.hideRefs`
202+
configuration along with `transfer.hideRefs` (see
202203
linkgit:git-config[1]). This option affects the next pseudo-ref option
203204
`--all` or `--glob` and is cleared after processing them.
204205

builtin/fetch.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
11331133
if (!connectivity_checked) {
11341134
struct check_connected_options opt = CHECK_CONNECTED_INIT;
11351135

1136+
opt.exclude_hidden_refs_section = "fetch";
11361137
rm = ref_map;
11371138
if (check_connected(iterate_ref_map, &rm, &opt)) {
11381139
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)
13261327
}
13271328

13281329
opt.quiet = 1;
1330+
opt.exclude_hidden_refs_section = "fetch";
13291331
return check_connected(iterate_ref_map, &rm, &opt);
13301332
}
13311333

builtin/rev-list.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static const char rev_list_usage[] =
3939
" --tags\n"
4040
" --remotes\n"
4141
" --stdin\n"
42-
" --exclude-hidden=[receive|uploadpack]\n"
42+
" --exclude-hidden=[fetch|receive|uploadpack]\n"
4343
" --quiet\n"
4444
" ordering output:\n"
4545
" --topo-order\n"

revision.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1576,7 +1576,8 @@ void exclude_hidden_refs(struct ref_exclusions *exclusions, const char *section)
15761576
{
15771577
struct exclude_hidden_refs_cb cb;
15781578

1579-
if (strcmp(section, "receive") && strcmp(section, "uploadpack"))
1579+
if (strcmp(section, "fetch") && strcmp(section, "receive") &&
1580+
strcmp(section, "uploadpack"))
15801581
die(_("unsupported section for hidden refs: %s"), section);
15811582

15821583
if (exclusions->hidden_refs_configured)

t/t5510-fetch.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,15 @@ test_expect_success '--no-show-forced-updates' '
11711171
)
11721172
'
11731173

1174+
for section in fetch transfer
1175+
do
1176+
test_expect_success "$section.hideRefs affects connectivity check" '
1177+
GIT_TRACE="$PWD"/trace git -c $section.hideRefs=refs -c \
1178+
$section.hideRefs="!refs/tags/" fetch &&
1179+
grep "git rev-list .*--exclude-hidden=fetch" trace
1180+
'
1181+
done
1182+
11741183
setup_negotiation_tip () {
11751184
SERVER="$1"
11761185
URL="$2"

t/t6018-rev-list-glob.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ test_expect_success 'rev-parse --exclude=ref with --remotes=glob' '
187187
compare rev-parse "--exclude=upstream/x --remotes=upstream/*" "upstream/one upstream/two"
188188
'
189189

190-
for section in receive uploadpack
190+
for section in fetch receive uploadpack
191191
do
192192
test_expect_success "rev-parse --exclude-hidden=$section with --all" '
193193
compare "-c transfer.hideRefs=refs/remotes/ rev-parse" "--branches --tags" "--exclude-hidden=$section --all"

t/t6021-rev-list-exclude-hidden.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test_expect_success 'invalid section' '
2222
test_cmp expected err
2323
'
2424

25-
for section in receive uploadpack
25+
for section in fetch receive uploadpack
2626
do
2727
test_expect_success "$section: passed multiple times" '
2828
echo "fatal: --exclude-hidden= passed more than once" >expected &&

0 commit comments

Comments
 (0)