Skip to content

Commit 346a817

Browse files
stefanbellergitster
authored andcommitted
object: allow grow_object_hash to handle arbitrary repositories
Reviewed-by: Jonathan Tan <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent dd5d9de commit 346a817

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

object.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,27 +116,27 @@ struct object *lookup_object(const unsigned char *sha1)
116116
* power of 2 (but at least 32). Copy the existing values to the new
117117
* hash map.
118118
*/
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)
121120
{
122121
int i;
123122
/*
124123
* Note that this size must always be power-of-2 to match hash_obj
125124
* above.
126125
*/
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;
128127
struct object **new_hash;
129128

130129
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+
133133
if (!obj)
134134
continue;
135135
insert_obj_hash(obj, new_hash, new_hash_size);
136136
}
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;
140140
}
141141

142142
void *create_object_the_repository(const unsigned char *sha1, void *o)

0 commit comments

Comments
 (0)