diff options
author | Jeff King <peff@peff.net> | 2015-11-20 06:56:11 -0500 |
---|---|---|
committer | Jeff King <peff@peff.net> | 2015-11-20 06:56:11 -0500 |
commit | dbba85e46b9c7450710a23208ca1868179330e1e (patch) | |
tree | 1de2e7302f6872f263e187859b2917ad13f826a4 /refs.c | |
parent | Merge branch 'dk/gc-idx-wo-pack' (diff) | |
parent | t5509: add basic tests for hideRefs (diff) | |
download | tgif-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.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -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; |