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 <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
1febabff7a
commit
ed93ea1602
@ -509,7 +509,7 @@ static int add_worktree(const char *path, const char *refname,
|
|||||||
}
|
}
|
||||||
wt_refs = get_worktree_ref_store(wt);
|
wt_refs = get_worktree_ref_store(wt);
|
||||||
|
|
||||||
ret = refs_init_db(wt_refs, REFS_INIT_DB_IS_WORKTREE, &sb);
|
ret = ref_store_create_on_disk(wt_refs, REF_STORE_CREATE_ON_DISK_IS_WORKTREE, &sb);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
|
4
refs.c
4
refs.c
@ -1938,9 +1938,9 @@ const char *refs_resolve_ref_unsafe(struct ref_store *refs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* backend functions */
|
/* backend functions */
|
||||||
int refs_init_db(struct ref_store *refs, int flags, struct strbuf *err)
|
int ref_store_create_on_disk(struct ref_store *refs, int flags, struct strbuf *err)
|
||||||
{
|
{
|
||||||
return refs->be->init_db(refs, flags, err);
|
return refs->be->create_on_disk(refs, flags, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
int resolve_gitlink_ref(const char *submodule, const char *refname,
|
int resolve_gitlink_ref(const char *submodule, const char *refname,
|
||||||
|
4
refs.h
4
refs.h
@ -114,9 +114,9 @@ int should_autocreate_reflog(const char *refname);
|
|||||||
|
|
||||||
int is_branch(const char *refname);
|
int is_branch(const char *refname);
|
||||||
|
|
||||||
#define REFS_INIT_DB_IS_WORKTREE (1 << 0)
|
#define REF_STORE_CREATE_ON_DISK_IS_WORKTREE (1 << 0)
|
||||||
|
|
||||||
int refs_init_db(struct ref_store *refs, int flags, struct strbuf *err);
|
int ref_store_create_on_disk(struct ref_store *refs, int flags, struct strbuf *err);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return the peeled value of the oid currently being iterated via
|
* Return the peeled value of the oid currently being iterated via
|
||||||
|
@ -33,11 +33,11 @@ struct ref_store *maybe_debug_wrap_ref_store(const char *gitdir, struct ref_stor
|
|||||||
return (struct ref_store *)res;
|
return (struct ref_store *)res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int debug_init_db(struct ref_store *refs, int flags, struct strbuf *err)
|
static int debug_create_on_disk(struct ref_store *refs, int flags, struct strbuf *err)
|
||||||
{
|
{
|
||||||
struct debug_ref_store *drefs = (struct debug_ref_store *)refs;
|
struct debug_ref_store *drefs = (struct debug_ref_store *)refs;
|
||||||
int res = drefs->refs->be->init_db(drefs->refs, flags, err);
|
int res = drefs->refs->be->create_on_disk(drefs->refs, flags, err);
|
||||||
trace_printf_key(&trace_refs, "init_db: %d\n", res);
|
trace_printf_key(&trace_refs, "create_on_disk: %d\n", res);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,7 +427,7 @@ static int debug_reflog_expire(struct ref_store *ref_store, const char *refname,
|
|||||||
struct ref_storage_be refs_be_debug = {
|
struct ref_storage_be refs_be_debug = {
|
||||||
.name = "debug",
|
.name = "debug",
|
||||||
.init = NULL,
|
.init = NULL,
|
||||||
.init_db = debug_init_db,
|
.create_on_disk = debug_create_on_disk,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* None of these should be NULL. If the "files" backend (in
|
* None of these should be NULL. If the "files" backend (in
|
||||||
|
@ -3236,12 +3236,12 @@ static int files_reflog_expire(struct ref_store *ref_store,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int files_init_db(struct ref_store *ref_store,
|
static int files_ref_store_create_on_disk(struct ref_store *ref_store,
|
||||||
int flags,
|
int flags,
|
||||||
struct strbuf *err UNUSED)
|
struct strbuf *err UNUSED)
|
||||||
{
|
{
|
||||||
struct files_ref_store *refs =
|
struct files_ref_store *refs =
|
||||||
files_downcast(ref_store, REF_STORE_WRITE, "init_db");
|
files_downcast(ref_store, REF_STORE_WRITE, "create");
|
||||||
struct strbuf sb = STRBUF_INIT;
|
struct strbuf sb = STRBUF_INIT;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -3264,7 +3264,7 @@ static int files_init_db(struct ref_store *ref_store,
|
|||||||
* There is no need to create directories for common refs when creating
|
* There is no need to create directories for common refs when creating
|
||||||
* a worktree ref store.
|
* a worktree ref store.
|
||||||
*/
|
*/
|
||||||
if (!(flags & REFS_INIT_DB_IS_WORKTREE)) {
|
if (!(flags & REF_STORE_CREATE_ON_DISK_IS_WORKTREE)) {
|
||||||
/*
|
/*
|
||||||
* Create .git/refs/{heads,tags}
|
* Create .git/refs/{heads,tags}
|
||||||
*/
|
*/
|
||||||
@ -3284,7 +3284,7 @@ static int files_init_db(struct ref_store *ref_store,
|
|||||||
struct ref_storage_be refs_be_files = {
|
struct ref_storage_be refs_be_files = {
|
||||||
.name = "files",
|
.name = "files",
|
||||||
.init = files_ref_store_init,
|
.init = files_ref_store_init,
|
||||||
.init_db = files_init_db,
|
.create_on_disk = files_ref_store_create_on_disk,
|
||||||
.transaction_prepare = files_transaction_prepare,
|
.transaction_prepare = files_transaction_prepare,
|
||||||
.transaction_finish = files_transaction_finish,
|
.transaction_finish = files_transaction_finish,
|
||||||
.transaction_abort = files_transaction_abort,
|
.transaction_abort = files_transaction_abort,
|
||||||
|
@ -1244,7 +1244,7 @@ int packed_refs_is_locked(struct ref_store *ref_store)
|
|||||||
static const char PACKED_REFS_HEADER[] =
|
static const char PACKED_REFS_HEADER[] =
|
||||||
"# pack-refs with: peeled fully-peeled sorted \n";
|
"# pack-refs with: peeled fully-peeled sorted \n";
|
||||||
|
|
||||||
static int packed_ref_store_init_db(struct ref_store *ref_store UNUSED,
|
static int packed_ref_store_create_on_disk(struct ref_store *ref_store UNUSED,
|
||||||
int flags UNUSED,
|
int flags UNUSED,
|
||||||
struct strbuf *err UNUSED)
|
struct strbuf *err UNUSED)
|
||||||
{
|
{
|
||||||
@ -1707,7 +1707,7 @@ static struct ref_iterator *packed_reflog_iterator_begin(struct ref_store *ref_s
|
|||||||
struct ref_storage_be refs_be_packed = {
|
struct ref_storage_be refs_be_packed = {
|
||||||
.name = "packed",
|
.name = "packed",
|
||||||
.init = packed_ref_store_init,
|
.init = packed_ref_store_init,
|
||||||
.init_db = packed_ref_store_init_db,
|
.create_on_disk = packed_ref_store_create_on_disk,
|
||||||
.transaction_prepare = packed_transaction_prepare,
|
.transaction_prepare = packed_transaction_prepare,
|
||||||
.transaction_finish = packed_transaction_finish,
|
.transaction_finish = packed_transaction_finish,
|
||||||
.transaction_abort = packed_transaction_abort,
|
.transaction_abort = packed_transaction_abort,
|
||||||
|
@ -530,7 +530,7 @@ typedef struct ref_store *ref_store_init_fn(struct repository *repo,
|
|||||||
const char *gitdir,
|
const char *gitdir,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
|
|
||||||
typedef int ref_init_db_fn(struct ref_store *refs,
|
typedef int ref_store_create_on_disk_fn(struct ref_store *refs,
|
||||||
int flags,
|
int flags,
|
||||||
struct strbuf *err);
|
struct strbuf *err);
|
||||||
|
|
||||||
@ -668,7 +668,7 @@ typedef int read_symbolic_ref_fn(struct ref_store *ref_store, const char *refnam
|
|||||||
struct ref_storage_be {
|
struct ref_storage_be {
|
||||||
const char *name;
|
const char *name;
|
||||||
ref_store_init_fn *init;
|
ref_store_init_fn *init;
|
||||||
ref_init_db_fn *init_db;
|
ref_store_create_on_disk_fn *create_on_disk;
|
||||||
|
|
||||||
ref_transaction_prepare_fn *transaction_prepare;
|
ref_transaction_prepare_fn *transaction_prepare;
|
||||||
ref_transaction_finish_fn *transaction_finish;
|
ref_transaction_finish_fn *transaction_finish;
|
||||||
|
@ -293,12 +293,12 @@ done:
|
|||||||
return &refs->base;
|
return &refs->base;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int reftable_be_init_db(struct ref_store *ref_store,
|
static int reftable_be_create_on_disk(struct ref_store *ref_store,
|
||||||
int flags UNUSED,
|
int flags UNUSED,
|
||||||
struct strbuf *err UNUSED)
|
struct strbuf *err UNUSED)
|
||||||
{
|
{
|
||||||
struct reftable_ref_store *refs =
|
struct reftable_ref_store *refs =
|
||||||
reftable_be_downcast(ref_store, REF_STORE_WRITE, "init_db");
|
reftable_be_downcast(ref_store, REF_STORE_WRITE, "create");
|
||||||
struct strbuf sb = STRBUF_INIT;
|
struct strbuf sb = STRBUF_INIT;
|
||||||
|
|
||||||
strbuf_addf(&sb, "%s/reftable", refs->base.gitdir);
|
strbuf_addf(&sb, "%s/reftable", refs->base.gitdir);
|
||||||
@ -2248,7 +2248,7 @@ done:
|
|||||||
struct ref_storage_be refs_be_reftable = {
|
struct ref_storage_be refs_be_reftable = {
|
||||||
.name = "reftable",
|
.name = "reftable",
|
||||||
.init = reftable_be_init,
|
.init = reftable_be_init,
|
||||||
.init_db = reftable_be_init_db,
|
.create_on_disk = reftable_be_create_on_disk,
|
||||||
.transaction_prepare = reftable_be_transaction_prepare,
|
.transaction_prepare = reftable_be_transaction_prepare,
|
||||||
.transaction_finish = reftable_be_transaction_finish,
|
.transaction_finish = reftable_be_transaction_finish,
|
||||||
.transaction_abort = reftable_be_transaction_abort,
|
.transaction_abort = reftable_be_transaction_abort,
|
||||||
|
2
setup.c
2
setup.c
@ -2049,7 +2049,7 @@ void create_reference_database(unsigned int ref_storage_format,
|
|||||||
int reinit = is_reinit();
|
int reinit = is_reinit();
|
||||||
|
|
||||||
repo_set_ref_storage_format(the_repository, ref_storage_format);
|
repo_set_ref_storage_format(the_repository, ref_storage_format);
|
||||||
if (refs_init_db(get_main_ref_store(the_repository), 0, &err))
|
if (ref_store_create_on_disk(get_main_ref_store(the_repository), 0, &err))
|
||||||
die("failed to set up refs db: %s", err.buf);
|
die("failed to set up refs db: %s", err.buf);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user