Merge branch 'mh/simplify-cache-tree-find'
[gitweb.git] / cache-tree.c
index 30149d1c42f94cf28e10db317ad3337c8e534ae1..587b35362f18b3e98cd9e201a2de37c1878e852b 100644 (file)
@@ -550,22 +550,19 @@ static struct cache_tree *cache_tree_find(struct cache_tree *it, const char *pat
                const char *slash;
                struct cache_tree_sub *sub;
 
-               slash = strchr(path, '/');
-               if (!slash)
-                       slash = path + strlen(path);
-               /* between path and slash is the name of the
-                * subtree to look for.
+               slash = strchrnul(path, '/');
+               /*
+                * Between path and slash is the name of the subtree
+                * to look for.
                 */
                sub = find_subtree(it, path, slash - path, 0);
                if (!sub)
                        return NULL;
                it = sub->cache_tree;
-               if (slash)
-                       while (*slash && *slash == '/')
-                               slash++;
-               if (!slash || !*slash)
-                       return it; /* prefix ended with slashes */
+
                path = slash;
+               while (*path == '/')
+                       path++;
        }
        return it;
 }