refs: add methods to init refs db
Alternate refs backends might not need the refs/heads directory and so on, so we make ref db initialization part of the backend. Signed-off-by: David Turner <dturner@twopensource.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
a27dcf89b6
commit
6fb5acfd8f
@ -4058,10 +4058,28 @@ static int files_reflog_expire(struct ref_store *ref_store,
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int files_init_db(struct ref_store *ref_store, struct strbuf *err)
|
||||
{
|
||||
/* Check validity (but we don't need the result): */
|
||||
files_downcast(ref_store, 0, "init_db");
|
||||
|
||||
/*
|
||||
* Create .git/refs/{heads,tags}
|
||||
*/
|
||||
safe_create_dir(git_path("refs/heads"), 1);
|
||||
safe_create_dir(git_path("refs/tags"), 1);
|
||||
if (get_shared_repository()) {
|
||||
adjust_shared_perm(git_path("refs/heads"));
|
||||
adjust_shared_perm(git_path("refs/tags"));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct ref_storage_be refs_be_files = {
|
||||
NULL,
|
||||
"files",
|
||||
files_ref_store_create,
|
||||
files_init_db,
|
||||
files_transaction_commit,
|
||||
files_initial_transaction_commit,
|
||||
|
||||
|
Reference in New Issue
Block a user