refs: rename 'pack_refs_opts' to 'refs_optimize_opts'

The previous commit removed all references to 'pack_refs()' within the refs subsystem. Continue this cleanup by also renaming 'pack_refs_opts' to 'refs_optimize_opts' and the respective flags accordingly. Keeping the naming consistent will make the code easier to maintain. Signed-off-by: Karthik Nayak <karthik.188@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Karthik Nayak committed Oct 20, 2025 at 10:18 UTC 2cd99d984122f7f1cd7c3b153ee0a0d566831b30
8 files changed +30 -30
pack-refs.c
+10 -10
@@ -14,10 +14,10 @@ int pack_refs_core(int argc,
14 {
15 struct ref_exclusions excludes = REF_EXCLUSIONS_INIT;
16 struct string_list included_refs = STRING_LIST_INIT_NODUP;
17 - struct pack_refs_opts pack_refs_opts = {
17 + struct refs_optimize_opts optimize_opts = {
18 .exclusions = &excludes,
19 .includes = &included_refs,
20 - .flags = PACK_REFS_PRUNE,
20 + .flags = REFS_OPTIMIZE_PRUNE,
21 };
22 struct string_list option_excluded_refs = STRING_LIST_INIT_NODUP;
23 struct string_list_item *item;
@@ -26,9 +26,9 @@ int pack_refs_core(int argc,
26
27 struct option opts[] = {
28 OPT_BOOL(0, "all", &pack_all, N_("pack everything")),
29 - OPT_BIT(0, "prune", &pack_refs_opts.flags, N_("prune loose refs (default)"), PACK_REFS_PRUNE),
30 - OPT_BIT(0, "auto", &pack_refs_opts.flags, N_("auto-pack refs as needed"), PACK_REFS_AUTO),
31 - OPT_STRING_LIST(0, "include", pack_refs_opts.includes, N_("pattern"),
29 + OPT_BIT(0, "prune", &optimize_opts.flags, N_("prune loose refs (default)"), REFS_OPTIMIZE_PRUNE),
30 + OPT_BIT(0, "auto", &optimize_opts.flags, N_("auto-pack refs as needed"), REFS_OPTIMIZE_AUTO),
31 + OPT_STRING_LIST(0, "include", optimize_opts.includes, N_("pattern"),
32 N_("references to include")),
33 OPT_STRING_LIST(0, "exclude", &option_excluded_refs, N_("pattern"),
34 N_("references to exclude")),
@@ -39,15 +39,15 @@ int pack_refs_core(int argc,
39 usage_with_options(usage_opts, opts);
40
41 for_each_string_list_item(item, &option_excluded_refs)
42 - add_ref_exclusion(pack_refs_opts.exclusions, item->string);
42 + add_ref_exclusion(optimize_opts.exclusions, item->string);
43
44 if (pack_all)
45 - string_list_append(pack_refs_opts.includes, "*");
45 + string_list_append(optimize_opts.includes, "*");
46
47 - if (!pack_refs_opts.includes->nr)
48 - string_list_append(pack_refs_opts.includes, "refs/tags/*");
47 + if (!optimize_opts.includes->nr)
48 + string_list_append(optimize_opts.includes, "refs/tags/*");
49
50 - ret = refs_optimize(get_main_ref_store(repo), &pack_refs_opts);
50 + ret = refs_optimize(get_main_ref_store(repo), &optimize_opts);
51
52 clear_ref_exclusions(&excludes);
53 string_list_clear(&included_refs, 0);
refs.c
+1 -1
@@ -2313,7 +2313,7 @@ void base_ref_store_init(struct ref_store *refs, struct repository *repo,
2313 refs->gitdir = xstrdup(path);
2314 }
2315
2316 -int refs_optimize(struct ref_store *refs, struct pack_refs_opts *opts)
2316 +int refs_optimize(struct ref_store *refs, struct refs_optimize_opts *opts)
2317 {
2318 return refs->be->optimize(refs, opts);
2319 }
refs.h
+9 -9
@@ -499,16 +499,16 @@ void refs_warn_dangling_symrefs(struct ref_store *refs, FILE *fp,
499 const struct string_list *refnames);
500
501 /*
502 - * Flags for controlling behaviour of pack_refs()
503 - * PACK_REFS_PRUNE: Prune loose refs after packing
504 - * PACK_REFS_AUTO: Pack refs on a best effort basis. The heuristics and end
505 - * result are decided by the ref backend. Backends may ignore
506 - * this flag and fall back to a normal repack.
502 + * Flags for controlling behaviour of refs_optimize()
503 + * REFS_OPTIMIZE_PRUNE: Prune loose refs after packing
504 + * REFS_OPTIMIZE_AUTO: Pack refs on a best effort basis. The heuristics and end
505 + * result are decided by the ref backend. Backends may ignore
506 + * this flag and fall back to a normal repack.
507 */
508 -#define PACK_REFS_PRUNE (1 << 0)
509 -#define PACK_REFS_AUTO (1 << 1)
508 +#define REFS_OPTIMIZE_PRUNE (1 << 0)
509 +#define REFS_OPTIMIZE_AUTO (1 << 1)
510
511 -struct pack_refs_opts {
511 +struct refs_optimize_opts {
512 unsigned int flags;
513 struct ref_exclusions *exclusions;
514 struct string_list *includes;
@@ -518,7 +518,7 @@ struct pack_refs_opts {
518 * Optimize the ref store. The exact behavior is up to the backend.
519 * For the files backend, this is equivalent to packing refs.
520 */
521 -int refs_optimize(struct ref_store *refs, struct pack_refs_opts *opts);
521 +int refs_optimize(struct ref_store *refs, struct refs_optimize_opts *opts);
522
523 /*
524 * Setup reflog before using. Fill in err and return -1 on failure.
refs/debug.c
+1 -1
@@ -116,7 +116,7 @@ static int debug_transaction_abort(struct ref_store *refs,
116 return res;
117 }
118
119 -static int debug_optimize(struct ref_store *ref_store, struct pack_refs_opts *opts)
119 +static int debug_optimize(struct ref_store *ref_store, struct refs_optimize_opts *opts)
120 {
121 struct debug_ref_store *drefs = (struct debug_ref_store *)ref_store;
122 int res = drefs->refs->be->optimize(drefs->refs, opts);
refs/files-backend.c
+5 -5
@@ -1355,7 +1355,7 @@ static void prune_refs(struct files_ref_store *refs, struct ref_to_prune **refs_
1355 */
1356 static int should_pack_ref(struct files_ref_store *refs,
1357 const struct reference *ref,
1358 - struct pack_refs_opts *opts)
1358 + struct refs_optimize_opts *opts)
1359 {
1360 struct string_list_item *item;
1361
@@ -1383,7 +1383,7 @@ static int should_pack_ref(struct files_ref_store *refs,
1383 }
1384
1385 static int should_pack_refs(struct files_ref_store *refs,
1386 - struct pack_refs_opts *opts)
1386 + struct refs_optimize_opts *opts)
1387 {
1388 struct ref_iterator *iter;
1389 size_t packed_size;
@@ -1391,7 +1391,7 @@ static int should_pack_refs(struct files_ref_store *refs,
1391 size_t limit;
1392 int ret;
1393
1394 - if (!(opts->flags & PACK_REFS_AUTO))
1394 + if (!(opts->flags & REFS_OPTIMIZE_AUTO))
1395 return 1;
1396
1397 ret = packed_refs_size(refs->packed_ref_store, &packed_size);
@@ -1445,7 +1445,7 @@ static int should_pack_refs(struct files_ref_store *refs,
1445 }
1446
1447 static int files_optimize(struct ref_store *ref_store,
1448 - struct pack_refs_opts *opts)
1448 + struct refs_optimize_opts *opts)
1449 {
1450 struct files_ref_store *refs =
1451 files_downcast(ref_store, REF_STORE_WRITE | REF_STORE_ODB,
@@ -1488,7 +1488,7 @@ static int files_optimize(struct ref_store *ref_store,
1488 iter->ref.name, err.buf);
1489
1490 /* Schedule the loose reference for pruning if requested. */
1491 - if ((opts->flags & PACK_REFS_PRUNE)) {
1491 + if ((opts->flags & REFS_OPTIMIZE_PRUNE)) {
1492 struct ref_to_prune *n;
1493 FLEX_ALLOC_STR(n, name, iter->ref.name);
1494 oidcpy(&n->oid, iter->ref.oid);
refs/packed-backend.c
+1 -1
@@ -1774,7 +1774,7 @@ cleanup:
1774 }
1775
1776 static int packed_optimize(struct ref_store *ref_store UNUSED,
1777 - struct pack_refs_opts *pack_opts UNUSED)
1777 + struct refs_optimize_opts *opts UNUSED)
1778 {
1779 /*
1780 * Packed refs are already packed. It might be that loose refs
refs/refs-internal.h
+1 -1
@@ -423,7 +423,7 @@ typedef int ref_transaction_commit_fn(struct ref_store *refs,
423 struct strbuf *err);
424
425 typedef int optimize_fn(struct ref_store *ref_store,
426 - struct pack_refs_opts *opts);
426 + struct refs_optimize_opts *opts);
427 typedef int rename_ref_fn(struct ref_store *ref_store,
428 const char *oldref, const char *newref,
429 const char *logmsg);
refs/reftable-backend.c
+2 -2
@@ -1701,7 +1701,7 @@ done:
1701 }
1702
1703 static int reftable_be_optimize(struct ref_store *ref_store,
1704 - struct pack_refs_opts *opts)
1704 + struct refs_optimize_opts *opts)
1705 {
1706 struct reftable_ref_store *refs =
1707 reftable_be_downcast(ref_store, REF_STORE_WRITE | REF_STORE_ODB, "optimize_refs");
@@ -1715,7 +1715,7 @@ static int reftable_be_optimize(struct ref_store *ref_store,
1715 if (!stack)
1716 stack = refs->main_backend.stack;
1717
1718 - if (opts->flags & PACK_REFS_AUTO)
1718 + if (opts->flags & REFS_OPTIMIZE_AUTO)
1719 ret = reftable_stack_auto_compact(stack);
1720 else
1721 ret = reftable_stack_compact_all(stack, NULL);