118
int midx_must_contain_cruft;
119
};
120
121
-static int midx_has_unknown_packs(char **midx_pack_names,
122
- size_t midx_pack_names_nr,
121
+static int midx_has_unknown_packs(struct string_list *midx_pack_names,
122
struct string_list *include,
123
struct pack_geometry *geometry,
124
struct existing_packs *existing)
125
{
127
- size_t i;
126
+ struct string_list_item *item;
127
128
string_list_sort(include);
129
131
- for (i = 0; i < midx_pack_names_nr; i++) {
132
- const char *pack_name = midx_pack_names[i];
130
+ for_each_string_list_item(item, midx_pack_names) {
131
+ const char *pack_name = item->string;
132
133
/*
134
* Determine whether or not each MIDX'd pack from the existing
190
191
static void midx_included_packs(struct string_list *include,
192
struct existing_packs *existing,
194
- char **midx_pack_names,
195
- size_t midx_pack_names_nr,
193
+ struct string_list *midx_pack_names,
194
struct string_list *names,
195
struct pack_geometry *geometry)
196
{
245
}
246
247
if (midx_must_contain_cruft ||
250
- midx_has_unknown_packs(midx_pack_names, midx_pack_names_nr,
251
- include, geometry, existing)) {
248
+ midx_has_unknown_packs(midx_pack_names, include, geometry,
249
+ existing)) {
250
/*
251
* If there are one or more unknown pack(s) present (see
252
* midx_has_unknown_packs() for what makes a pack
604
struct child_process cmd = CHILD_PROCESS_INIT;
605
struct string_list_item *item;
606
struct string_list names = STRING_LIST_INIT_DUP;
607
+ struct string_list midx_pack_names = STRING_LIST_INIT_DUP;
608
struct existing_packs existing = EXISTING_PACKS_INIT;
609
struct pack_geometry geometry = { 0 };
610
struct tempfile *refs_snapshot = NULL;
611
int i, ret;
612
int show_progress;
614
- char **midx_pack_names = NULL;
615
- size_t midx_pack_names_nr = 0;
613
614
/* variables to be filled by option parsing */
615
struct repack_config_ctx config_ctx;
982
struct multi_pack_index *m =
983
get_multi_pack_index(repo->objects->sources);
984
988
- ALLOC_ARRAY(midx_pack_names,
989
- m->num_packs + m->num_packs_in_base);
990
-
991
- for (; m; m = m->base_midx)
992
- for (uint32_t i = 0; i < m->num_packs; i++)
993
- midx_pack_names[midx_pack_names_nr++] =
994
- xstrdup(m->pack_names[i]);
985
+ for (; m; m = m->base_midx) {
986
+ for (uint32_t i = 0; i < m->num_packs; i++) {
987
+ string_list_append(&midx_pack_names,
988
+ m->pack_names[i]);
989
+ }
990
+ }
991
}
992
993
close_object_store(repo->objects);
1015
.write_bitmaps = write_bitmaps > 0,
1016
.midx_must_contain_cruft = midx_must_contain_cruft
1017
};
1022
- midx_included_packs(&include, &existing, midx_pack_names,
1023
- midx_pack_names_nr, &names, &geometry);
1018
+ midx_included_packs(&include, &existing, &midx_pack_names,
1019
+ &names, &geometry);
1020
1021
ret = write_midx_included_packs(&opts);
1022
1063
cleanup:
1064
string_list_clear(&keep_pack_list, 0);
1065
string_list_clear(&names, 1);
1066
+ string_list_clear(&midx_pack_names, 0);
1067
existing_packs_release(&existing);
1068
pack_geometry_release(&geometry);
1072
- for (size_t i = 0; i < midx_pack_names_nr; i++)
1073
- free(midx_pack_names[i]);
1074
- free(midx_pack_names);
1069
pack_objects_args_release(&po_args);
1070
pack_objects_args_release(&cruft_po_args);
1071