Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorChristian Couder <christian.couder@gmail.com>2017-07-22 07:39:12 +0300
committerJunio C Hamano <gitster@pobox.com>2017-07-25 00:48:59 +0300
commit7a40a95eb4f79517750eb2bcd81342c25c6db406 (patch)
tree04d1314593637570508b24d8c07529c4683bfaf9 /refs.c
parent95d67879735cfecfdd85f89e59d993c5b4de8835 (diff)
refs: use skip_prefix() in ref_is_hidden()
This is shorter, makes the logic a bit easier to follow, and is perhaps a bit faster too. The logic is to make the final decision only when "subject" is there, its early part matches "match", and the match is at the slash boundary (or the whole thing). Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/refs.c b/refs.c
index 2d717742d60..dcfa4dee7a5 100644
--- a/refs.c
+++ b/refs.c
@@ -1066,7 +1066,7 @@ int ref_is_hidden(const char *refname, const char *refname_full)
const char *match = hide_refs->items[i].string;
const char *subject;
int neg = 0;
- int len;
+ const char *p;
if (*match == '!') {
neg = 1;
@@ -1081,10 +1081,9 @@ int ref_is_hidden(const char *refname, const char *refname_full)
}
/* refname can be NULL when namespaces are used. */
- if (!subject || !starts_with(subject, match))
- continue;
- len = strlen(match);
- if (!subject[len] || subject[len] == '/')
+ if (subject &&
+ skip_prefix(subject, match, &p) &&
+ (!*p || *p == '/'))
return !neg;
}
return 0;