]> git.ipfire.org Git - thirdparty/git.git/commitdiff
refs: pass gitdir to packed_ref_store_create
authorHan-Wen Nienhuys <hanwen@google.com>
Wed, 22 Dec 2021 18:11:52 +0000 (18:11 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 22 Dec 2021 21:51:37 +0000 (13:51 -0800)
This is consistent with the calling convention for ref backend creation, and
avoids storing ".git/packed-refs" (the name of a regular file) in a variable called
ref_store::gitdir.

Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs/files-backend.c
refs/packed-backend.c
refs/packed-backend.h

index 90b671025a742d743cfeac118348de516c0425f9..f1b66130dfb48e28fa6a888b01fa5e16781f7ea5 100644 (file)
@@ -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",
index 67152c664e2e4bb0ee92d3f2ebc19cdd9840c895..caa1957252aae739ae09277c56df3542f1e301d4 100644 (file)
@@ -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;
 }
 
index f61a73ec25b4cb55d96bac23ada11a53e2781f95..9dd8a344c34dd7ae078f8226abf044219d5f3a3c 100644 (file)
@@ -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);
 
 /*