check_refname_component(): return 0 for zero-length components
[gitweb.git] / refs.c
diff --git a/refs.c b/refs.c
index 8659c3eff70d30e4ddf7b068faef563703bff886..1f6890bf486fcb3b9022ab55f35aa63edbe56bab 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -51,7 +51,7 @@ static int check_refname_component(const char *refname, int flags)
                last = ch;
        }
        if (cp == refname)
-               return -1; /* Component has zero length. */
+               return 0; /* Component has zero length. */
        if (refname[0] == '.') {
                if (!(flags & REFNAME_DOT_COMPONENT))
                        return -1; /* Component starts with '.'. */
@@ -74,7 +74,7 @@ int check_refname_format(const char *refname, int flags)
        while (1) {
                /* We are at the start of a path component. */
                component_len = check_refname_component(refname, flags);
-               if (component_len < 0) {
+               if (component_len <= 0) {
                        if ((flags & REFNAME_REFSPEC_PATTERN) &&
                                        refname[0] == '*' &&
                                        (refname[1] == '\0' || refname[1] == '/')) {