]> git.ipfire.org Git - thirdparty/git.git/commitdiff
sha1_object_info: examine cached_object store too
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sat, 5 Feb 2011 14:03:02 +0000 (21:03 +0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 7 Feb 2011 23:05:48 +0000 (15:05 -0800)
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>
sha1_file.c

index 9fd7e166d1451da7957fe45d1adf7f9a7767fc7e..0b830c8642fa2b141c9888c68713a29fc4df2ef2 100644 (file)
@@ -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);