Merge branch 'jk/negative-hiderefs'
A negative !ref entry in multi-value transfer.hideRefs configuration can be used to say "don't hide this one". * jk/negative-hiderefs: refs: support negative transfer.hideRefs docs/config.txt: reorder hideRefs config
This commit is contained in:
commit
824a0be6be
@ -2313,13 +2313,10 @@ receive.denyNonFastForwards::
|
|||||||
set when initializing a shared repository.
|
set when initializing a shared repository.
|
||||||
|
|
||||||
receive.hideRefs::
|
receive.hideRefs::
|
||||||
String(s) `receive-pack` uses to decide which refs to omit
|
This variable is the same as `transfer.hideRefs`, but applies
|
||||||
from its initial advertisement. Use more than one
|
only to `receive-pack` (and so affects pushes, but not fetches).
|
||||||
definitions to specify multiple prefix strings. A ref that
|
An attempt to update or delete a hidden ref by `git push` is
|
||||||
are under the hierarchies listed on the value of this
|
rejected.
|
||||||
variable is excluded, and is hidden when responding to `git
|
|
||||||
push`, and an attempt to update or delete a hidden ref by
|
|
||||||
`git push` is rejected.
|
|
||||||
|
|
||||||
receive.updateServerInfo::
|
receive.updateServerInfo::
|
||||||
If set to true, git-receive-pack will run git-update-server-info
|
If set to true, git-receive-pack will run git-update-server-info
|
||||||
@ -2607,9 +2604,18 @@ transfer.fsckObjects::
|
|||||||
Defaults to false.
|
Defaults to false.
|
||||||
|
|
||||||
transfer.hideRefs::
|
transfer.hideRefs::
|
||||||
This variable can be used to set both `receive.hideRefs`
|
String(s) `receive-pack` and `upload-pack` use to decide which
|
||||||
and `uploadpack.hideRefs` at the same time to the same
|
refs to omit from their initial advertisements. Use more than
|
||||||
values. See entries for these other variables.
|
one definition to specify multiple prefix strings. A ref that is
|
||||||
|
under the hierarchies listed in the value of this variable is
|
||||||
|
excluded, and is hidden when responding to `git push` or `git
|
||||||
|
fetch`. See `receive.hideRefs` and `uploadpack.hideRefs` for
|
||||||
|
program-specific versions of this config.
|
||||||
|
+
|
||||||
|
You may also include a `!` in front of the ref name to negate the entry,
|
||||||
|
explicitly exposing it, even if an earlier entry marked it as hidden.
|
||||||
|
If you have multiple hideRefs values, later entries override earlier ones
|
||||||
|
(and entries in more-specific config files override less-specific ones).
|
||||||
|
|
||||||
transfer.unpackLimit::
|
transfer.unpackLimit::
|
||||||
When `fetch.unpackLimit` or `receive.unpackLimit` are
|
When `fetch.unpackLimit` or `receive.unpackLimit` are
|
||||||
@ -2624,13 +2630,10 @@ uploadarchive.allowUnreachable::
|
|||||||
`false`.
|
`false`.
|
||||||
|
|
||||||
uploadpack.hideRefs::
|
uploadpack.hideRefs::
|
||||||
String(s) `upload-pack` uses to decide which refs to omit
|
This variable is the same as `transfer.hideRefs`, but applies
|
||||||
from its initial advertisement. Use more than one
|
only to `upload-pack` (and so affects only fetches, not pushes).
|
||||||
definitions to specify multiple prefix strings. A ref that
|
An attempt to fetch a hidden ref by `git fetch` will fail. See
|
||||||
are under the hierarchies listed on the value of this
|
also `uploadpack.allowTipSHA1InWant`.
|
||||||
variable is excluded, and is hidden from `git ls-remote`,
|
|
||||||
`git fetch`, etc. An attempt to fetch a hidden ref by `git
|
|
||||||
fetch` will fail. See also `uploadpack.allowTipSHA1InWant`.
|
|
||||||
|
|
||||||
uploadpack.allowTipSHA1InWant::
|
uploadpack.allowTipSHA1InWant::
|
||||||
When `uploadpack.hideRefs` is in effect, allow `upload-pack`
|
When `uploadpack.hideRefs` is in effect, allow `upload-pack`
|
||||||
|
18
refs.c
18
refs.c
@ -4371,17 +4371,25 @@ int parse_hide_refs_config(const char *var, const char *value, const char *secti
|
|||||||
|
|
||||||
int ref_is_hidden(const char *refname)
|
int ref_is_hidden(const char *refname)
|
||||||
{
|
{
|
||||||
struct string_list_item *item;
|
int i;
|
||||||
|
|
||||||
if (!hide_refs)
|
if (!hide_refs)
|
||||||
return 0;
|
return 0;
|
||||||
for_each_string_list_item(item, hide_refs) {
|
for (i = hide_refs->nr - 1; i >= 0; i--) {
|
||||||
|
const char *match = hide_refs->items[i].string;
|
||||||
|
int neg = 0;
|
||||||
int len;
|
int len;
|
||||||
if (!starts_with(refname, item->string))
|
|
||||||
|
if (*match == '!') {
|
||||||
|
neg = 1;
|
||||||
|
match++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!starts_with(refname, match))
|
||||||
continue;
|
continue;
|
||||||
len = strlen(item->string);
|
len = strlen(match);
|
||||||
if (!refname[len] || refname[len] == '/')
|
if (!refname[len] || refname[len] == '/')
|
||||||
return 1;
|
return !neg;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -128,6 +128,11 @@ test_expect_success 'Report match with --exit-code' '
|
|||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'set up some extra tags for ref hiding' '
|
||||||
|
git tag magic/one &&
|
||||||
|
git tag magic/two
|
||||||
|
'
|
||||||
|
|
||||||
for configsection in transfer uploadpack
|
for configsection in transfer uploadpack
|
||||||
do
|
do
|
||||||
test_expect_success "Hide some refs with $configsection.hiderefs" '
|
test_expect_success "Hide some refs with $configsection.hiderefs" '
|
||||||
@ -138,6 +143,24 @@ do
|
|||||||
sed -e "/ refs\/tags\//d" >expect &&
|
sed -e "/ refs\/tags\//d" >expect &&
|
||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success "Override hiding of $configsection.hiderefs" '
|
||||||
|
test_when_finished "test_unconfig $configsection.hiderefs" &&
|
||||||
|
git config --add $configsection.hiderefs refs/tags &&
|
||||||
|
git config --add $configsection.hiderefs "!refs/tags/magic" &&
|
||||||
|
git config --add $configsection.hiderefs refs/tags/magic/one &&
|
||||||
|
git ls-remote . >actual &&
|
||||||
|
grep refs/tags/magic/two actual &&
|
||||||
|
! grep refs/tags/magic/one actual
|
||||||
|
'
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
test_expect_success 'overrides work between mixed transfer/upload-pack hideRefs' '
|
||||||
|
test_config uploadpack.hiderefs refs/tags &&
|
||||||
|
test_config transfer.hiderefs "!refs/tags/magic" &&
|
||||||
|
git ls-remote . >actual &&
|
||||||
|
grep refs/tags/magic actual
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
Loading…
Reference in New Issue
Block a user