diff --git a/refs/files-backend.c b/refs/files-backend.c index 90b671025a..f1b66130df 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -93,9 +93,8 @@ static struct ref_store *files_ref_store_create(struct repository *repo, 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..caa1957252 100644 --- a/refs/packed-backend.c +++ b/refs/packed-backend.c @@ -194,20 +194,21 @@ 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); + ref_store->gitdir = xstrdup(gitdir); refs->store_flags = store_flags; + strbuf_addf(&sb, "%s/packed-refs", gitdir); + refs->path = strbuf_detach(&sb, NULL); - refs->path = xstrdup(path); 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); /*