]> git.ipfire.org Git - thirdparty/git.git/blobdiff - pack-objects.c
Merge branch 'jt/delay-fetch-if-missing'
[thirdparty/git.git] / pack-objects.c
index c1df08df1ad27f2c684fd925cf7f564e109075b9..c6250d77f4dec714de1073ccc0260309c24f6312 100644 (file)
@@ -68,8 +68,7 @@ static void rehash_objects(struct packing_data *pdata)
 }
 
 struct object_entry *packlist_find(struct packing_data *pdata,
-                                  const struct object_id *oid,
-                                  uint32_t *index_pos)
+                                  const struct object_id *oid)
 {
        uint32_t i;
        int found;
@@ -79,9 +78,6 @@ struct object_entry *packlist_find(struct packing_data *pdata,
 
        i = locate_object_entry_hash(pdata, oid, &found);
 
-       if (index_pos)
-               *index_pos = i;
-
        if (!found)
                return NULL;
 
@@ -153,8 +149,7 @@ void prepare_packing_data(struct repository *r, struct packing_data *pdata)
 }
 
 struct object_entry *packlist_alloc(struct packing_data *pdata,
-                                   const struct object_id *oid,
-                                   uint32_t index_pos)
+                                   const struct object_id *oid)
 {
        struct object_entry *new_entry;
 
@@ -181,8 +176,15 @@ struct object_entry *packlist_alloc(struct packing_data *pdata,
 
        if (pdata->index_size * 3 <= pdata->nr_objects * 4)
                rehash_objects(pdata);
-       else
-               pdata->index[index_pos] = pdata->nr_objects;
+       else {
+               int found;
+               uint32_t pos = locate_object_entry_hash(pdata,
+                                                       &new_entry->idx.oid,
+                                                       &found);
+               if (found)
+                       BUG("duplicate object inserted into hash");
+               pdata->index[pos] = pdata->nr_objects;
+       }
 
        if (pdata->in_pack)
                pdata->in_pack[pdata->nr_objects - 1] = NULL;