Skip to content

Commit a0dcecb

Browse files
ttaylorrgitster
authored andcommitted
builtin/repack.c: rename many 'struct existing_packs' functions
Rename many of the 'struct existing_packs'-related functions according to the convention introduced in and described by 541204a (Documentation: document naming schema for structs and their functions, 2024-07-30). Note that some functions which operate over an individual entry in the list of existing packs are prefixed with "existing_pack_" instead of the plural form. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 7005d25 commit a0dcecb

1 file changed

Lines changed: 34 additions & 32 deletions

File tree

builtin/repack.c

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -121,39 +121,39 @@ struct existing_packs {
121121
.cruft_packs = STRING_LIST_INIT_DUP, \
122122
}
123123

124-
static int has_existing_non_kept_packs(const struct existing_packs *existing)
124+
static int existing_packs_has_non_kept(const struct existing_packs *existing)
125125
{
126126
return existing->non_kept_packs.nr || existing->cruft_packs.nr;
127127
}
128128

129-
static void pack_mark_for_deletion(struct string_list_item *item)
129+
static void existing_pack_mark_for_deletion(struct string_list_item *item)
130130
{
131131
item->util = (void*)((uintptr_t)item->util | DELETE_PACK);
132132
}
133133

134-
static void pack_unmark_for_deletion(struct string_list_item *item)
134+
static void existing_pack_unmark_for_deletion(struct string_list_item *item)
135135
{
136136
item->util = (void*)((uintptr_t)item->util & ~DELETE_PACK);
137137
}
138138

139-
static int pack_is_marked_for_deletion(struct string_list_item *item)
139+
static int existing_pack_is_marked_for_deletion(struct string_list_item *item)
140140
{
141141
return (uintptr_t)item->util & DELETE_PACK;
142142
}
143143

144-
static void pack_mark_retained(struct string_list_item *item)
144+
static void existing_packs_mark_retained(struct string_list_item *item)
145145
{
146146
item->util = (void*)((uintptr_t)item->util | RETAIN_PACK);
147147
}
148148

149-
static int pack_is_retained(struct string_list_item *item)
149+
static int existing_pack_is_retained(struct string_list_item *item)
150150
{
151151
return (uintptr_t)item->util & RETAIN_PACK;
152152
}
153153

