aboutsummaryrefslogtreecommitdiff
path: root/pack-objects.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-09-30 13:19:30 +0900
committerJunio C Hamano <gitster@pobox.com>2019-09-30 13:19:30 +0900
commitd8ce144e11fef0606a531a5a9c34c2a8ca09e155 (patch)
tree92a8566d6fc7eabd26057b1ad6ae355098b9060f /pack-objects.c
parent2be6ccc01a93a96aa4a462921e15e69ed56b0792 (diff)
parent3a37876b5dca4c18bda67bcdead9c1d79a59933d (diff)
downloadgit-d8ce144e11fef0606a531a5a9c34c2a8ca09e155.tar.xz
Merge branch 'jk/misc-uninitialized-fixes'
Various fixes to codepaths gcc 9 had trouble following dataflow. * jk/misc-uninitialized-fixes: pack-objects: drop packlist index_pos optimization test-read-cache: drop namelen variable diff-delta: set size out-parameter to 0 for NULL delta bulk-checkin: zero-initialize hashfile_checkpoint pack-objects: use object_id in packlist_alloc() git-am: handle missing "author" when parsing commit
Diffstat (limited to 'pack-objects.c')
-rw-r--r--pack-objects.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/pack-objects.c b/pack-objects.c
index 52560293b6..c6250d77f4 100644
--- a/pack-objects.c
+++ b/pack-objects.c
@@ -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 unsigned char *sha1,
- uint32_t index_pos)
+ const struct object_id *oid)
{
struct object_entry *new_entry;
@@ -177,12 +172,19 @@ 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);
- 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;