aboutsummaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@lfos.de>2015-11-03 08:58:16 +0100
committerJunio C Hamano <gitster@pobox.com>2015-11-05 11:25:02 -0800
commit78a766ab6eaaa91c2638158bd4fda06a93291da0 (patch)
tree3318ee5a30e7227c2c20b46d2a8b7118ed8d3050 /refs.c
parent00b293e519d1aa0c5b57ae9359ec5306d7023b3f (diff)
downloadgit-78a766ab6eaaa91c2638158bd4fda06a93291da0.tar.gz
git-78a766ab6eaaa91c2638158bd4fda06a93291da0.tar.xz
hideRefs: add support for matching full refs
In addition to matching stripped refs, one can now add hideRefs patterns that the full (unstripped) ref is matched against. To distinguish between stripped and full matches, those new patterns must be prefixed with a circumflex (^). This commit also removes support for the undocumented and unintended hideRefs settings ".have" (suppressing all "have" lines) and "capabilities^{}" (suppressing the capabilities line). Signed-off-by: Lukas Fleischer <lfleischer@lfos.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
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 132eff52c..bab92d773 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;