builtin/repack.c: rename "struct generated_pack_data"
The name "generated_pack_data" is somewhat redundant, since the contents of the struct *is* the data associated with the generated pack. Rename the structure to just "generated_pack", resulting in less awkward function names, like "generated_pack_has_ext()" which is preferable to "generated_pack_data_has_ext()". Rename a few related functions to align with the convention that functions to do with a struct "S" should be prefixed with "S_". 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
2b72c1236725915b353b9740a27a32c107dfe3b0
1 file changed
+16
-16
builtin/repack.c
+16
-16
@@ -146,15 +146,15 @@ static struct {
146
{".idx"},
147
};
148
149
-struct generated_pack_data {
149
+struct generated_pack {
150
struct tempfile *tempfiles[ARRAY_SIZE(exts)];
151
};
152
153
-static struct generated_pack_data *populate_pack_exts(const char *name)
153
+static struct generated_pack *generated_pack_populate(const char *name)
154
{
155
struct stat statbuf;
156
struct strbuf path = STRBUF_INIT;
157
- struct generated_pack_data *data = xcalloc(1, sizeof(*data));
157
+ struct generated_pack *pack = xcalloc(1, sizeof(*pack));
158
int i;
159
160
for (i = 0; i < ARRAY_SIZE(exts); i++) {
@@ -164,21 +164,21 @@ static struct generated_pack_data *populate_pack_exts(const char *name)
164
if (stat(path.buf, &statbuf))
165
continue;
166
167
- data->tempfiles[i] = register_tempfile(path.buf);
167
+ pack->tempfiles[i] = register_tempfile(path.buf);
168
}
169
170
strbuf_release(&path);
171
- return data;
171
+ return pack;
172
}
173
174
-static int has_pack_ext(const struct generated_pack_data *data,
175
- const char *ext)
174
+static int generated_pack_has_ext(const struct generated_pack *pack,
175
+ const char *ext)
176
{
177
int i;
178
for (i = 0; i < ARRAY_SIZE(exts); i++) {
179
if (strcmp(exts[i].name, ext))
180
continue;
181
- return !!data->tempfiles[i];
181
+ return !!pack->tempfiles[i];
182
}
183
BUG("unknown pack extension: '%s'", ext);
184
}
@@ -239,7 +239,7 @@ static void repack_promisor_objects(struct repository *repo,
239
line.buf);
240
write_promisor_file(promisor_name, NULL, 0);
241
242
- item->util = populate_pack_exts(item->string);
242
+ item->util = generated_pack_populate(item->string);
243
244
free(promisor_name);
245
}
@@ -780,8 +780,8 @@ static int write_midx_included_packs(struct string_list *include,
780
* will suffice, so pick the first one.)
781
*/
782
for_each_string_list_item(item, names) {
783
- struct generated_pack_data *data = item->util;
784
- if (has_pack_ext(data, ".mtimes"))
783
+ struct generated_pack *pack = item->util;
784
+ if (generated_pack_has_ext(pack, ".mtimes"))
785
continue;
786
787
strvec_pushf(&cmd.args, "--preferred-pack=pack-%s.pack",
@@ -864,7 +864,7 @@ static int finish_pack_objects_cmd(const struct git_hash_algo *algop,
864
*/
865
if (local) {
866
item = string_list_append(names, line.buf);
867
- item->util = populate_pack_exts(line.buf);
867
+ item->util = generated_pack_populate(line.buf);
868
}
869
}
870
fclose(out);
@@ -1435,7 +1435,7 @@ int cmd_repack(int argc,
1435
* Ok we have prepared all new packfiles.
1436
*/
1437
for_each_string_list_item(item, &names) {
1438
- struct generated_pack_data *data = item->util;
1438
+ struct generated_pack *pack = item->util;
1439
1440
for (ext = 0; ext < ARRAY_SIZE(exts); ext++) {
1441
char *fname;
@@ -1443,8 +1443,8 @@ int cmd_repack(int argc,
1443
fname = mkpathdup("%s/pack-%s%s",
1444
packdir, item->string, exts[ext].name);
1445
1446
- if (data->tempfiles[ext]) {
1447
- const char *fname_old = get_tempfile_path(data->tempfiles[ext]);
1446
+ if (pack->tempfiles[ext]) {
1447
+ const char *fname_old = get_tempfile_path(pack->tempfiles[ext]);
1448
struct stat statbuffer;
1449
1450
if (!stat(fname_old, &statbuffer)) {
@@ -1452,7 +1452,7 @@ int cmd_repack(int argc,
1452
chmod(fname_old, statbuffer.st_mode);
1453
}
1454
1455
- if (rename_tempfile(&data->tempfiles[ext], fname))
1455
+ if (rename_tempfile(&pack->tempfiles[ext], fname))
1456
die_errno(_("renaming pack to '%s' failed"), fname);
1457
} else if (!exts[ext].optional)
1458
die(_("pack-objects did not write a '%s' file for pack %s-%s"),