diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 76ce906946..dc2a7e9ac0 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -1147,7 +1147,7 @@ static void create_object_entry(const struct object_id *oid,
 {
 	struct object_entry *entry;
 
-	entry = packlist_alloc(&to_pack, oid->hash, index_pos);
+	entry = packlist_alloc(&to_pack, oid, index_pos);
 	entry->hash = hash;
 	oe_set_type(entry, type);
 	if (exclude)
diff --git a/pack-objects.c b/pack-objects.c
index 52560293b6..c1df08df1a 100644
--- a/pack-objects.c
+++ b/pack-objects.c
@@ -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);
diff --git a/pack-objects.h b/pack-objects.h
index 857d43850b..47bf7ebf86 100644
--- a/pack-objects.h
+++ b/pack-objects.h
@@ -183,7 +183,7 @@ static inline void packing_data_unlock(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 *packlist_find(struct packing_data *pdata,