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 <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Feb 5, 2011 at 21:03 UTC
c4d9986f5f35c22010ed6dd58351b89fd4ee0def
1 file changed
+8
sha1_file.c
+8
@@ -2020,9 +2020,17 @@ static int sha1_loose_object_info(const unsigned char *sha1, unsigned long *size
2020
2021
int sha1_object_info(const unsigned char *sha1, unsigned long *sizep)
2022
{
2023
+ struct cached_object *co;
2024
struct pack_entry e;
2025
int status;
2026
2027
+ co = find_cached_object(sha1);
2028
+ if (co) {
2029
+ if (sizep)
2030
+ *sizep = co->size;
2031
+ return co->type;
2032
+ }
2033
+
2034
if (!find_pack_entry(sha1, &e)) {
2035
/* Most likely it's a loose object. */
2036
status = sha1_loose_object_info(sha1, sizep);