summaryrefslogtreecommitdiff
path: root/cache-tree.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-03-18 13:51:02 -0700
committerJunio C Hamano <gitster@pobox.com>2014-03-18 13:51:02 -0700
commitda2e0579adad88136b8a0a850d7325c398a401ac (patch)
treee287a91e0ceb79b1e76f266a3c80ebb5a86ce9c2 /cache-tree.c
parent6bd34241760125481e170bff40b278a41f3d80db (diff)
parent3491047e14532f4c01e3459d59d914d9598721c5 (diff)
downloadgit-da2e0579adad88136b8a0a850d7325c398a401ac.tar.gz
Merge branch 'mh/simplify-cache-tree-find'
* mh/simplify-cache-tree-find: cache_tree_find(): use path variable when passing over slashes cache_tree_find(): remove early return cache_tree_find(): remove redundant check cache_tree_find(): fix comment formatting cache_tree_find(): find the end of path component using strchrnul() cache_tree_find(): remove redundant checks
Diffstat (limited to 'cache-tree.c')
-rw-r--r--cache-tree.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/cache-tree.c b/cache-tree.c
index 30149d1c42..587b35362f 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -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;
}