refs.c: spell NULL pointer as NULL
[gitweb.git] / sha1_file.c
index 8c2d1ed52d6663507ff5b03bc7e5b4f4070403d1..f80bbe467437a4ffc161a4cdd09f97cf5436d4f9 100644 (file)
@@ -2126,6 +2126,16 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
                int i;
                struct delta_base_cache_entry *ent;
 
+               ent = get_delta_base_cache_entry(p, curpos);
+               if (eq_delta_base_cache_entry(ent, p, curpos)) {
+                       type = ent->type;
+                       data = ent->data;
+                       size = ent->size;
+                       clear_delta_base_cache_entry(ent);
+                       base_from_cache = 1;
+                       break;
+               }
+
                if (do_check_packed_object_crc && p->index_version > 1) {
                        struct revindex_entry *revidx = find_pack_revindex(p, obj_offset);
                        unsigned long len = revidx[1].offset - obj_offset;
@@ -2140,16 +2150,6 @@ void *unpack_entry(struct packed_git *p, off_t obj_offset,
                        }
                }
 
-               ent = get_delta_base_cache_entry(p, curpos);
-               if (eq_delta_base_cache_entry(ent, p, curpos)) {
-                       type = ent->type;
-                       data = ent->data;
-                       size = ent->size;
-                       clear_delta_base_cache_entry(ent);
-                       base_from_cache = 1;
-                       break;
-               }
-
                type = unpack_object_header(p, &w_curs, &curpos, &size);
                if (type != OBJ_OFS_DELTA && type != OBJ_REF_DELTA)
                        break;
@@ -2995,7 +2995,10 @@ int has_sha1_file(const unsigned char *sha1)
 
        if (find_pack_entry(sha1, &e))
                return 1;
-       return has_loose_object(sha1);
+       if (has_loose_object(sha1))
+               return 1;
+       reprepare_packed_git();
+       return find_pack_entry(sha1, &e);
 }
 
 static void check_tree(const void *buf, size_t size)