Skip to content

Commit 6e1683a

Browse files
pks-tgitster
authored andcommitted
refs: pass storage format to ref_store_init() explicitly
We're about to introduce logic to migrate refs from one storage format to another one. This will require us to initialize a ref store with a different format than the one used by the passed-in repository. Prepare for this by accepting the desired ref storage format as parameter. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 318efb9 commit 6e1683a

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

refs.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1891,16 +1891,17 @@ static struct ref_store *lookup_ref_store_map(struct strmap *map,
18911891

18921892
/*
18931893
* Create, record, and return a ref_store instance for the specified
1894-
* gitdir.
1894+
* gitdir using the given ref storage format.
18951895
*/
18961896
static struct ref_store *ref_store_init(struct repository *repo,
1897+
enum ref_storage_format format,
18971898
const char *gitdir,
18981899
unsigned int flags)
18991900
{
19001901
const struct ref_storage_be *be;
19011902
struct ref_store *refs;
19021903

1903-
be = find_ref_storage_backend(repo->ref_storage_format);
1904+
be = find_ref_storage_backend(format);
19041905
if (!be)
19051906
BUG("reference backend is unknown");
19061907

@@ -1922,7 +1923,8 @@ struct ref_store *get_main_ref_store(struct repository *r)
19221923
if (!r->gitdir)
19231924
BUG("attempting to get main_ref_store outside of repository");
19241925

1925-
r->refs_private = ref_store_init(r, r->gitdir, REF_STORE_ALL_CAPS);
1926+
r->refs_private = ref_store_init(r, r->ref_storage_format,
1927+
r->gitdir, REF_STORE_ALL_CAPS);
19261928
r->refs_private = maybe_debug_wrap_ref_store(r->gitdir, r->refs_private);
19271929
return r->refs_private;
19281930
}
@@ -1982,7 +1984,8 @@ struct ref_store *repo_get_submodule_ref_store(struct repository *repo,
19821984
free(subrepo);
19831985
goto done;
19841986
}
1985-
refs = ref_store_init(subrepo, submodule_sb.buf,
1987+
refs = ref_store_init(subrepo, the_repository->ref_storage_format,
1988+
submodule_sb.buf,
19861989
REF_STORE_READ | REF_STORE_ODB);
19871990
register_ref_store_map(&repo->submodule_ref_stores, "submodule",
19881991
refs, submodule);
@@ -2011,12 +2014,12 @@ struct ref_store *get_worktree_ref_store(const struct worktree *wt)
20112014
struct strbuf common_path = STRBUF_INIT;
20122015
strbuf_git_common_path(&common_path, wt->repo,
20132016
"worktrees/%s", wt->id);
2014-
refs = ref_store_init(wt->repo, common_path.buf,
2015-
REF_STORE_ALL_CAPS);
2017+
refs = ref_store_init(wt->repo, wt->repo->ref_storage_format,
2018+
common_path.buf, REF_STORE_ALL_CAPS);
20162019
strbuf_release(&common_path);
20172020
} else {
2018-
refs = ref_store_init(wt->repo, wt->repo->commondir,
2019-
REF_STORE_ALL_CAPS);
2021+
refs = ref_store_init(wt->repo, the_repository->ref_storage_format,
2022+
wt->repo->commondir, REF_STORE_ALL_CAPS);
20202023
}
20212024

20222025
if (refs)

0 commit comments

Comments
 (0)