Skip to content

Commit ed93ea1

Browse files
pks-tgitster
authored andcommitted
refs: rename init_db callback to avoid confusion
Reference backends have two callbacks `init` and `init_db`. The similarity of these two callbacks has repeatedly confused me whenever I was looking at them, where I always had to look up which of them does what. Rename the `init_db` callback to `create_on_disk`, which should hopefully be clearer. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1febabf commit ed93ea1

File tree

9 files changed

+29
-29
lines changed

9 files changed

+29
-29
lines changed

builtin/worktree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ static int add_worktree(const char *path, const char *refname,
509509
}
510510
wt_refs = get_worktree_ref_store(wt);
511511

512-
ret = refs_init_db(wt_refs, REFS_INIT_DB_IS_WORKTREE, &sb);
512+
ret = ref_store_create_on_disk(wt_refs, REF_STORE_CREATE_ON_DISK_IS_WORKTREE, &sb);
513513
if (ret)
514514
goto done;
515515

refs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1938,9 +1938,9 @@ const char *refs_resolve_ref_unsafe(struct ref_store *refs,
19381938
}
19391939

19401940
/* backend functions */
1941-
int refs_init_db(struct ref_store *refs, int flags, struct strbuf *err)
1941+
int ref_store_create_on_disk(struct ref_store *refs, int flags, struct strbuf *err)
19421942
{
1943-
return refs->be->init_db(refs, flags, err);
1943+
return refs->be->create_on_disk(refs, flags, err);
19441944
}
19451945

