]> git.ipfire.org Git - thirdparty/git.git/blobdiff - packfile.c
Merge branch 'rs/hashwrite-be64'
[thirdparty/git.git] / packfile.c
index bfe76b2119e0d37fce028e30462de3999443d1ba..0929ebe4fc747fc52c98d45542d9b257dc25a31d 100644 (file)
@@ -923,6 +923,7 @@ unsigned long repo_approximate_object_count(struct repository *r)
                        count += p->num_objects;
                }
                r->objects->approximate_object_count = count;
+               r->objects->approximate_object_count_valid = 1;
        }
        return r->objects->approximate_object_count;
 }
@@ -1027,6 +1028,17 @@ struct multi_pack_index *get_multi_pack_index(struct repository *r)
        return r->objects->multi_pack_index;
 }
 
+struct multi_pack_index *get_local_multi_pack_index(struct repository *r)
+{
+       struct multi_pack_index *m = get_multi_pack_index(r);
+
+       /* no need to iterate; we always put the local one first (if any) */
+       if (m && m->local)
+               return m;
+
+       return NULL;
+}
+
 struct packed_git *get_all_packs(struct repository *r)
 {
        struct multi_pack_index *m;
@@ -1463,7 +1475,7 @@ void clear_delta_base_cache(void)
 static void add_delta_base_cache(struct packed_git *p, off_t base_offset,
        void *base, unsigned long base_size, enum object_type type)
 {
-       struct delta_base_cache_entry *ent = xmalloc(sizeof(*ent));
+       struct delta_base_cache_entry *ent;
        struct list_head *lru, *tmp;
 
        /*
@@ -1471,8 +1483,10 @@ static void add_delta_base_cache(struct packed_git *p, off_t base_offset,
         * is unpacking the same object, in unpack_entry() (since its phases I
         * and III might run concurrently across multiple threads).
         */
-       if (in_delta_base_cache(p, base_offset))
+       if (in_delta_base_cache(p, base_offset)) {
+               free(base);
                return;
+       }
 
        delta_base_cached += base_size;
 
@@ -1484,6 +1498,7 @@ static void add_delta_base_cache(struct packed_git *p, off_t base_offset,
                release_delta_base_cache(f);
        }
 
+       ent = xmalloc(sizeof(*ent));
        ent->key.p = p;
        ent->key.base_offset = base_offset;
        ent->type = type;