Skip to content

Commit 2b72c12

Browse files
ttaylorrgitster
authored andcommitted
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>
1 parent 7d1f442 commit 2b72c12

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

builtin/repack.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,15 @@ static struct {
146146
{".idx"},
147147
};
148148

149-
struct generated_pack_data {
149+
struct generated_pack {
150150
struct tempfile *tempfiles[ARRAY_SIZE(exts)];
151151
};
152152

153-
static struct generated_pack_data *populate_pack_exts(const char *name)
153+
static struct generated_pack *generated_pack_populate(const char *name)
154154
{
155155
struct stat statbuf;
156156
struct strbuf path = STRBUF_INIT;
157-
struct generated_pack_data *data = xcalloc(1, sizeof(*data));
157+
struct generated_pack *pack = xcalloc(1, sizeof(*pack));
158158
int i;
159159

160160
for (i = 0; i < ARRAY_SIZE(exts); i++) {
@@ -164,21 +164,21 @@ static struct generated_pack_data *populate_pack_exts(const char *name)
164164
if (stat(path.buf, &statbuf))
165165
continue;
166166

167-
data->tempfiles[i] = register_tempfile(path.buf);
167+
pack->tempfiles[i] = register_tempfile(path.buf);
168168
}
169169

170170
strbuf_release(&path);
171-
return data;
171+
return pack;
172172
}
173173

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)
176176
{
177177
int i;
178178
for (i = 0; i < ARRAY_SIZE(exts); i++) {
179179
if (strcmp(exts[i].name, ext))
180180
continue;
181-
return !!data->tempfiles[i];
181+
return !!pack->tempfiles[i];
182182
}
183183
BUG("unknown pack extension: '%s'", ext);
184184
}
@@ -239,7 +239,7 @@ static void repack_promisor_objects(struct repository *repo,
239239
line.buf);
240240
write_promisor_file(promisor_name, NULL, 0);
241241

242-
item->util = populate_pack_exts(item->string);
242+
item->util = generated_pack_populate(item->string);
243243

244244
free(promisor_name);
245245
}
@@ -780,8 +780,8 @@ static int write_midx_included_packs(struct string_list *include,
780780
* will suffice, so pick the first one.)
781781
*/
782782
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"))
785785
continue;
786786

787787
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,
864864
*/
865865
if (local) {
866866
item = string_list_append(names, line.buf);
867-
item->util = populate_pack_exts(line.buf);
867+
item->util = generated_pack_populate(line.buf);
868868
}
869869
}
870870
fclose(out);
@@ -1435,24 +1435,24 @@ int cmd_repack(int argc,
14351435
* Ok we have prepared all new packfiles.
14361436
*/
14371437
for_each_string_list_item(item, &names) {
1438-
struct generated_pack_data *data = item->util;
1438+
struct generated_pack *pack = item->util;
14391439

14401440
for (ext = 0; ext < ARRAY_SIZE(exts); ext++) {
14411441
char *fname;
14421442

14431443
fname = mkpathdup("%s/pack-%s%s",
14441444
packdir, item->string, exts[ext].name);
14451445

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]);
14481448
struct stat statbuffer;
14491449

14501450
if (!stat(fname_old, &statbuffer)) {
14511451
statbuffer.st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
14521452
chmod(fname_old, statbuffer.st_mode);
14531453
}
14541454

1455-
if (rename_tempfile(&data->tempfiles[ext], fname))
1455+
if (rename_tempfile(&pack->tempfiles[ext], fname))
14561456
die_errno(_("renaming pack to '%s' failed"), fname);
14571457
} else if (!exts[ext].optional)
14581458
die(_("pack-objects did not write a '%s' file for pack %s-%s"),

0 commit comments

Comments
 (0)