{
const struct ref_storage_be *be;
struct ref_store *refs;
+ struct ref_store_init_options opts = {
+ .access_flags = flags,
+ };
be = find_ref_storage_backend(format);
if (!be)
* TODO Send in a 'struct worktree' instead of a 'gitdir', and
* allow the backend to handle how it wants to deal with worktrees.
*/
- refs = be->init(repo, repo->ref_storage_payload, gitdir, flags);
+ refs = be->init(repo, repo->ref_storage_payload, gitdir, &opts);
+
return refs;
}
static struct ref_store *files_ref_store_init(struct repository *repo,
const char *payload,
const char *gitdir,
- unsigned int flags)
+ const struct ref_store_init_options *opts)
{
struct files_ref_store *refs = xcalloc(1, sizeof(*refs));
struct ref_store *ref_store = (struct ref_store *)refs;
&ref_common_dir);
base_ref_store_init(ref_store, repo, refdir.buf, &refs_be_files);
- refs->store_flags = flags;
+
refs->gitcommondir = strbuf_detach(&ref_common_dir, NULL);
refs->packed_ref_store =
- packed_ref_store_init(repo, NULL, refs->gitcommondir, flags);
+ packed_ref_store_init(repo, NULL, refs->gitcommondir, opts);
+ refs->store_flags = opts->access_flags;
refs->log_all_ref_updates = repo_settings_get_log_all_ref_updates(repo);
+
repo_config_get_bool(repo, "core.prefersymlinkrefs", &refs->prefer_symlink_refs);
chdir_notify_reparent("files-backend $GIT_DIR", &refs->base.gitdir);
struct ref_store *packed_ref_store_init(struct repository *repo,
const char *payload UNUSED,
const char *gitdir,
- unsigned int store_flags)
+ const struct ref_store_init_options *opts)
{
struct packed_ref_store *refs = xcalloc(1, sizeof(*refs));
struct ref_store *ref_store = (struct ref_store *)refs;
struct strbuf sb = STRBUF_INIT;
base_ref_store_init(ref_store, repo, gitdir, &refs_be_packed);
- refs->store_flags = store_flags;
+ refs->store_flags = opts->access_flags;
strbuf_addf(&sb, "%s/packed-refs", gitdir);
refs->path = strbuf_detach(&sb, NULL);
struct repository;
struct ref_transaction;
+struct ref_store_init_options;
/*
* Support for storing references in a `packed-refs` file.
struct ref_store *packed_ref_store_init(struct repository *repo,
const char *payload,
const char *gitdir,
- unsigned int store_flags);
+ const struct ref_store_init_options *options);
/*
* Lock the packed-refs file for writing. Flags is passed to
REF_STORE_ODB | \
REF_STORE_MAIN)
+/*
+ * Options for initializing the ref backend. All backend-agnostic information
+ * which backends required will be held here.
+ */
+struct ref_store_init_options {
+ /* The kind of operations that the ref_store is allowed to perform. */
+ unsigned int access_flags;
+};
+
/*
* Initialize the ref_store for the specified gitdir. These functions
* should call base_ref_store_init() to initialize the shared part of
typedef struct ref_store *ref_store_init_fn(struct repository *repo,
const char *payload,
const char *gitdir,
- unsigned int flags);
+ const struct ref_store_init_options *opts);
/*
* Release all memory and resources associated with the ref store.
*/
static struct ref_store *reftable_be_init(struct repository *repo,
const char *payload,
const char *gitdir,
- unsigned int store_flags)
+ const struct ref_store_init_options *opts)
{
struct reftable_ref_store *refs = xcalloc(1, sizeof(*refs));
struct strbuf ref_common_dir = STRBUF_INIT;
base_ref_store_init(&refs->base, repo, refdir.buf, &refs_be_reftable);
strmap_init(&refs->worktree_backends);
- refs->store_flags = store_flags;
refs->log_all_ref_updates = repo_settings_get_log_all_ref_updates(repo);
+ refs->store_flags = opts->access_flags;
switch (repo->hash_algo->format_id) {
case GIT_SHA1_FORMAT_ID: