1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-08 21:26:08 +02:00

object: allow grow_object_hash to handle arbitrary repositories

Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Stefan Beller 2018-05-08 12:37:34 -07:00 committed by Junio C Hamano
parent dd5d9deb01
commit 346a817a72

View File

@ -116,27 +116,27 @@ struct object *lookup_object(const unsigned char *sha1)
* power of 2 (but at least 32). Copy the existing values to the new
* hash map.
*/
#define grow_object_hash(r) grow_object_hash_##r()
static void grow_object_hash_the_repository(void)
static void grow_object_hash(struct repository *r)
{
int i;
/*
* Note that this size must always be power-of-2 to match hash_obj
* above.
*/
int new_hash_size = the_repository->parsed_objects->obj_hash_size < 32 ? 32 : 2 * the_repository->parsed_objects->obj_hash_size;
int new_hash_size = r->parsed_objects->obj_hash_size < 32 ? 32 : 2 * r->parsed_objects->obj_hash_size;
struct object **new_hash;
new_hash = xcalloc(new_hash_size, sizeof(struct object *));
for (i = 0; i < the_repository->parsed_objects->obj_hash_size; i++) {
struct object *obj = the_repository->parsed_objects->obj_hash[i];
for (i = 0; i < r->parsed_objects->obj_hash_size; i++) {
struct object *obj = r->parsed_objects->obj_hash[i];
if (!obj)
continue;
insert_obj_hash(obj, new_hash, new_hash_size);
}
free(the_repository->parsed_objects->obj_hash);
the_repository->parsed_objects->obj_hash = new_hash;
the_repository->parsed_objects->obj_hash_size = new_hash_size;
free(r->parsed_objects->obj_hash);
r->parsed_objects->obj_hash = new_hash;
r->parsed_objects->obj_hash_size = new_hash_size;
}
void *create_object_the_repository(const unsigned char *sha1, void *o)