summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2015-11-20 06:56:11 -0500
committerLibravatar Jeff King <peff@peff.net>2015-11-20 06:56:11 -0500
commitdbba85e46b9c7450710a23208ca1868179330e1e (patch)
tree1de2e7302f6872f263e187859b2917ad13f826a4 /refs.c
parentMerge branch 'dk/gc-idx-wo-pack' (diff)
parentt5509: add basic tests for hideRefs (diff)
downloadtgif-dbba85e46b9c7450710a23208ca1868179330e1e.tar.xz
Merge branch 'lf/ref-is-hidden-namespace'
Extend transfer.hideRefs to work better with use of namespaces. * lf/ref-is-hidden-namespace: t5509: add basic tests for hideRefs hideRefs: add support for matching full refs upload-pack: strip refs before calling ref_is_hidden() config.txt: document the semantics of hideRefs with namespaces
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/refs.c b/refs.c
index 132eff52ca..bab92d773d 100644
--- a/refs.c
+++ b/refs.c
@@ -4534,7 +4534,7 @@ int parse_hide_refs_config(const char *var, const char *value, const char *secti
return 0;
}
-int ref_is_hidden(const char *refname)
+int ref_is_hidden(const char *refname, const char *refname_full)
{
int i;
@@ -4542,6 +4542,7 @@ int ref_is_hidden(const char *refname)
return 0;
for (i = hide_refs->nr - 1; i >= 0; i--) {
const char *match = hide_refs->items[i].string;
+ const char *subject;
int neg = 0;
int len;
@@ -4550,10 +4551,18 @@ int ref_is_hidden(const char *refname)
match++;
}
- if (!starts_with(refname, match))
+ if (*match == '^') {
+ subject = refname_full;
+ match++;
+ } else {
+ subject = refname;
+ }
+
+ /* refname can be NULL when namespaces are used. */
+ if (!subject || !starts_with(subject, match))
continue;
len = strlen(match);
- if (!refname[len] || refname[len] == '/')
+ if (!subject[len] || subject[len] == '/')
return !neg;
}
return 0;