]> git.ipfire.org Git - thirdparty/git.git/blobdiff - packfile.c
l10n: fr v2.24.0 rnd2
[thirdparty/git.git] / packfile.c
index 3edd648de0855927df0982ac43d32d3103d6584b..355066de17514e1a2cf8456e6d55d871bf15f09b 100644 (file)
@@ -6,7 +6,6 @@
 #include "mergesort.h"
 #include "packfile.h"
 #include "delta.h"
-#include "list.h"
 #include "streaming.h"
 #include "sha1-lookup.h"
 #include "commit.h"
 #include "object-store.h"
 #include "midx.h"
 #include "commit-graph.h"
+#include "promisor-remote.h"
 
 char *odb_pack_name(struct strbuf *buf,
-                   const unsigned char *sha1,
+                   const unsigned char *hash,
                    const char *ext)
 {
        strbuf_reset(buf);
        strbuf_addf(buf, "%s/pack/pack-%s.%s", get_object_directory(),
-                   sha1_to_hex(sha1), ext);
+                   hash_to_hex(hash), ext);
        return buf->buf;
 }
 
@@ -287,13 +287,6 @@ static int unuse_one_window(struct packed_git *current)
        return 0;
 }
 
-void release_pack_memory(size_t need)
-{
-       size_t cur = pack_mapped;
-       while (need >= (cur - pack_mapped) && unuse_one_window(NULL))
-               ; /* nothing */
-}
-
 void close_pack_windows(struct packed_git *p)
 {
        while (p->windows) {
@@ -710,23 +703,12 @@ void unuse_pack(struct pack_window **w_cursor)
        }
 }
 
-static void try_to_free_pack_memory(size_t size)
-{
-       release_pack_memory(size);
-}
-
 struct packed_git *add_packed_git(const char *path, size_t path_len, int local)
 {
-       static int have_set_try_to_free_routine;
        struct stat st;
        size_t alloc;
        struct packed_git *p;
 
-       if (!have_set_try_to_free_routine) {
-               have_set_try_to_free_routine = 1;
-               set_try_to_free_routine(try_to_free_pack_memory);
-       }
-
        /*
         * Make sure a corresponding .pack file exists and that
         * the index looks sane.
@@ -1381,7 +1363,7 @@ static unsigned int pack_entry_hash(struct packed_git *p, off_t base_offset)
 static struct delta_base_cache_entry *
 get_delta_base_cache_entry(struct packed_git *p, off_t base_offset)
 {
-       struct hashmap_entry entry;
+       struct hashmap_entry entry, *e;
        struct delta_base_cache_key key;
 
        if (!delta_base_cache.cmpfn)
@@ -1390,7 +1372,8 @@ get_delta_base_cache_entry(struct packed_git *p, off_t base_offset)
        hashmap_entry_init(&entry, pack_entry_hash(p, base_offset));
        key.p = p;
        key.base_offset = base_offset;
-       return hashmap_get(&delta_base_cache, &entry, &key);
+       e = hashmap_get(&delta_base_cache, &entry, &key);
+       return e ? container_of(e, struct delta_base_cache_entry, ent) : NULL;
 }
 
 static int delta_base_cache_key_eq(const struct delta_base_cache_key *a,
@@ -1400,11 +1383,16 @@ static int delta_base_cache_key_eq(const struct delta_base_cache_key *a,
 }
 
 static int delta_base_cache_hash_cmp(const void *unused_cmp_data,
-                                    const void *va, const void *vb,
+                                    const struct hashmap_entry *va,
+                                    const struct hashmap_entry *vb,
                                     const void *vkey)
 {
-       const struct delta_base_cache_entry *a = va, *b = vb;
+       const struct delta_base_cache_entry *a, *b;
        const struct delta_base_cache_key *key = vkey;
+
+       a = container_of(va, const struct delta_base_cache_entry, ent);
+       b = container_of(vb, const struct delta_base_cache_entry, ent);
+
        if (key)
                return !delta_base_cache_key_eq(&a->key, key);
        else
@@ -2139,7 +2127,7 @@ static int add_promisor_object(const struct object_id *oid,
                        oidset_insert(set, &parents->item->object.oid);
        } else if (obj->type == OBJ_TAG) {
                struct tag *tag = (struct tag *) obj;
-               oidset_insert(set, &tag->tagged->oid);
+               oidset_insert(set, get_tagged_oid(tag));
        }
        return 0;
 }
@@ -2150,7 +2138,7 @@ int is_promisor_object(const struct object_id *oid)
        static int promisor_objects_prepared;
 
        if (!promisor_objects_prepared) {
-               if (repository_format_partial_clone) {
+               if (has_promisor_remote()) {
                        for_each_packed_object(add_promisor_object,
                                               &promisor_objects,
                                               FOR_EACH_OBJECT_PROMISOR_ONLY);