git_object_lookup() should also check the type if the object comes from the cache

This commit is contained in:
Ben Noordhuis 2011-03-14 00:07:37 +01:00 committed by Vicent Marti
parent 7c8a7b9143
commit bd1aa741a4

View File

@ -276,6 +276,9 @@ int git_object_lookup(git_object **object_out, git_repository *repo, const git_o
object = git_hashtable_lookup(repo->objects, id); object = git_hashtable_lookup(repo->objects, id);
if (object != NULL) { if (object != NULL) {
if (type != GIT_OBJ_ANY && type != object->source.raw.type)
return GIT_EINVALIDTYPE;
*object_out = object; *object_out = object;
object->lru = ++repo->lru_counter; object->lru = ++repo->lru_counter;
object->can_free = 0; object->can_free = 0;