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 541204aabe (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>

Taylor Blau committed Oct 15, 2025 at 18:28 UTC a0dcecb14613e5bdfdc06616271bffac9e1366e8
1 file changed +34 -32
builtin/repack.c
+34 -32
@@ -121,39 +121,39 @@ struct existing_packs {
121 .cruft_packs = STRING_LIST_INIT_DUP, \
122 }
123
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)
125 {
126 return existing->non_kept_packs.nr || existing->cruft_packs.nr;
127 }
128
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)
130 {
131 item->util = (void*)((uintptr_t)item->util | DELETE_PACK);
132 }
133
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)
135 {
136 item->util = (void*)((uintptr_t)item->util & ~DELETE_PACK);
137 }
138
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)
140 {
141 return (uintptr_t)item->util & DELETE_PACK;
142 }
143
144 -static void pack_mark_retained(struct string_list_item *item)
144 +static void existing_packs_mark_retained(struct string_list_item *item)
145 {
146 item->util = (void*)((uintptr_t)item->util | RETAIN_PACK);
147 }
148
149 -static int pack_is_retained(struct string_list_item *item)
149 +static int existing_pack_is_retained(struct string_list_item *item)
150 {
151 return (uintptr_t)item->util & RETAIN_PACK;
152 }
153
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)
157 {
158 struct string_list_item *item;
159 const int hexsz = algop->hexsz;
@@ -165,8 +165,8 @@ static void mark_packs_for_deletion_1(const struct git_hash_algo *algop,
165 continue;
166 sha1 = item->string + len - hexsz;
167
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);
170 } else if (!string_list_has_string(names, sha1)) {
171 /*
172 * Mark this pack for deletion, which ensures
@@ -175,13 +175,13 @@ static void mark_packs_for_deletion_1(const struct git_hash_algo *algop,
175 * will actually delete this pack (if `-d` was
176 * given).
177 */
178 - pack_mark_for_deletion(item);
178 + existing_pack_mark_for_deletion(item);
179 }
180 }
181 }
182
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)
185 {
186 struct strbuf buf = STRBUF_INIT;
187 struct string_list_item *item;
@@ -193,17 +193,19 @@ static void retain_cruft_pack(struct existing_packs *existing,
193 if (!item)
194 BUG("could not find cruft pack '%s'", pack_basename(cruft));
195
196 - pack_mark_retained(item);
196 + existing_packs_mark_retained(item);
197 strbuf_release(&buf);
198 }
199
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)
202
203 {
204 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);
209 }
210
211 static void remove_redundant_pack(struct repository *repo,
@@ -225,13 +227,13 @@ static void remove_redundant_packs_1(struct repository *repo,
227 {
228 struct string_list_item *item;
229 for_each_string_list_item(item, packs) {
228 - if (!pack_is_marked_for_deletion(item))
230 + if (!existing_pack_is_marked_for_deletion(item))
231 continue;
232 remove_redundant_pack(repo, packdir, item->string);
233 }
234 }
235
234 -static void remove_redundant_existing_packs(struct existing_packs *existing)
236 +static void existing_packs_remove_redundant(struct existing_packs *existing)
237 {
238 remove_redundant_packs_1(existing->repo, &existing->non_kept_packs);
239 remove_redundant_packs_1(existing->repo, &existing->cruft_packs);
@@ -250,7 +252,7 @@ static void existing_packs_release(struct existing_packs *existing)
252 * .keep file or not. Packs without a .keep file are not to be kept
253 * if we are going to pack everything into one file.
254 */
253 -static void collect_pack_filenames(struct existing_packs *existing,
255 +static void existing_packs_collect(struct existing_packs *existing,
256 const struct string_list *extra_keep)
257 {
258 struct packfile_store *packs = existing->repo->objects->packfiles;
@@ -721,7 +723,7 @@ static int midx_has_unknown_packs(char **midx_pack_names,
723
724 item = string_list_lookup(&existing->non_kept_packs,
725 pack_name);
724 - if (item && !pack_is_marked_for_deletion(item))
726 + if (item && !existing_pack_is_marked_for_deletion(item))
727 continue;
728 }
729
@@ -851,7 +853,7 @@ static void midx_included_packs(struct string_list *include,
853 }
854 } else {
855 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))
857 continue;
858
859 strbuf_reset(&buf);
@@ -888,10 +890,10 @@ static void midx_included_packs(struct string_list *include,
890 * --geometric case, but doing so is unnecessary
891 * since no packs are marked as pending
892 * 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).
895 */
894 - if (pack_is_marked_for_deletion(item))
896 + if (existing_pack_is_marked_for_deletion(item))
897 continue;
898
899 strbuf_reset(&buf);
@@ -1128,7 +1130,7 @@ static void combine_small_cruft_packs(FILE *in, size_t combine_cruft_below_size,
1130 if (p->pack_size < combine_cruft_below_size) {
1131 fprintf(in, "-%s\n", pack_basename(p));
1132 } else {
1131 - retain_cruft_pack(existing, p);
1133 + existing_packs_retain_cruft(existing, p);
1134 fprintf(in, "%s\n", pack_basename(p));
1135 }
1136 }
@@ -1382,7 +1384,7 @@ int cmd_repack(int argc,
1384 packtmp = mkpathdup("%s/%s", packdir, packtmp_name);
1385
1386 existing.repo = repo;
1385 - collect_pack_filenames(&existing, &keep_pack_list);
1387 + existing_packs_collect(&existing, &keep_pack_list);
1388
1389 if (geometry.split_factor) {
1390 if (pack_everything)
@@ -1431,7 +1433,7 @@ int cmd_repack(int argc,
1433 if (pack_everything & ALL_INTO_ONE) {
1434 repack_promisor_objects(repo, &po_args, &names);
1435
1434 - if (has_existing_non_kept_packs(&existing) &&
1436 + if (existing_packs_has_non_kept(&existing) &&
1437 delete_redundant &&
1438 !(pack_everything & PACK_CRUFT)) {
1439 for_each_string_list_item(item, &names) {
@@ -1647,7 +1649,7 @@ int cmd_repack(int argc,
1649 /* End of pack replacement. */
1650
1651 if (delete_redundant && pack_everything & ALL_INTO_ONE)
1650 - mark_packs_for_deletion(&existing, &names);
1652 + existing_packs_mark_for_deletion(&existing, &names);
1653
1654 if (write_midx) {
1655 struct string_list include = STRING_LIST_INIT_DUP;
@@ -1671,7 +1673,7 @@ int cmd_repack(int argc,
1673
1674 if (delete_redundant) {
1675 int opts = 0;
1674 - remove_redundant_existing_packs(&existing);
1676 + existing_packs_remove_redundant(&existing);
1677
1678 if (geometry.split_factor)
1679 geometry_remove_redundant_packs(&geometry, &names,