summaryrefslogtreecommitdiff
path: root/cache-tree.c
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2021-01-23 19:58:13 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-01-24 01:14:07 (GMT)
commitc80dd3967f28527dab49c8e9525524c7f33baa22 (patch)
treea52012f5fed36ff5c484daf759cce6e2d73de864 /cache-tree.c
parent8d87e338e16e022545638a0e9a3e15c6bdb56111 (diff)
downloadgit-c80dd3967f28527dab49c8e9525524c7f33baa22.zip
git-c80dd3967f28527dab49c8e9525524c7f33baa22.tar.gz
git-c80dd3967f28527dab49c8e9525524c7f33baa22.tar.bz2
cache-tree: extract subtree_pos()
This method will be helpful to use outside of cache-tree.c in a later feature. The implementation is subtle due to subtree_name_cmp() sorting by length and then lexicographically. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'cache-tree.c')
-rw-r--r--cache-tree.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/cache-tree.c b/cache-tree.c
index acac6d5..2fb483d 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -45,7 +45,7 @@ static int subtree_name_cmp(const char *one, int onelen,
return memcmp(one, two, onelen);
}
-static int subtree_pos(struct cache_tree *it, const char *path, int pathlen)
+int cache_tree_subtree_pos(struct cache_tree *it, const char *path, int pathlen)
{
struct cache_tree_sub **down = it->down;
int lo, hi;
@@ -72,7 +72,7 @@ static struct cache_tree_sub *find_subtree(struct cache_tree *it,
int create)
{
struct cache_tree_sub *down;
- int pos = subtree_pos(it, path, pathlen);
+ int pos = cache_tree_subtree_pos(it, path, pathlen);
if (0 <= pos)
return it->down[pos];
if (!create)
@@ -123,7 +123,7 @@ static int do_invalidate_path(struct cache_tree *it, const char *path)
it->entry_count = -1;
if (!*slash) {
int pos;
- pos = subtree_pos(it, path, namelen);
+ pos = cache_tree_subtree_pos(it, path, namelen);
if (0 <= pos) {
cache_tree_free(&it->down[pos]->cache_tree);
free(it->down[pos]);