builtin/repack.c: rename various pack_geometry functions
Rename functions which work with 'struct pack_geometry' to begin with "pack_geometry_". While we're at it, change `free_pack_geometry()` to instead be named `pack_geometry_release()` to match our conventions, and make clear that that function frees the contents of the struct, not the memory allocated to hold the struct itself. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Taylor Blau committed
Oct 15, 2025 at 18:28 UTC
e05c2d55668dcaa6a912372d93fb8f82d418d390
1 file changed
+26
-26
builtin/repack.c
+26
-26
@@ -115,17 +115,17 @@ struct pack_geometry {
115
int split_factor;
116
};
117
118
-static uint32_t geometry_pack_weight(struct packed_git *p)
118
+static uint32_t pack_geometry_weight(struct packed_git *p)
119
{
120
if (open_pack_index(p))
121
die(_("cannot open index for %s"), p->pack_name);
122
return p->num_objects;
123
}
124
125
-static int geometry_cmp(const void *va, const void *vb)
125
+static int pack_geometry_cmp(const void *va, const void *vb)
126
{
127
- uint32_t aw = geometry_pack_weight(*(struct packed_git **)va),
128
- bw = geometry_pack_weight(*(struct packed_git **)vb);
127
+ uint32_t aw = pack_geometry_weight(*(struct packed_git **)va),
128
+ bw = pack_geometry_weight(*(struct packed_git **)vb);
129
130
if (aw < bw)
131
return -1;
@@ -134,7 +134,7 @@ static int geometry_cmp(const void *va, const void *vb)
134
return 0;
135
}
136
137
-static void init_pack_geometry(struct pack_geometry *geometry,
137
+static void pack_geometry_init(struct pack_geometry *geometry,
138
struct existing_packs *existing,
139
const struct pack_objects_args *args)
140
{
@@ -184,11 +184,11 @@ static void init_pack_geometry(struct pack_geometry *geometry,
184
geometry->pack_nr++;
185
}
186
187
- QSORT(geometry->pack, geometry->pack_nr, geometry_cmp);
187
+ QSORT(geometry->pack, geometry->pack_nr, pack_geometry_cmp);
188
strbuf_release(&buf);
189
}
190
191
-static void split_pack_geometry(struct pack_geometry *geometry)
191
+static void pack_geometry_split(struct pack_geometry *geometry)
192
{
193
uint32_t i;
194
uint32_t split;
@@ -208,13 +208,13 @@ static void split_pack_geometry(struct pack_geometry *geometry)
208
struct packed_git *prev = geometry->pack[i - 1];
209
210
if (unsigned_mult_overflows(geometry->split_factor,
211
- geometry_pack_weight(prev)))
211
+ pack_geometry_weight(prev)))
212
die(_("pack %s too large to consider in geometric "
213
"progression"),
214
prev->pack_name);
215
216
- if (geometry_pack_weight(ours) <
217
- geometry->split_factor * geometry_pack_weight(prev))
216
+ if (pack_geometry_weight(ours) <
217
+ geometry->split_factor * pack_geometry_weight(prev))
218
break;
219
}
220
@@ -242,9 +242,9 @@ static void split_pack_geometry(struct pack_geometry *geometry)
242
for (i = 0; i < split; i++) {
243
struct packed_git *p = geometry->pack[i];
244
245
- if (unsigned_add_overflows(total_size, geometry_pack_weight(p)))
245
+ if (unsigned_add_overflows(total_size, pack_geometry_weight(p)))
246
die(_("pack %s too large to roll up"), p->pack_name);
247
- total_size += geometry_pack_weight(p);
247
+ total_size += pack_geometry_weight(p);
248
}
249
for (i = split; i < geometry->pack_nr; i++) {
250
struct packed_git *ours = geometry->pack[i];
@@ -253,15 +253,15 @@ static void split_pack_geometry(struct pack_geometry *geometry)
253
total_size))
254
die(_("pack %s too large to roll up"), ours->pack_name);
255
256
- if (geometry_pack_weight(ours) <
256
+ if (pack_geometry_weight(ours) <
257
geometry->split_factor * total_size) {
258
if (unsigned_add_overflows(total_size,
259
- geometry_pack_weight(ours)))
259
+ pack_geometry_weight(ours)))
260
die(_("pack %s too large to roll up"),
261
ours->pack_name);
262
263
split++;
264
- total_size += geometry_pack_weight(ours);
264
+ total_size += pack_geometry_weight(ours);
265
} else
266
break;
267
}
@@ -269,7 +269,7 @@ static void split_pack_geometry(struct pack_geometry *geometry)
269
geometry->split = split;
270
}
271
272
-static struct packed_git *get_preferred_pack(struct pack_geometry *geometry)
272
+static struct packed_git *pack_geometry_preferred_pack(struct pack_geometry *geometry)
273
{
274
uint32_t i;
275
@@ -304,9 +304,9 @@ static struct packed_git *get_preferred_pack(struct pack_geometry *geometry)
304
return NULL;
305
}
306
307
-static void geometry_remove_redundant_packs(struct pack_geometry *geometry,
308
- struct string_list *names,
309
- struct existing_packs *existing)
307
+static void pack_geometry_remove_redundant(struct pack_geometry *geometry,
308
+ struct string_list *names,
309
+ struct existing_packs *existing)
310
{
311
const struct git_hash_algo *algop = existing->repo->hash_algo;
312
struct strbuf buf = STRBUF_INIT;
@@ -332,7 +332,7 @@ static void geometry_remove_redundant_packs(struct pack_geometry *geometry,
332
strbuf_release(&buf);
333
}
334
335
-static void free_pack_geometry(struct pack_geometry *geometry)
335
+static void pack_geometry_release(struct pack_geometry *geometry)
336
{
337
if (!geometry)
338
return;
@@ -599,7 +599,7 @@ static int write_midx_included_packs(struct string_list *include,
599
{
600
struct child_process cmd = CHILD_PROCESS_INIT;
601
struct string_list_item *item;
602
- struct packed_git *preferred = get_preferred_pack(geometry);
602
+ struct packed_git *preferred = pack_geometry_preferred_pack(geometry);
603
FILE *in;
604
int ret;
605
@@ -1063,8 +1063,8 @@ int cmd_repack(int argc,
1063
if (geometry.split_factor) {
1064
if (pack_everything)
1065
die(_("options '%s' and '%s' cannot be used together"), "--geometric", "-A/-a");
1066
- init_pack_geometry(&geometry, &existing, &po_args);
1067
- split_pack_geometry(&geometry);
1066
+ pack_geometry_init(&geometry, &existing, &po_args);
1067
+ pack_geometry_split(&geometry);
1068
}
1069
1070
prepare_pack_objects(&cmd, &po_args, packtmp);
@@ -1324,8 +1324,8 @@ int cmd_repack(int argc,
1324
existing_packs_remove_redundant(&existing, packdir);
1325
1326
if (geometry.split_factor)
1327
- geometry_remove_redundant_packs(&geometry, &names,
1328
- &existing);
1327
+ pack_geometry_remove_redundant(&geometry, &names,
1328
+ &existing);
1329
if (show_progress)
1330
opts |= PRUNE_PACKED_VERBOSE;
1331
prune_packed_objects(opts);
@@ -1352,7 +1352,7 @@ cleanup:
1352
string_list_clear(&keep_pack_list, 0);
1353
string_list_clear(&names, 1);
1354
existing_packs_release(&existing);
1355
- free_pack_geometry(&geometry);
1355
+ pack_geometry_release(&geometry);
1356
for (size_t i = 0; i < midx_pack_names_nr; i++)
1357
free(midx_pack_names[i]);
1358
free(midx_pack_names);