about summary refs log tree commit diff
path: root/third_party/git/pack-objects.c
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-25T23·06+0100
committerVincent Ambo <tazjin@google.com>2020-05-25T23·06+0100
commit93ba78d6f4632ef1c5228965e3edc8c0faf88c1e (patch)
tree85730c182a9f5f492ade8e8ccdb1c2356f9900bd /third_party/git/pack-objects.c
parent6f8fbf4aa4b1654ab27d4829e114538761817de0 (diff)
revert(3p/git): Revert merge of git upstream at v2.26.2 r/852
This causes cgit to serve error pages, which is undesirable.

This reverts commit 5229c9b232de5bfa959ad6ebbb4c8192ac513352, reversing
changes made to f2b211131f2347342dde63975b09cf603149f1a3.
Diffstat (limited to 'third_party/git/pack-objects.c')
-rw-r--r--third_party/git/pack-objects.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/third_party/git/pack-objects.c b/third_party/git/pack-objects.c
index f2a433885ac8..52560293b626 100644
--- a/third_party/git/pack-objects.c
+++ b/third_party/git/pack-objects.c
@@ -68,7 +68,8 @@ static void rehash_objects(struct packing_data *pdata)
 }
 
 struct object_entry *packlist_find(struct packing_data *pdata,
-				   const struct object_id *oid)
+				   const struct object_id *oid,
+				   uint32_t *index_pos)
 {
 	uint32_t i;
 	int found;
@@ -78,6 +79,9 @@ 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;
 
@@ -119,10 +123,7 @@ void oe_map_new_pack(struct packing_data *pack)
 {
 	uint32_t i;
 
-	if (pack->in_pack)
-		BUG("packing_data has already been converted to pack array");
-
-	ALLOC_ARRAY(pack->in_pack, pack->nr_alloc);
+	REALLOC_ARRAY(pack->in_pack, pack->nr_alloc);
 
 	for (i = 0; i < pack->nr_objects; i++)
 		pack->in_pack[i] = oe_in_pack(pack, pack->objects + i);
@@ -152,7 +153,8 @@ 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)
+				    const unsigned char *sha1,
+				    uint32_t index_pos)
 {
 	struct object_entry *new_entry;
 
@@ -175,19 +177,12 @@ struct object_entry *packlist_alloc(struct packing_data *pdata,
 	new_entry = pdata->objects + pdata->nr_objects++;
 
 	memset(new_entry, 0, sizeof(*new_entry));
-	oidcpy(&new_entry->idx.oid, oid);
+	hashcpy(new_entry->idx.oid.hash, sha1);
 
 	if (pdata->index_size * 3 <= pdata->nr_objects * 4)
 		rehash_objects(pdata);
-	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;
-	}
+	else
+		pdata->index[index_pos] = pdata->nr_objects;
 
 	if (pdata->in_pack)
 		pdata->in_pack[pdata->nr_objects - 1] = NULL;
@@ -203,14 +198,14 @@ struct object_entry *packlist_alloc(struct packing_data *pdata,
 
 void oe_set_delta_ext(struct packing_data *pdata,
 		      struct object_entry *delta,
-		      const struct object_id *oid)
+		      const unsigned char *sha1)
 {
 	struct object_entry *base;
 
 	ALLOC_GROW(pdata->ext_bases, pdata->nr_ext + 1, pdata->alloc_ext);
 	base = &pdata->ext_bases[pdata->nr_ext++];
 	memset(base, 0, sizeof(*base));
-	oidcpy(&base->idx.oid, oid);
+	hashcpy(base->idx.oid.hash, sha1);
 
 	/* These flags mark that we are not part of the actual pack output. */
 	base->preferred_base = 1;