Merge branch 'jc/tag-contains-with'
[gitweb.git] / cache-tree.c
index 17db9f9045b675afc2c2a39f7f53682adfc8a96d..587b35362f18b3e98cd9e201a2de37c1878e852b 100644 (file)
@@ -75,11 +75,7 @@ static struct cache_tree_sub *find_subtree(struct cache_tree *it,
                return NULL;
 
        pos = -pos-1;
-       if (it->subtree_alloc <= it->subtree_nr) {
-               it->subtree_alloc = alloc_nr(it->subtree_alloc);
-               it->down = xrealloc(it->down, it->subtree_alloc *
-                                   sizeof(*it->down));
-       }
+       ALLOC_GROW(it->down, it->subtree_nr + 1, it->subtree_alloc);
        it->subtree_nr++;
 
        down = xmalloc(sizeof(*down) + pathlen + 1);
@@ -563,9 +559,10 @@ static struct cache_tree *cache_tree_find(struct cache_tree *it, const char *pat
                if (!sub)
                        return NULL;
                it = sub->cache_tree;
-               while (*slash == '/')
-                       slash++;
+
                path = slash;
+               while (*path == '/')
+                       path++;
        }
        return it;
 }