summaryrefslogtreecommitdiff
path: root/cache-tree.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-04-27 01:33:07 -0700
committerJunio C Hamano <junkio@cox.net>2006-04-27 01:33:07 -0700
commit7927a55d5bde25702dca4fb1a7d6eb7ef61110ba (patch)
treeed3c465e99f20045c9e5e85d4123e2820a097066 /cache-tree.c
parentb34c39cf31e370dad3bcfba29ee8cd023c40fd6b (diff)
downloadgit-7927a55d5bde25702dca4fb1a7d6eb7ef61110ba.tar.gz
read-tree: teach 1-way merege and plain read to prime cache-tree.
This teaches read-tree to fully populate valid cache-tree when reading a tree from scratch, or reading a single tree into an existing index, reusing only the cached stat information (i.e. one-way merge). We have already taught update-index about cache-tree, so "git checkout" followed by updates to a few path followed by a "git commit" would become very efficient. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'cache-tree.c')
-rw-r--r--cache-tree.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/cache-tree.c b/cache-tree.c
index d8438d67d7..35740b3647 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -91,6 +91,12 @@ static struct cache_tree_sub *find_subtree(struct cache_tree *it,
return down;
}
+struct cache_tree_sub *cache_tree_sub(struct cache_tree *it, const char *path)
+{
+ int pathlen = strlen(path);
+ return find_subtree(it, path, pathlen, 1);
+}
+
void cache_tree_invalidate_path(struct cache_tree *it, const char *path)
{
/* a/b/c
@@ -476,12 +482,11 @@ static struct cache_tree *read_one(const char **buffer, unsigned long *size_p)
struct cache_tree *sub;
struct cache_tree_sub *subtree;
const char *name = buf;
- int namelen;
+
sub = read_one(&buf, &size);
if (!sub)
goto free_return;
- namelen = strlen(name);
- subtree = find_subtree(it, name, namelen, 1);
+ subtree = cache_tree_sub(it, name);
subtree->cache_tree = sub;
}
if (subtree_nr != it->subtree_nr)