Skip to content

Commit e05c2d5

Browse files
ttaylorrgitster
authored andcommitted
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>
1 parent 29e9355 commit e05c2d5

1 file changed

Lines changed: 26 additions & 26 deletions

File tree

builtin/repack.c

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,17 @@ struct pack_geometry {
115115
int split_factor;
116116
};
117117

118-
static uint32_t geometry_pack_weight(struct packed_git *p)
118+
static uint32_t pack_geometry_weight(struct packed_git *p)
119119
{
120120
if (open_pack_index(p))
121121
die(_("cannot open index for %s"), p->pack_name);
122122
return p->num_objects;
123123
}
124124

125-
static int geometry_cmp(const void *va, const void *vb)
125+
static int pack_geometry_cmp(const void *va, const void *vb)
126126
{
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);
129129

130130
if (aw < bw)
131131
return -1;
@@ -134,7 +134,7 @@ static int geometry_cmp(const void *va, const void *vb)
134134
return 0;
135135
}
136136

137-
static void init_pack_geometry(struct pack_geometry *geometry,
137+
static void pack_geometry_init(struct pack_geometry *geometry,
138138
struct existing_packs *existing,
139139
const struct pack_objects_args *args)
140140
{
@@ -184,11 +184,11 @@ static void init_pack_geometry(struct pack_geometry *geometry,
184184
geometry->pack_nr++;
185185
}
186186

187-
QSORT(geometry->pack, geometry->pack_nr, geometry_cmp);
187+
QSORT(geometry->pack, geometry->pack_nr, pack_geometry_cmp);
188188
strbuf_release(&buf);
189189
}
190190

191-
static void split_pack_geometry(struct pack_geometry *geometry)
191+
static void pack_geometry_split(struct pack_geometry *geometry)
192192
{
193193
uint32_t i;
194194
uint32_t split;
@@ -208,13 +208,13 @@ static void split_pack_geometry(struct pack_geometry *geometry)
208208
struct packed_git *prev = geometry->pack[i - 1];
209209

210210
if (unsigned_mult_overflows(geometry->split_factor,
211-
geometry_pack_weight(prev)))
211+
pack_geometry_weight(prev)))
212212
die(_("pack %s too large to consider in geometric "
213213
"progression"),
214214
prev->pack_name);
215215

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))
218218
break;
219219
}
220220

@@ -242,9 +242,9 @@ static void split_pack_geometry(struct pack_geometry *geometry)
242242
for (i = 0; i < split; i++) {
243243
struct packed_git *p = geometry->pack[i];
244244

245-
if (unsigned_add_overflows(total_size, geometry_pack_weight(p)))
245+
if (unsigned_add_overflows(total_size, pack_geometry_weight(p)))
246246
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);
248248
}
249249
for (i = split; i < geometry->pack_nr; i++) {
250250
struct packed_git *ours = geometry->pack[i];
@@ -253,23 +253,23 @@ static void split_pack_geometry(struct pack_geometry *geometry)
253253
total_size))
254254
die(_("pack %s too large to roll up"), ours->pack_name);
255255

256-
if (geometry_pack_weight(ours) <
256+
if (pack_geometry_weight(ours) <
257257
geometry->split_factor * total_size) {
258258
if (unsigned_add_overflows(total_size,
259-
geometry_pack_weight(ours)))
259+
pack_geometry_weight(ours)))
260260
die(_("pack %s too large to roll up"),
261261
ours->pack_name);
262262

263263
split++;
264-
total_size += geometry_pack_weight(ours);
264+
total_size += pack_geometry_weight(ours);
265265
} else
266266
break;
267267
}
268268

269269
geometry->split = split;
270270
}
271271

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)
273273
{
274274
uint32_t i;
275275

@@ -304,9 +304,9 @@ static struct packed_git *get_preferred_pack(struct pack_geometry *geometry)
304304
return NULL;
305305
}
306306

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)
310310
{
311311
const struct git_hash_algo *algop = existing->repo->hash_algo;
312312
struct strbuf buf = STRBUF_INIT;
@@ -332,7 +332,7 @@ static void geometry_remove_redundant_packs(struct pack_geometry *geometry,
332332
strbuf_release(&buf);
333333
}
334334

335-
static void free_pack_geometry(struct pack_geometry *geometry)
335+
static void pack_geometry_release(struct pack_geometry *geometry)
336336
{
337337
if (!geometry)
338338
return;
@@ -599,7 +599,7 @@ static int write_midx_included_packs(struct string_list *include,
599599
{
600600
struct child_process cmd = CHILD_PROCESS_INIT;
601601
struct string_list_item *item;
602-
struct packed_git *preferred = get_preferred_pack(geometry);
602+
struct packed_git *preferred = pack_geometry_preferred_pack(geometry);
603603
FILE *in;
604604
int ret;
605605

@@ -1063,8 +1063,8 @@ int cmd_repack(int argc,
10631063
if (geometry.split_factor) {
10641064
if (pack_everything)
10651065
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);
10681068
}
10691069

10701070
prepare_pack_objects(&cmd, &po_args, packtmp);
@@ -1324,8 +1324,8 @@ int cmd_repack(int argc,
13241324
existing_packs_remove_redundant(&existing, packdir);
13251325

13261326
if (geometry.split_factor)
1327-
geometry_remove_redundant_packs(&geometry, &names,
1328-
&existing);
1327+
pack_geometry_remove_redundant(&geometry, &names,
1328+
&existing);
13291329
if (show_progress)
13301330
opts |= PRUNE_PACKED_VERBOSE;
13311331
prune_packed_objects(opts);
@@ -1352,7 +1352,7 @@ int cmd_repack(int argc,
13521352
string_list_clear(&keep_pack_list, 0);
13531353
string_list_clear(&names, 1);
13541354
existing_packs_release(&existing);
1355-
free_pack_geometry(&geometry);
1355+
pack_geometry_release(&geometry);
13561356
for (size_t i = 0; i < midx_pack_names_nr; i++)
13571357
free(midx_pack_names[i]);
13581358
free(midx_pack_names);

0 commit comments

Comments
 (0)