19461946
int resolve_gitlink_ref(const char *submodule, const char *refname,

refs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ int should_autocreate_reflog(const char *refname);
114114

115115
int is_branch(const char *refname);
116116

117-
#define REFS_INIT_DB_IS_WORKTREE (1 << 0)
117+
#define REF_STORE_CREATE_ON_DISK_IS_WORKTREE (1 << 0)
118118

119-
int refs_init_db(struct ref_store *refs, int flags, struct strbuf *err);
119+
int ref_store_create_on_disk(struct ref_store *refs, int flags, struct strbuf *err);
120120

121121
/*
122122
* Return the peeled value of the oid currently being iterated via

refs/debug.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ struct ref_store *maybe_debug_wrap_ref_store(const char *gitdir, struct ref_stor
3333
return (struct ref_store *)res;
3434
}
3535

36-
static int debug_init_db(struct ref_store *refs, int flags, struct strbuf *err)
36+
static int debug_create_on_disk(struct ref_store *refs, int flags, struct strbuf *err)
3737
{
3838
struct debug_ref_store *drefs = (struct debug_ref_store *)refs;
39-
int res = drefs->refs->be->init_db(drefs->refs, flags, err);
40-
trace_printf_key(&trace_refs, "init_db: %d\n", res);
39+
int res = drefs->refs->be->create_on_disk(drefs->refs, flags, err);
40+
trace_printf_key(&trace_refs, "create_on_disk: %d\n", res);
4141
return res;
4242
}
4343

@@ -427,7 +427,7 @@ static int debug_reflog_expire(struct ref_store *ref_store, const char *refname,
427427
struct ref_storage_be refs_be_debug = {
428428
.name = "debug",
429429
.init = NULL,
430-
.init_db = debug_init_db,
430+
.create_on_disk = debug_create_on_disk,
431431

432432
/*
433433
* None of these should be NULL. If the "files" backend (in

refs/files-backend.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3236,12 +3236,12 @@ static int files_reflog_expire(struct ref_store *ref_store,
32363236
return -1;
32373237
}
32383238

3239-
static int files_init_db(struct ref_store *ref_store,
3240-
int flags,
3241-
struct strbuf *err UNUSED)
3239+
static int files_ref_store_create_on_disk(struct ref_store *ref_store,
3240+
int flags,
3241+
struct strbuf *err UNUSED)
32423242
{
32433243
struct files_ref_store *refs =
3244-
files_downcast(ref_store, REF_STORE_WRITE, "init_db");
3244+
files_downcast(ref_store, REF_STORE_WRITE, "create");
32453245
struct strbuf sb = STRBUF_INIT;
32463246

32473247
/*
@@ -3264,7 +3264,7 @@ static int files_init_db(struct ref_store *ref_store,
32643264
* There is no need to create directories for common refs when creating
32653265
* a worktree ref store.
32663266
*/
3267-
if (!(flags & REFS_INIT_DB_IS_WORKTREE)) {
3267+
if (!(flags & REF_STORE_CREATE_ON_DISK_IS_WORKTREE)) {
32683268
/*
32693269
* Create .git/refs/{heads,tags}
32703270
*/
@@ -3284,7 +3284,7 @@ static int files_init_db(struct ref_store *ref_store,
32843284
struct ref_storage_be refs_be_files = {
32853285
.name = "files",
32863286
.init = files_ref_store_init,
3287-
.init_db = files_init_db,
3287+
.create_on_disk = files_ref_store_create_on_disk,
32883288
.transaction_prepare = files_transaction_prepare,
32893289
.transaction_finish = files_transaction_finish,
32903290
.transaction_abort = files_transaction_abort,

refs/packed-backend.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,9 +1244,9 @@ int packed_refs_is_locked(struct ref_store *ref_store)
12441244
static const char PACKED_REFS_HEADER[] =
12451245
"# pack-refs with: peeled fully-peeled sorted \n";
12461246

1247-
static int packed_ref_store_init_db(struct ref_store *ref_store UNUSED,
1248-
int flags UNUSED,
1249-
struct strbuf *err UNUSED)
1247+
static int packed_ref_store_create_on_disk(struct ref_store *ref_store UNUSED,
1248+
int flags UNUSED,
1249+
struct strbuf *err UNUSED)
12501250
{
12511251
/* Nothing to do. */
12521252
return 0;
@@ -1707,7 +1707,7 @@ static struct ref_iterator *packed_reflog_iterator_begin(struct ref_store *ref_s
17071707
struct ref_storage_be refs_be_packed = {
17081708
.name = "packed",
17091709
.init = packed_ref_store_init,
1710-
.init_db = packed_ref_store_init_db,
1710+
.create_on_disk = packed_ref_store_create_on_disk,
17111711
.transaction_prepare = packed_transaction_prepare,
17121712
.transaction_finish = packed_transaction_finish,
17131713
.transaction_abort = packed_transaction_abort,

refs/refs-internal.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,9 @@ typedef struct ref_store *ref_store_init_fn(struct repository *repo,
530530
const char *gitdir,
531531
unsigned int flags);
532532

533-
typedef int ref_init_db_fn(struct ref_store *refs,
534-
int flags,
535-
struct strbuf *err);
533+
typedef int ref_store_create_on_disk_fn(struct ref_store *refs,
534+
int flags,
535+
struct strbuf *err);
536536

537537
typedef int ref_transaction_prepare_fn(struct ref_store *refs,
538538
struct ref_transaction *transaction,
@@ -668,7 +668,7 @@ typedef int read_symbolic_ref_fn(struct ref_store *ref_store, const char *refnam
668668
struct ref_storage_be {
669669
const char *name;
670670
ref_store_init_fn *init;
671-
ref_init_db_fn *init_db;
671+
ref_store_create_on_disk_fn *create_on_disk;
672672

673673
ref_transaction_prepare_fn *transaction_prepare;
674674
ref_transaction_finish_fn *transaction_finish;

refs/reftable-backend.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,12 +293,12 @@ static struct ref_store *reftable_be_init(struct repository *repo,
293293
return &refs->base;
294294
}
295295

296-
static int reftable_be_init_db(struct ref_store *ref_store,
297-
int flags UNUSED,
298-
struct strbuf *err UNUSED)
296+
static int reftable_be_create_on_disk(struct ref_store *ref_store,
297+
int flags UNUSED,
298+
struct strbuf *err UNUSED)
299299
{
300300
struct reftable_ref_store *refs =
301-
reftable_be_downcast(ref_store, REF_STORE_WRITE, "init_db");
301+
reftable_be_downcast(ref_store, REF_STORE_WRITE, "create");
302302
struct strbuf sb = STRBUF_INIT;
303303

304304
strbuf_addf(&sb, "%s/reftable", refs->base.gitdir);
@@ -2248,7 +2248,7 @@ static int reftable_be_reflog_expire(struct ref_store *ref_store,
22482248
struct ref_storage_be refs_be_reftable = {
22492249
.name = "reftable",
22502250
.init = reftable_be_init,
2251-
.init_db = reftable_be_init_db,
2251+
.create_on_disk = reftable_be_create_on_disk,
22522252
.transaction_prepare = reftable_be_transaction_prepare,
22532253
.transaction_finish = reftable_be_transaction_finish,
22542254
.transaction_abort = reftable_be_transaction_abort,

setup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2049,7 +2049,7 @@ void create_reference_database(unsigned int ref_storage_format,
20492049
int reinit = is_reinit();
20502050

20512051
repo_set_ref_storage_format(the_repository, ref_storage_format);
2052-
if (refs_init_db(get_main_ref_store(the_repository), 0, &err))
2052+
if (ref_store_create_on_disk(get_main_ref_store(the_repository), 0, &err))
20532053
die("failed to set up refs db: %s", err.buf);
20542054

20552055
/*

0 commit comments

Comments
 (0)