Sync with maint
[gitweb.git] / object.c
index 34c1d0dc8f886c2c72f5b2992ea69f329ec6c918..07bdd5b26e2b10a8f4f7851e6c3d545ede23c461 100644 (file)
--- a/object.c
+++ b/object.c
@@ -59,9 +59,9 @@ int type_from_string_gently(const char *str, ssize_t len, int gentle)
  * the specified sha1.  n must be a power of 2.  Please note that the
  * return value is *not* consistent across computer architectures.
  */
-static unsigned int hash_obj(const unsigned char *sha1, unsigned int n)
+static unsigned int hash_obj(const struct object_id *oid, unsigned int n)
 {
-       return sha1hash(sha1) & (n - 1);
+       return oidhash(oid) & (n - 1);
 }
 
 /*
@@ -71,7 +71,7 @@ static unsigned int hash_obj(const unsigned char *sha1, unsigned int n)
  */
 static void insert_obj_hash(struct object *obj, struct object **hash, unsigned int size)
 {
-       unsigned int j = hash_obj(obj->oid.hash, size);
+       unsigned int j = hash_obj(&obj->oid, size);
 
        while (hash[j]) {
                j++;
@@ -93,7 +93,7 @@ struct object *lookup_object(struct repository *r, const struct object_id *oid)
        if (!r->parsed_objects->obj_hash)
                return NULL;
 
-       first = i = hash_obj(oid->hash, r->parsed_objects->obj_hash_size);
+       first = i = hash_obj(oid, r->parsed_objects->obj_hash_size);
        while ((obj = r->parsed_objects->obj_hash[i]) != NULL) {
                if (oideq(oid, &obj->oid))
                        break;
@@ -141,13 +141,13 @@ static void grow_object_hash(struct repository *r)
        r->parsed_objects->obj_hash_size = new_hash_size;
 }
 
-void *create_object(struct repository *r, const unsigned char *sha1, void *o)
+void *create_object(struct repository *r, const struct object_id *oid, void *o)
 {
        struct object *obj = o;
 
        obj->parsed = 0;
        obj->flags = 0;
-       hashcpy(obj->oid.hash, sha1);
+       oidcpy(&obj->oid, oid);
 
        if (r->parsed_objects->obj_hash_size - 1 <= r->parsed_objects->nr_objs * 2)
                grow_object_hash(r);
@@ -182,7 +182,7 @@ struct object *lookup_unknown_object(const struct object_id *oid)
 {
        struct object *obj = lookup_object(the_repository, oid);
        if (!obj)
-               obj = create_object(the_repository, oid->hash,
+               obj = create_object(the_repository, oid,
                                    alloc_object_node(the_repository));
        return obj;
 }
@@ -517,7 +517,7 @@ void raw_object_store_clear(struct raw_object_store *o)
        o->loaded_alternates = 0;
 
        INIT_LIST_HEAD(&o->packed_git_mru);
-       close_all_packs(o);
+       close_object_store(o);
        o->packed_git = NULL;
 }