]> git.ipfire.org Git - thirdparty/git.git/blobdiff - packfile.c
refs: unify parse_worktree_ref() and ref_type()
[thirdparty/git.git] / packfile.c
index 6b0eb9048ecc3e04f3fc839a3d687866a6f0b910..c0d7dd93f46dfbc07ea0f17839d4a2d1a9d43622 100644 (file)
@@ -1392,7 +1392,7 @@ static int delta_base_cache_key_eq(const struct delta_base_cache_key *a,
        return a->p == b->p && a->base_offset == b->base_offset;
 }
 
-static int delta_base_cache_hash_cmp(const void *unused_cmp_data,
+static int delta_base_cache_hash_cmp(const void *cmp_data UNUSED,
                                     const struct hashmap_entry *va,
                                     const struct hashmap_entry *vb,
                                     const void *vkey)
@@ -2217,7 +2217,17 @@ static int add_promisor_object(const struct object_id *oid,
                               void *set_)
 {
        struct oidset *set = set_;
-       struct object *obj = parse_object(the_repository, oid);
+       struct object *obj;
+       int we_parsed_object;
+
+       obj = lookup_object(the_repository, oid);
+       if (obj && obj->parsed) {
+               we_parsed_object = 0;
+       } else {
+               we_parsed_object = 1;
+               obj = parse_object(the_repository, oid);
+       }
+
        if (!obj)
                return 1;
 
@@ -2231,7 +2241,7 @@ static int add_promisor_object(const struct object_id *oid,
                struct tree *tree = (struct tree *)obj;
                struct tree_desc desc;
                struct name_entry entry;
-               if (init_tree_desc_gently(&desc, tree->buffer, tree->size))
+               if (init_tree_desc_gently(&desc, tree->buffer, tree->size, 0))
                        /*
                         * Error messages are given when packs are
                         * verified, so do not print any here.
@@ -2239,7 +2249,8 @@ static int add_promisor_object(const struct object_id *oid,
                        return 0;
                while (tree_entry_gently(&desc, &entry))
                        oidset_insert(set, &entry.oid);
-               free_tree_buffer(tree);
+               if (we_parsed_object)
+                       free_tree_buffer(tree);
        } else if (obj->type == OBJ_COMMIT) {
                struct commit *commit = (struct commit *) obj;
                struct commit_list *parents = commit->parents;