refs: prepare refs_init_db() for initializing worktree refs

The purpose of `refs_init_db()` is to initialize the on-disk files of a
new ref database. The function is quite inflexible right now though, as
callers can neither specify the `struct ref_store` nor can they pass any
flags.

Refactor the interface to accept both of these. This will be required so
that we can start initializing per-worktree ref databases via the ref
backend instead of open-coding the initialization in "worktree.c".

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2024-01-08 11:05:26 +01:00
committed by Junio C Hamano
parent 5bf20d6c77
commit 2e573d61ff
7 changed files with 13 additions and 10 deletions

View File

@ -1943,7 +1943,7 @@ void create_reference_database(unsigned int ref_storage_format,
adjust_shared_perm(git_path("refs"));
repo_set_ref_storage_format(the_repository, ref_storage_format);
if (refs_init_db(&err))
if (refs_init_db(get_main_ref_store(the_repository), 0, &err))
die("failed to set up refs db: %s", err.buf);
/*