]> git.ipfire.org Git - thirdparty/git.git/commitdiff
refs: rename 'pack_refs_opts' to 'refs_optimize_opts'
authorKarthik Nayak <karthik.188@gmail.com>
Mon, 20 Oct 2025 08:18:30 +0000 (10:18 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 4 Nov 2025 15:35:12 +0000 (07:35 -0800)
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>
pack-refs.c
refs.c
refs.h
refs/debug.c
refs/files-backend.c
refs/packed-backend.c
refs/refs-internal.h
refs/reftable-backend.c

index 1a5e07d8b888abd9cf128c8058d2ca4cbffd5371..eb6b2ba2c2c2b50922bdae4104b768a3fb50b2d3 100644 (file)
@@ -14,10 +14,10 @@ int pack_refs_core(int argc,
 {
        struct ref_exclusions excludes = REF_EXCLUSIONS_INIT;
        struct string_list included_refs = STRING_LIST_INIT_NODUP;
-       struct pack_refs_opts pack_refs_opts = {
+       struct refs_optimize_opts optimize_opts = {
                .exclusions = &excludes,
                .includes = &included_refs,
-               .flags = PACK_REFS_PRUNE,
+               .flags = REFS_OPTIMIZE_PRUNE,
        };
        struct string_list option_excluded_refs = STRING_LIST_INIT_NODUP;
        struct string_list_item *item;
@@ -26,9 +26,9 @@ int pack_refs_core(int argc,
 
        struct option opts[] = {
                OPT_BOOL(0, "all",   &pack_all, N_("pack everything")),
-               OPT_BIT(0, "prune", &pack_refs_opts.flags, N_("prune loose refs (default)"), PACK_REFS_PRUNE),
-               OPT_BIT(0, "auto", &pack_refs_opts.flags, N_("auto-pack refs as needed"), PACK_REFS_AUTO),
-               OPT_STRING_LIST(0, "include", pack_refs_opts.includes, N_("pattern"),
+               OPT_BIT(0, "prune", &optimize_opts.flags, N_("prune loose refs (default)"), REFS_OPTIMIZE_PRUNE),
+               OPT_BIT(0, "auto", &optimize_opts.flags, N_("auto-pack refs as needed"), REFS_OPTIMIZE_AUTO),
+               OPT_STRING_LIST(0, "include", optimize_opts.includes, N_("pattern"),
                        N_("references to include")),
                OPT_STRING_LIST(0, "exclude", &option_excluded_refs, N_("pattern"),
                        N_("references to exclude")),
@@ -39,15 +39,15 @@ int pack_refs_core(int argc,
                usage_with_options(usage_opts, opts);
 
        for_each_string_list_item(item, &option_excluded_refs)
-               add_ref_exclusion(pack_refs_opts.exclusions, item->string);
+               add_ref_exclusion(optimize_opts.exclusions, item->string);
 
        if (pack_all)
-               string_list_append(pack_refs_opts.includes, "*");
+               string_list_append(optimize_opts.includes, "*");
 
-       if (!pack_refs_opts.includes->nr)
-               string_list_append(pack_refs_opts.includes, "refs/tags/*");
+       if (!optimize_opts.includes->nr)
+               string_list_append(optimize_opts.includes, "refs/tags/*");
 
-       ret = refs_optimize(get_main_ref_store(repo), &pack_refs_opts);
+       ret = refs_optimize(get_main_ref_store(repo), &optimize_opts);
 
        clear_ref_exclusions(&excludes);
        string_list_clear(&included_refs, 0);
diff --git a/refs.c b/refs.c
index b9a4a606462d71c21396aa3377d57001dc9407d5..0d0831f29ba25bccae36170e9dcfef27f623904e 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -2313,7 +2313,7 @@ void base_ref_store_init(struct ref_store *refs, struct repository *repo,
        refs->gitdir = xstrdup(path);
 }
 
-int refs_optimize(struct ref_store *refs, struct pack_refs_opts *opts)
+int refs_optimize(struct ref_store *refs, struct refs_optimize_opts *opts)
 {
        return refs->be->optimize(refs, opts);
 }
diff --git a/refs.h b/refs.h
index 8ff591ea95c7d9f775769103acc57e6f4a52b4f6..6b05bba527ffca938a75b1e1d98ee0f608d54234 100644 (file)
--- a/refs.h
+++ b/refs.h
@@ -499,16 +499,16 @@ void refs_warn_dangling_symrefs(struct ref_store *refs, FILE *fp,
                                const struct string_list *refnames);
 
 /*
- * Flags for controlling behaviour of pack_refs()
- * PACK_REFS_PRUNE: Prune loose refs after packing
- * PACK_REFS_AUTO: Pack refs on a best effort basis. The heuristics and end
- *                 result are decided by the ref backend. Backends may ignore
- *                 this flag and fall back to a normal repack.
+ * Flags for controlling behaviour of refs_optimize()
+ * REFS_OPTIMIZE_PRUNE: Prune loose refs after packing
+ * REFS_OPTIMIZE_AUTO: Pack refs on a best effort basis. The heuristics and end
+ *                     result are decided by the ref backend. Backends may ignore
+ *                     this flag and fall back to a normal repack.
  */
-#define PACK_REFS_PRUNE (1 << 0)
-#define PACK_REFS_AUTO  (1 << 1)
+#define REFS_OPTIMIZE_PRUNE (1 << 0)
+#define REFS_OPTIMIZE_AUTO  (1 << 1)
 
-struct pack_refs_opts {
+struct refs_optimize_opts {
        unsigned int flags;
        struct ref_exclusions *exclusions;
        struct string_list *includes;
@@ -518,7 +518,7 @@ struct pack_refs_opts {
  * Optimize the ref store. The exact behavior is up to the backend.
  * For the files backend, this is equivalent to packing refs.
  */
-int refs_optimize(struct ref_store *refs, struct pack_refs_opts *opts);
+int refs_optimize(struct ref_store *refs, struct refs_optimize_opts *opts);
 
 /*
  * Setup reflog before using. Fill in err and return -1 on failure.
index 40cd1d9c1540c6d0e6d8172e3459a386a70176fb..2defd2d465712ef3d8a0721c2b837084a9c029d2 100644 (file)
@@ -116,7 +116,7 @@ static int debug_transaction_abort(struct ref_store *refs,
        return res;
 }
 
-static int debug_optimize(struct ref_store *ref_store, struct pack_refs_opts *opts)
+static int debug_optimize(struct ref_store *ref_store, struct refs_optimize_opts *opts)
 {
        struct debug_ref_store *drefs = (struct debug_ref_store *)ref_store;
        int res = drefs->refs->be->optimize(drefs->refs, opts);
index d13b87e056cf5e8c8ff06272fb1f2828d27167a5..23bb641f2c84eebbb1b35445565368dfae45b126 100644 (file)
@@ -1355,7 +1355,7 @@ static void prune_refs(struct files_ref_store *refs, struct ref_to_prune **refs_
  */
 static int should_pack_ref(struct files_ref_store *refs,
                           const struct reference *ref,
-                          struct pack_refs_opts *opts)
+                          struct refs_optimize_opts *opts)
 {
        struct string_list_item *item;
 
@@ -1383,7 +1383,7 @@ static int should_pack_ref(struct files_ref_store *refs,
 }
 
 static int should_pack_refs(struct files_ref_store *refs,
-                           struct pack_refs_opts *opts)
+                           struct refs_optimize_opts *opts)
 {
        struct ref_iterator *iter;
        size_t packed_size;
@@ -1391,7 +1391,7 @@ static int should_pack_refs(struct files_ref_store *refs,
        size_t limit;
        int ret;
 
-       if (!(opts->flags & PACK_REFS_AUTO))
+       if (!(opts->flags & REFS_OPTIMIZE_AUTO))
                return 1;
 
        ret = packed_refs_size(refs->packed_ref_store, &packed_size);
@@ -1445,7 +1445,7 @@ static int should_pack_refs(struct files_ref_store *refs,
 }
 
 static int files_optimize(struct ref_store *ref_store,
-                         struct pack_refs_opts *opts)
+                         struct refs_optimize_opts *opts)
 {
        struct files_ref_store *refs =
                files_downcast(ref_store, REF_STORE_WRITE | REF_STORE_ODB,
@@ -1488,7 +1488,7 @@ static int files_optimize(struct ref_store *ref_store,
                            iter->ref.name, err.buf);
 
                /* Schedule the loose reference for pruning if requested. */
-               if ((opts->flags & PACK_REFS_PRUNE)) {
+               if ((opts->flags & REFS_OPTIMIZE_PRUNE)) {
                        struct ref_to_prune *n;
                        FLEX_ALLOC_STR(n, name, iter->ref.name);
                        oidcpy(&n->oid, iter->ref.oid);
index 20cf9fab18e2e9cd042244eb500318b555024cf2..10062fd8b63063795266fb7dc0805ecdf43ac6a4 100644 (file)
@@ -1774,7 +1774,7 @@ cleanup:
 }
 
 static int packed_optimize(struct ref_store *ref_store UNUSED,
-                          struct pack_refs_opts *pack_opts UNUSED)
+                          struct refs_optimize_opts *opts UNUSED)
 {
        /*
         * Packed refs are already packed. It might be that loose refs
index fc5149df5b3c5c0f135ef6a7b1cf337e81c59a7f..dee42f231dbd0a0a445bf9b31fc61a5c3d95cc7e 100644 (file)
@@ -423,7 +423,7 @@ typedef int ref_transaction_commit_fn(struct ref_store *refs,
                                      struct strbuf *err);
 
 typedef int optimize_fn(struct ref_store *ref_store,
-                       struct pack_refs_opts *opts);
+                       struct refs_optimize_opts *opts);
 typedef int rename_ref_fn(struct ref_store *ref_store,
                          const char *oldref, const char *newref,
                          const char *logmsg);
index 43cc66a48e91431e675cce60b4c0bb0c75a5b045..c23c45f3bf46399b4eb432f2a8c1262bb8e37cbc 100644 (file)
@@ -1701,7 +1701,7 @@ done:
 }
 
 static int reftable_be_optimize(struct ref_store *ref_store,
-                               struct pack_refs_opts *opts)
+                               struct refs_optimize_opts *opts)
 {
        struct reftable_ref_store *refs =
                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,
        if (!stack)
                stack = refs->main_backend.stack;
 
-       if (opts->flags & PACK_REFS_AUTO)
+       if (opts->flags & REFS_OPTIMIZE_AUTO)
                ret = reftable_stack_auto_compact(stack);
        else
                ret = reftable_stack_compact_all(stack, NULL);