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>
Stefan Beller committed
May 8, 2018 at 12:37 UTC
346a817a7271b58811a8004fa225ab88bc94e9c3
1 file changed
+8
-8
object.c
+8
-8
@@ -116,27 +116,27 @@ struct object *lookup_object(const unsigned char *sha1)
116
* power of 2 (but at least 32). Copy the existing values to the new
117
* hash map.
118
*/
119
-#define grow_object_hash(r) grow_object_hash_##r()
120
-static void grow_object_hash_the_repository(void)
119
+static void grow_object_hash(struct repository *r)
120
{
121
int i;
122
/*
123
* Note that this size must always be power-of-2 to match hash_obj
124
* above.
125
*/
127
- int new_hash_size = the_repository->parsed_objects->obj_hash_size < 32 ? 32 : 2 * the_repository->parsed_objects->obj_hash_size;
126
+ int new_hash_size = r->parsed_objects->obj_hash_size < 32 ? 32 : 2 * r->parsed_objects->obj_hash_size;
127
struct object **new_hash;
128
129
new_hash = xcalloc(new_hash_size, sizeof(struct object *));
131
- for (i = 0; i < the_repository->parsed_objects->obj_hash_size; i++) {
132
- struct object *obj = the_repository->parsed_objects->obj_hash[i];
130
+ for (i = 0; i < r->parsed_objects->obj_hash_size; i++) {
131
+ struct object *obj = r->parsed_objects->obj_hash[i];
132
+
133
if (!obj)
134
continue;
135
insert_obj_hash(obj, new_hash, new_hash_size);
136
}
137
- free(the_repository->parsed_objects->obj_hash);
138
- the_repository->parsed_objects->obj_hash = new_hash;
139
- the_repository->parsed_objects->obj_hash_size = new_hash_size;
137
+ free(r->parsed_objects->obj_hash);
138
+ r->parsed_objects->obj_hash = new_hash;
139
+ r->parsed_objects->obj_hash_size = new_hash_size;
140
}
141
142
void *create_object_the_repository(const unsigned char *sha1, void *o)