Skip to content

Commit 2cd99d9

Browse files
KarthikNayakgitster
authored andcommitted
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>
1 parent 9b93ab8 commit 2cd99d9

File tree

8 files changed

+30
-30
lines changed

8 files changed

+30
-30
lines changed

pack-refs.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ int pack_refs_core(int argc,
1414
{
1515
struct ref_exclusions excludes = REF_EXCLUSIONS_INIT;
1616
struct string_list included_refs = STRING_LIST_INIT_NODUP;
17-
struct pack_refs_opts pack_refs_opts = {
17+
struct refs_optimize_opts optimize_opts = {
1818
.exclusions = &excludes,
1919
.includes = &included_refs,
20-
.flags = PACK_REFS_PRUNE,
20+
.flags = REFS_OPTIMIZE_PRUNE,
2121
};
2222
struct string_list option_excluded_refs = STRING_LIST_INIT_NODUP;
2323
struct string_list_item *item;
@@ -26,9 +26,9 @@ int pack_refs_core(int argc,
2626

2727
struct option opts[] = {
2828
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"),
3232
N_("references to include")),
3333
OPT_STRING_LIST(0, "exclude", &option_excluded_refs, N_("pattern"),
3434
N_("references to exclude")),
@@ -39,15 +39,15 @@ int pack_refs_core(int argc,
3939
usage_with_options(usage_opts, opts);
4040

4141
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);
4343

4444
if (pack_all)
45-
string_list_append(pack_refs_opts.includes, "*");
45+
string_list_append(optimize_opts.includes, "*");
4646

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/*");
4949

50-
ret = refs_optimize(get_main_ref_store(repo), &pack_refs_opts);
50+
ret = refs_optimize(get_main_ref_store(repo), &optimize_opts);
5151

5252
clear_ref_exclusions(&excludes);
5353
string_list_clear(&included_refs, 0);

refs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2313,7 +2313,7 @@ void base_ref_store_init(struct ref_store *refs, struct repository *repo,
23132313
refs->gitdir = xstrdup(path);
23142314
}
23152315

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)
23172317
{
23182318
return refs->be->optimize(refs, opts);
23192319
}

refs.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -499,16 +499,16 @@ void refs_warn_dangling_symrefs(struct ref_store *refs, FILE *fp,
499499
const struct string_list *refnames);
500500

501501
/*
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.
507507
*/
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)
510510

511-
struct pack_refs_opts {
511+
struct refs_optimize_opts {
512512
unsigned int flags;
513513
struct ref_exclusions *exclusions;
514514
struct string_list *includes;
@@ -518,7 +518,7 @@ struct pack_refs_opts {
518518
* Optimize the ref store. The exact behavior is up to the backend.
519519
* For the files backend, this is equivalent to packing refs.
520520
*/
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);
522522

523523
/*
524524
* Setup reflog before using. Fill in err and return -1 on failure.

refs/debug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ static int debug_transaction_abort(struct ref_store *refs,
116116
return res;
117117
}
118118

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)
120120
{
121121
struct debug_ref_store *drefs = (struct debug_ref_store *)ref_store;
122122
int res = drefs->refs->be->optimize(drefs->refs, opts);

refs/files-backend.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,7 +1355,7 @@ static void prune_refs(struct files_ref_store *refs, struct ref_to_prune **refs_
13551355
*/
13561356
static int should_pack_ref(struct files_ref_store *refs,
13571357
const struct reference *ref,
1358-
struct pack_refs_opts *opts)
1358+
struct refs_optimize_opts *opts)
13591359
{
13601360
struct string_list_item *item;
13611361

@@ -1383,15 +1383,15 @@ static int should_pack_ref(struct files_ref_store *refs,
13831383
}
13841384

13851385
static int should_pack_refs(struct files_ref_store *refs,
1386-
struct pack_refs_opts *opts)
1386+
struct refs_optimize_opts *opts)
13871387
{
13881388
struct ref_iterator *iter;
13891389
size_t packed_size;
13901390
size_t refcount = 0;
13911391
size_t limit;
13921392
int ret;
13931393

1394-
if (!(opts->flags & PACK_REFS_AUTO))
1394+
if (!(opts->flags & REFS_OPTIMIZE_AUTO))
13951395
return 1;
13961396

13971397
ret = packed_refs_size(refs->packed_ref_store, &packed_size);
@@ -1445,7 +1445,7 @@ static int should_pack_refs(struct files_ref_store *refs,
14451445
}
14461446

14471447
static int files_optimize(struct ref_store *ref_store,
1448-
struct pack_refs_opts *opts)
1448+
struct refs_optimize_opts *opts)
14491449
{
14501450
struct files_ref_store *refs =
14511451
files_downcast(ref_store, REF_STORE_WRITE | REF_STORE_ODB,
@@ -1488,7 +1488,7 @@ static int files_optimize(struct ref_store *ref_store,
14881488
iter->ref.name, err.buf);
14891489

14901490
/* Schedule the loose reference for pruning if requested. */
1491-
if ((opts->flags & PACK_REFS_PRUNE)) {
1491+
if ((opts->flags & REFS_OPTIMIZE_PRUNE)) {
14921492
struct ref_to_prune *n;
14931493
FLEX_ALLOC_STR(n, name, iter->ref.name);
14941494
oidcpy(&n->oid, iter->ref.oid);

refs/packed-backend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1774,7 +1774,7 @@ static int packed_transaction_finish(struct ref_store *ref_store,
17741774
}
17751775

17761776
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)
17781778
{
17791779
/*
17801780
* Packed refs are already packed. It might be that loose refs

refs/refs-internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ typedef int ref_transaction_commit_fn(struct ref_store *refs,
423423
struct strbuf *err);
424424

425425
typedef int optimize_fn(struct ref_store *ref_store,
426-
struct pack_refs_opts *opts);
426+
struct refs_optimize_opts *opts);
427427
typedef int rename_ref_fn(struct ref_store *ref_store,
428428
const char *oldref, const char *newref,
429429
const char *logmsg);

refs/reftable-backend.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,7 +1701,7 @@ static int reftable_be_transaction_finish(struct ref_store *ref_store UNUSED,
17011701
}
17021702

17031703
static int reftable_be_optimize(struct ref_store *ref_store,
1704-
struct pack_refs_opts *opts)
1704+
struct refs_optimize_opts *opts)
17051705
{
17061706
struct reftable_ref_store *refs =
17071707
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,
17151715
if (!stack)
17161716
stack = refs->main_backend.stack;
17171717

1718-
if (opts->flags & PACK_REFS_AUTO)
1718+
if (opts->flags & REFS_OPTIMIZE_AUTO)
17191719
ret = reftable_stack_auto_compact(stack);
17201720
else
17211721
ret = reftable_stack_compact_all(stack, NULL);

0 commit comments

Comments
 (0)