pack-objects: use object_id in packlist_alloc()
[gitweb.git] / pack-objects.c
index ce33b8906e5c589813c7d873c9173aa3aa2afddc..c1df08df1ad27f2c684fd925cf7f564e109075b9 100644 (file)
@@ -6,17 +6,17 @@
 #include "config.h"
 
 static uint32_t locate_object_entry_hash(struct packing_data *pdata,
-                                        const unsigned char *sha1,
+                                        const struct object_id *oid,
                                         int *found)
 {
        uint32_t i, mask = (pdata->index_size - 1);
 
-       i = sha1hash(sha1) & mask;
+       i = oidhash(oid) & mask;
 
        while (pdata->index[i] > 0) {
                uint32_t pos = pdata->index[i] - 1;
 
-               if (hasheq(sha1, pdata->objects[pos].idx.oid.hash)) {
+               if (oideq(oid, &pdata->objects[pos].idx.oid)) {
                        *found = 1;
                        return i;
                }
@@ -56,7 +56,7 @@ static void rehash_objects(struct packing_data *pdata)
        for (i = 0; i < pdata->nr_objects; i++) {
                int found;
                uint32_t ix = locate_object_entry_hash(pdata,
-                                                      entry->idx.oid.hash,
+                                                      &entry->idx.oid,
                                                       &found);
 
                if (found)
@@ -68,7 +68,7 @@ static void rehash_objects(struct packing_data *pdata)
 }
 
 struct object_entry *packlist_find(struct packing_data *pdata,
-                                  const unsigned char *sha1,
+                                  const struct object_id *oid,
                                   uint32_t *index_pos)
 {
        uint32_t i;
@@ -77,7 +77,7 @@ struct object_entry *packlist_find(struct packing_data *pdata,
        if (!pdata->index_size)
                return NULL;
 
-       i = locate_object_entry_hash(pdata, sha1, &found);
+       i = locate_object_entry_hash(pdata, oid, &found);
 
        if (index_pos)
                *index_pos = i;
@@ -153,7 +153,7 @@ void prepare_packing_data(struct repository *r, struct packing_data *pdata)
 }
 
 struct object_entry *packlist_alloc(struct packing_data *pdata,
-                                   const unsigned char *sha1,
+                                   const struct object_id *oid,
                                    uint32_t index_pos)
 {
        struct object_entry *new_entry;
@@ -177,7 +177,7 @@ struct object_entry *packlist_alloc(struct packing_data *pdata,
        new_entry = pdata->objects + pdata->nr_objects++;
 
        memset(new_entry, 0, sizeof(*new_entry));
-       hashcpy(new_entry->idx.oid.hash, sha1);
+       oidcpy(&new_entry->idx.oid, oid);
 
        if (pdata->index_size * 3 <= pdata->nr_objects * 4)
                rehash_objects(pdata);