154-
static void mark_packs_for_deletion_1(const struct git_hash_algo *algop,
155-
struct string_list *names,
156-
struct string_list *list)
154+
static void existing_packs_mark_for_deletion_1(const struct git_hash_algo *algop,
155+
struct string_list *names,
156+
struct string_list *list)
157157
{
158158
struct string_list_item *item;
159159
const int hexsz = algop->hexsz;
@@ -165,8 +165,8 @@ static void mark_packs_for_deletion_1(const struct git_hash_algo *algop,
165165
continue;
166166
sha1 = item->string + len - hexsz;
167167

168-
if (pack_is_retained(item)) {
169-
pack_unmark_for_deletion(item);
168+
if (existing_pack_is_retained(item)) {
169+
existing_pack_unmark_for_deletion(item);
170170
} else if (!string_list_has_string(names, sha1)) {
171171
/*
172172
* Mark this pack for deletion, which ensures
@@ -175,13 +175,13 @@ static void mark_packs_for_deletion_1(const struct git_hash_algo *algop,
175175
* will actually delete this pack (if `-d` was
176176
* given).
177177
*/
178-
pack_mark_for_deletion(item);
178+
existing_pack_mark_for_deletion(item);
179179
}
180180
}
181181
}
182182

183-
static void retain_cruft_pack(struct existing_packs *existing,
184-
struct packed_git *cruft)
183+
static void existing_packs_retain_cruft(struct existing_packs *existing,
184+
struct packed_git *cruft)
185185
{
186186
struct strbuf buf = STRBUF_INIT;
187187
struct string_list_item *item;
@@ -193,17 +193,19 @@ static void retain_cruft_pack(struct existing_packs *existing,
193193
if (!item)
194194
BUG("could not find cruft pack '%s'", pack_basename(cruft));
195195

196-
pack_mark_retained(item);
196+
existing_packs_mark_retained(item);
197197
strbuf_release(&buf);
198198
}
199199

200-
static void mark_packs_for_deletion(struct existing_packs *existing,
201-
struct string_list *names)
200+
static void existing_packs_mark_for_deletion(struct existing_packs *existing,
201+
struct string_list *names)
202202

203203
{
204204
const struct git_hash_algo *algop = existing->repo->hash_algo;
205-
mark_packs_for_deletion_1(algop, names, &existing->non_kept_packs);
206-
mark_packs_for_deletion_1(algop, names, &existing->cruft_packs);
205+
existing_packs_mark_for_deletion_1(algop, names,
206+
&existing->non_kept_packs);
207+
existing_packs_mark_for_deletion_1(algop, names,
208+
&existing->cruft_packs);
207209
}
208210

209211
static void remove_redundant_pack(struct repository *repo,
@@ -225,13 +227,13 @@ static void remove_redundant_packs_1(struct repository *repo,
225227
{
226228
struct string_list_item *item;
227229
for_each_string_list_item(item, packs) {
228-
if (!pack_is_marked_for_deletion(item))
230+
if (!existing_pack_is_marked_for_deletion(item))
229231
continue;
230232
remove_redundant_pack(repo, packdir, item->string);
231233
}
232234
}
233235

234-
static void remove_redundant_existing_packs(struct existing_packs *existing)
236+
static void existing_packs_remove_redundant(struct existing_packs *existing)
235237
{
236238
remove_redundant_packs_1(existing->repo, &existing->non_kept_packs);
237239
remove_redundant_packs_1(existing->repo, &existing->cruft_packs);
@@ -250,7 +252,7 @@ static void existing_packs_release(struct existing_packs *existing)
250252
* .keep file or not. Packs without a .keep file are not to be kept
251253
* if we are going to pack everything into one file.
252254
*/
253-
static void collect_pack_filenames(struct existing_packs *existing,
255+
static void existing_packs_collect(struct existing_packs *existing,
254256
const struct string_list *extra_keep)
255257
{
256258
struct packfile_store *packs = existing->repo->objects->packfiles;
@@ -721,7 +723,7 @@ static int midx_has_unknown_packs(char **midx_pack_names,
721723

722724
item = string_list_lookup(&existing->non_kept_packs,
723725
pack_name);
724-
if (item && !pack_is_marked_for_deletion(item))
726+
if (item && !existing_pack_is_marked_for_deletion(item))
725727
continue;
726728
}
727729

@@ -851,7 +853,7 @@ static void midx_included_packs(struct string_list *include,
851853
}
852854
} else {
853855
for_each_string_list_item(item, &existing->non_kept_packs) {
854-
if (pack_is_marked_for_deletion(item))
856+
if (existing_pack_is_marked_for_deletion(item))
855857
continue;
856858

857859
strbuf_reset(&buf);
@@ -888,10 +890,10 @@ static void midx_included_packs(struct string_list *include,
888890
* --geometric case, but doing so is unnecessary
889891
* since no packs are marked as pending
890892
* deletion (since we only call
891-
* `mark_packs_for_deletion()` when doing an
892-
* all-into-one repack).
893+
* `existing_packs_mark_for_deletion()` when
894+
* doing an all-into-one repack).
893895
*/
894-
if (pack_is_marked_for_deletion(item))
896+
if (existing_pack_is_marked_for_deletion(item))
895897
continue;
896898

897899
strbuf_reset(&buf);
@@ -1128,7 +1130,7 @@ static void combine_small_cruft_packs(FILE *in, size_t combine_cruft_below_size,
11281130
if (p->pack_size < combine_cruft_below_size) {
11291131
fprintf(in, "-%s\n", pack_basename(p));
11301132
} else {
1131-
retain_cruft_pack(existing, p);
1133+
existing_packs_retain_cruft(existing, p);
11321134
fprintf(in, "%s\n", pack_basename(p));
11331135
}
11341136
}
@@ -1382,7 +1384,7 @@ int cmd_repack(int argc,
13821384
packtmp = mkpathdup("%s/%s", packdir, packtmp_name);
13831385

13841386
existing.repo = repo;
1385-
collect_pack_filenames(&existing, &keep_pack_list);
1387+
existing_packs_collect(&existing, &keep_pack_list);
13861388

13871389
if (geometry.split_factor) {
13881390
if (pack_everything)
@@ -1431,7 +1433,7 @@ int cmd_repack(int argc,
14311433
if (pack_everything & ALL_INTO_ONE) {
14321434
repack_promisor_objects(repo, &po_args, &names);
14331435

1434-
if (has_existing_non_kept_packs(&existing) &&
1436+
if (existing_packs_has_non_kept(&existing) &&
14351437
delete_redundant &&
14361438
!(pack_everything & PACK_CRUFT)) {
14371439
for_each_string_list_item(item, &names) {
@@ -1647,7 +1649,7 @@ int cmd_repack(int argc,
16471649
/* End of pack replacement. */
16481650

16491651
if (delete_redundant && pack_everything & ALL_INTO_ONE)
1650-
mark_packs_for_deletion(&existing, &names);
1652+
existing_packs_mark_for_deletion(&existing, &names);
16511653

16521654
if (write_midx) {
16531655
struct string_list include = STRING_LIST_INIT_DUP;
@@ -1671,7 +1673,7 @@ int cmd_repack(int argc,
16711673

16721674
if (delete_redundant) {
16731675
int opts = 0;
1674-
remove_redundant_existing_packs(&existing);
1676+
existing_packs_remove_redundant(&existing);
16751677

16761678
if (geometry.split_factor)
16771679
geometry_remove_redundant_packs(&geometry, &names,

0 commit comments

Comments
 (0)