Skip to content

Commit c4d9986

Browse files
pcloudsgitster
authored andcommitted
sha1_object_info: examine cached_object store too
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c597ba8 commit c4d9986

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

sha1_file.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,9 +2020,17 @@ static int sha1_loose_object_info(const unsigned char *sha1, unsigned long *size
20202020

20212021
int sha1_object_info(const unsigned char *sha1, unsigned long *sizep)
20222022
{
2023+
struct cached_object *co;
20232024
struct pack_entry e;
20242025
int status;
20252026

2027+
co = find_cached_object(sha1);
2028+
if (co) {
2029+
if (sizep)
2030+
*sizep = co->size;
2031+
return co->type;
2032+
}
2033+
20262034
if (!find_pack_entry(sha1, &e)) {
20272035
/* Most likely it's a loose object. */
20282036
status = sha1_loose_object_info(sha1, sizep);

0 commit comments

Comments
 (0)