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>
This commit is contained in:
Junio C Hamano 2006-04-24 15:12:42 -07:00
Родитель 17448209f5
Коммит dd0c34c46b
1 изменённых файлов: 1 добавлений и 1 удалений

Просмотреть файл

@ -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;
/*