summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--refs.c6
-rw-r--r--refs/debug.c6
-rw-r--r--refs/files-backend.c10
-rw-r--r--refs/packed-backend.c11
-rw-r--r--refs/packed-backend.h2
-rw-r--r--refs/refs-internal.h4
6 files changed, 19 insertions, 20 deletions
diff --git a/refs.c b/refs.c
index 4da4996c4d..bd2546ae23 100644
--- a/refs.c
+++ b/refs.c
@@ -2007,10 +2007,12 @@ struct ref_store *get_worktree_ref_store(const struct worktree *wt)
return refs;
}
-void base_ref_store_init(struct ref_store *refs,
- const struct ref_storage_be *be)
+void base_ref_store_init(struct ref_store *refs, struct repository *repo,
+ const char *path, const struct ref_storage_be *be)
{
refs->be = be;
+ refs->repo = repo;
+ refs->gitdir = xstrdup(path);
}
/* backend functions */
diff --git a/refs/debug.c b/refs/debug.c
index 791423c6a7..2b0771ca53 100644
--- a/refs/debug.c
+++ b/refs/debug.c
@@ -26,7 +26,8 @@ struct ref_store *maybe_debug_wrap_ref_store(const char *gitdir, struct ref_stor
be_copy->name = store->be->name;
trace_printf_key(&trace_refs, "ref_store for %s\n", gitdir);
res->refs = store;
- base_ref_store_init((struct ref_store *)res, be_copy);
+ base_ref_store_init((struct ref_store *)res, store->repo, gitdir,
+ be_copy);
return (struct ref_store *)res;
}
@@ -47,7 +48,8 @@ static int debug_transaction_prepare(struct ref_store *refs,
transaction->ref_store = drefs->refs;
res = drefs->refs->be->transaction_prepare(drefs->refs, transaction,
err);
- trace_printf_key(&trace_refs, "transaction_prepare: %d\n", res);
+ trace_printf_key(&trace_refs, "transaction_prepare: %d \"%s\"\n", res,
+ err->buf);
return res;
}
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 90b671025a..5c6d49a267 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -86,16 +86,12 @@ static struct ref_store *files_ref_store_create(struct repository *repo,
struct ref_store *ref_store = (struct ref_store *)refs;
struct strbuf sb = STRBUF_INIT;
- ref_store->repo = repo;
- ref_store->gitdir = xstrdup(gitdir);
- base_ref_store_init(ref_store, &refs_be_files);
+ base_ref_store_init(ref_store, repo, gitdir, &refs_be_files);
refs->store_flags = flags;
-
get_common_dir_noenv(&sb, gitdir);
refs->gitcommondir = strbuf_detach(&sb, NULL);
- strbuf_addf(&sb, "%s/packed-refs", refs->gitcommondir);
- refs->packed_ref_store = packed_ref_store_create(repo, sb.buf, flags);
- strbuf_release(&sb);
+ refs->packed_ref_store =
+ packed_ref_store_create(repo, refs->gitcommondir, flags);
chdir_notify_reparent("files-backend $GIT_DIR", &refs->base.gitdir);
chdir_notify_reparent("files-backend $GIT_COMMONDIR",
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index 67152c664e..d91a2018f6 100644
--- a/refs/packed-backend.c
+++ b/refs/packed-backend.c
@@ -194,20 +194,19 @@ static int release_snapshot(struct snapshot *snapshot)
}
struct ref_store *packed_ref_store_create(struct repository *repo,
- const char *path,
+ const char *gitdir,
unsigned int store_flags)
{
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, &refs_be_packed);
- ref_store->repo = repo;
- ref_store->gitdir = xstrdup(path);
+ base_ref_store_init(ref_store, repo, gitdir, &refs_be_packed);
refs->store_flags = store_flags;
- refs->path = xstrdup(path);
+ strbuf_addf(&sb, "%s/packed-refs", gitdir);
+ refs->path = strbuf_detach(&sb, NULL);
chdir_notify_reparent("packed-refs", &refs->path);
-
return ref_store;
}
diff --git a/refs/packed-backend.h b/refs/packed-backend.h
index f61a73ec25..9dd8a344c3 100644
--- a/refs/packed-backend.h
+++ b/refs/packed-backend.h
@@ -14,7 +14,7 @@ struct ref_transaction;
*/
struct ref_store *packed_ref_store_create(struct repository *repo,
- const char *path,
+ const char *gitdir,
unsigned int store_flags);
/*
diff --git a/refs/refs-internal.h b/refs/refs-internal.h
index 46a839539e..7ff6fba4f0 100644
--- a/refs/refs-internal.h
+++ b/refs/refs-internal.h
@@ -710,8 +710,8 @@ int parse_loose_ref_contents(const char *buf, struct object_id *oid,
* Fill in the generic part of refs and add it to our collection of
* reference stores.
*/
-void base_ref_store_init(struct ref_store *refs,
- const struct ref_storage_be *be);
+void base_ref_store_init(struct ref_store *refs, struct repository *repo,
+ const char *path, const struct ref_storage_be *be);
/*
* Support GIT_TRACE_REFS by optionally wrapping the given ref_store instance.