aboutsummaryrefslogtreecommitdiff
path: root/cache-tree.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-04-24 15:12:42 -0700
committerJunio C Hamano <junkio@cox.net>2006-04-24 15:12:42 -0700
commitdd0c34c46bdda0c20fd92d00516e711a4c9f7837 (patch)
treed2c8809120d3a174089775e6bd60dd104f187bde /cache-tree.c
parent17448209f5441718c69642871c85a80f00d12b43 (diff)
downloadgit-dd0c34c46bdda0c20fd92d00516e711a4c9f7837.tar.gz
git-dd0c34c46bdda0c20fd92d00516e711a4c9f7837.tar.xz
cache-tree: protect against "git prune".
We reused the cache-tree data without verifying the tree object still exists. Recompute in cache_tree_update() an otherwise valid cache-tree entry when the tree object disappeared. This is not usually a problem, but theoretically without this fix things can break when the user does something like this: - read-index from a side branch - write-tree the result - remove the side branch with "git branch -D" - remove the unreachable objects with "git prune" - write-tree what is in the index. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'cache-tree.c')
-rw-r--r--cache-tree.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/cache-tree.c b/cache-tree.c
index f6d1dd1d7..b34b0bc31 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -177,7 +177,7 @@ static int update_one(struct cache_tree *it,
char *buffer;
int i;
- if (0 <= it->entry_count)
+ if (0 <= it->entry_count && has_sha1_file(it->sha1))
return it->entry_count;
/*