Skip to content

Commit

Permalink
sha1_object_info: examine cached_object store too
Browse files Browse the repository at this point in the history
Cached object store was added in d66b37b (Add pretend_sha1_file()
interface. - 2007-02-04) as a way to temporarily inject some objects
to object store.

But only read_sha1_file() knows about this store. While it will return
an object from this store, sha1_object_info() will happily say
"object not found".

Teach sha1_object_info() about the cached store for consistency.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Feb 7, 2011
1 parent c597ba8 commit c4d9986
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2020,9 +2020,17 @@ static int sha1_loose_object_info(const unsigned char *sha1, unsigned long *size

int sha1_object_info(const unsigned char *sha1, unsigned long *sizep)
{
struct cached_object *co;
struct pack_entry e;
int status;

co = find_cached_object(sha1);
if (co) {
if (sizep)
*sizep = co->size;
return co->type;
}

if (!find_pack_entry(sha1, &e)) {
/* Most likely it's a loose object. */
status = sha1_loose_object_info(sha1, sizep);
Expand Down

0 comments on commit c4d9986

Please sign in to comment.