This change moves the hidden refs functions to the refs.c file since these functions do not contain any backend specific code. Signed-off-by: Ronnie Sahlberg <sahlberg@xxxxxxxxxx> --- refs-be-files.c | 43 ------------------------------------------- refs.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 43 deletions(-) diff --git a/refs-be-files.c b/refs-be-files.c index 52ca0bb..6181edf 100644 --- a/refs-be-files.c +++ b/refs-be-files.c @@ -3796,46 +3796,3 @@ char *shorten_unambiguous_ref(const char *refname, int strict) free(short_name); 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) -{ - struct string_list_item *item; - - if (!hide_refs) - return 0; - for_each_string_list_item(item, hide_refs) { - int len; - if (!starts_with(refname, item->string)) - continue; - len = strlen(item->string); - if (!refname[len] || refname[len] == '/') - return 1; - } - return 0; -} diff --git a/refs.c b/refs.c index 072cd39..9e2059b 100644 --- a/refs.c +++ b/refs.c @@ -3,6 +3,7 @@ */ #include "cache.h" #include "refs.h" +#include "string-list.h" int update_ref(const char *action, const char *refname, const unsigned char *sha1, const unsigned char *oldval, @@ -251,3 +252,46 @@ int read_ref_at(const char *refname, unsigned long at_time, int cnt, 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) +{ + struct string_list_item *item; + + if (!hide_refs) + return 0; + for_each_string_list_item(item, hide_refs) { + int len; + if (!starts_with(refname, item->string)) + continue; + len = strlen(item->string); + if (!refname[len] || refname[len] == '/') + return 1; + } + return 0; +} -- 2.0.1.552.g1af257a -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html