Code clean-up.
* rs/more-uses-of-skip-prefix:
pack-write: simplify index_pack_lockfile using skip_prefix() and xstrfmt()
connect: simplify check_ref() using skip_prefix() and starts_with()
static int check_ref(const char *name, int len, unsigned int flags)
static int check_ref(const char *name, unsigned int flags)
{
if (!flags)
return 1;
if (len < 5 || memcmp(name, "refs/", 5))
if (!skip_prefix(name, "refs/", &name))
return 0;
/* Skip the "refs/" part */
name += 5;
len -= 5;
/* REF_NORMAL means that we don't want the magic fake tag refs */
if ((flags & REF_NORMAL) && check_refname_format(name, 0))
return 0;
/* REF_HEADS means that we want regular branch heads */
if ((flags & REF_HEADS) && !memcmp(name, "heads/", 6))
if ((flags & REF_HEADS) && starts_with(name, "heads/"))
return 1;
/* REF_TAGS means that we want tags */
if ((flags & REF_TAGS) && !memcmp(name, "tags/", 5))
if ((flags & REF_TAGS) && starts_with(name, "tags/"))
return 1;
/* All type bits clear means that we are ok with anything */
@ -43,7 +39,7 @@ static int check_ref(const char *name, int len, unsigned int flags)
@@ -43,7 +39,7 @@ static int check_ref(const char *name, int len, unsigned int flags)
int check_ref_type(const struct ref *ref, int flags)