From: Ronnie Sahlberg <sahlb...@google.com> Move the hidden refs functions to the refs.c file since these functions do not contain any backend specific code.
Signed-off-by: Ronnie Sahlberg <sahlb...@google.com> Signed-off-by: David Turner <dtur...@twopensource.com> --- refs-be-files.c | 51 --------------------------------------------------- refs.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 51 deletions(-) diff --git a/refs-be-files.c b/refs-be-files.c index 4e7e05e..d110bf8 100644 --- a/refs-be-files.c +++ b/refs-be-files.c @@ -4169,57 +4169,6 @@ char *shorten_unambiguous_ref(const char *refname, int strict) return xstrdup(refname); } -static struct string_list *hide_refs; - -int parse_hide_refs_config(const char *var, const char *value, const char *section) -{ - if (!strcmp("transfer.hiderefs", var) || - /* NEEDSWORK: use parse_config_key() once both are merged */ - (starts_with(var, section) && var[strlen(section)] == '.' && - !strcmp(var + strlen(section), ".hiderefs"))) { - char *ref; - int len; - - if (!value) - return config_error_nonbool(var); - ref = xstrdup(value); - len = strlen(ref); - while (len && ref[len - 1] == '/') - ref[--len] = '\0'; - if (!hide_refs) { - hide_refs = xcalloc(1, sizeof(*hide_refs)); - hide_refs->strdup_strings = 1; - } - string_list_append(hide_refs, ref); - } - return 0; -} - -int ref_is_hidden(const char *refname) -{ - int i; - - if (!hide_refs) - return 0; - for (i = hide_refs->nr - 1; i >= 0; i--) { - const char *match = hide_refs->items[i].string; - int neg = 0; - int len; - - if (*match == '!') { - neg = 1; - match++; - } - - if (!starts_with(refname, match)) - continue; - len = strlen(match); - if (!refname[len] || refname[len] == '/') - return !neg; - } - return 0; -} - struct expire_reflog_cb { unsigned int flags; reflog_expiry_should_prune_fn *should_prune_fn; diff --git a/refs.c b/refs.c index 5a8ef0c..6b2fc39 100644 --- a/refs.c +++ b/refs.c @@ -328,3 +328,53 @@ int read_ref_at(const char *refname, unsigned int flags, unsigned long at_time, return 1; } + +static struct string_list *hide_refs; + +int parse_hide_refs_config(const char *var, const char *value, const char *section) +{ + if (!strcmp("transfer.hiderefs", var) || + /* NEEDSWORK: use parse_config_key() once both are merged */ + (starts_with(var, section) && var[strlen(section)] == '.' && + !strcmp(var + strlen(section), ".hiderefs"))) { + char *ref; + int len; + + if (!value) + return config_error_nonbool(var); + ref = xstrdup(value); + len = strlen(ref); + while (len && ref[len - 1] == '/') + ref[--len] = '\0'; + if (!hide_refs) { + hide_refs = xcalloc(1, sizeof(*hide_refs)); + hide_refs->strdup_strings = 1; + } + string_list_append(hide_refs, ref); + } + return 0; +} + +int ref_is_hidden(const char *refname) +{ + int i; + + if (!hide_refs) + return 0; + for (i = hide_refs->nr - 1; i >= 0; i--) { + const char *match = hide_refs->items[i].string; + int neg = 0; + int len; + if (*match == '!') { + neg = 1; + match++; + } + + if (!starts_with(refname, match)) + continue; + len = strlen(match); + if (!refname[len] || refname[len] == '/') + return !neg; + } + return 0; +} -- 2.4.2.644.g97b850b-twtrsrc -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html