Skip to content

Commit 99f0d97

Browse files
hanwengitster
authored andcommitted
refs: pass gitdir to packed_ref_store_create
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 597af31 commit 99f0d97

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

refs/files-backend.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,8 @@ static struct ref_store *files_ref_store_create(struct repository *repo,
9393

9494
get_common_dir_noenv(&sb, gitdir);
9595
refs->gitcommondir = strbuf_detach(&sb, NULL);
96-
strbuf_addf(&sb, "%s/packed-refs", refs->gitcommondir);
97-
refs->packed_ref_store = packed_ref_store_create(repo, sb.buf, flags);
98-
strbuf_release(&sb);
96+
refs->packed_ref_store =
97+
packed_ref_store_create(repo, refs->gitcommondir, flags);
9998

10099
chdir_notify_reparent("files-backend $GIT_DIR", &refs->base.gitdir);
101100
chdir_notify_reparent("files-backend $GIT_COMMONDIR",

refs/packed-backend.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,20 +194,21 @@ static int release_snapshot(struct snapshot *snapshot)
194194
}
195195

196196
struct ref_store *packed_ref_store_create(struct repository *repo,
197-
const char *path,
197+
const char *gitdir,
198198
unsigned int store_flags)
199199
{
200200
struct packed_ref_store *refs = xcalloc(1, sizeof(*refs));
201201
struct ref_store *ref_store = (struct ref_store *)refs;
202+
struct strbuf sb = STRBUF_INIT;
202203

203204
base_ref_store_init(ref_store, &refs_be_packed);
204205
ref_store->repo = repo;
205-
ref_store->gitdir = xstrdup(path);
206+
ref_store->gitdir = xstrdup(gitdir);
206207
refs->store_flags = store_flags;
208+
strbuf_addf(&sb, "%s/packed-refs", gitdir);
209+
refs->path = strbuf_detach(&sb, NULL);
207210

208-
refs->path = xstrdup(path);
209211
chdir_notify_reparent("packed-refs", &refs->path);
210-
211212
return ref_store;
212213
}
213214

refs/packed-backend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct ref_transaction;
1414
*/
1515

1616
struct ref_store *packed_ref_store_create(struct repository *repo,
17-
const char *path,
17+
const char *gitdir,
1818
unsigned int store_flags);
1919

2020
/*

0 commit comments

Comments
 (0)