aboutsummaryrefslogtreecommitdiff
path: root/refs
diff options
context:
space:
mode:
authorDavid Turner <dturner@twopensource.com>2016-09-04 18:08:41 +0200
committerJunio C Hamano <gitster@pobox.com>2016-09-09 15:28:14 -0700
commit6fb5acfd8f7102f53dedc887233313f233a65932 (patch)
tree0e7bfa8bb9bff754e05680d9ab913f9fd0c310c0 /refs
parenta27dcf89b6867577bb714e181dd181cd1a1e6512 (diff)
downloadgit-6fb5acfd8f7102f53dedc887233313f233a65932.tar.gz
git-6fb5acfd8f7102f53dedc887233313f233a65932.tar.xz
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>
Diffstat (limited to 'refs')
-rw-r--r--refs/files-backend.c18
-rw-r--r--refs/refs-internal.h3
2 files changed, 21 insertions, 0 deletions
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 33ec53038..40e789611 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -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,
diff --git a/refs/refs-internal.h b/refs/refs-internal.h
index ade65010d..b3a20955c 100644
--- a/refs/refs-internal.h
+++ b/refs/refs-internal.h
@@ -479,6 +479,8 @@ struct ref_store;
*/
typedef struct ref_store *ref_store_init_fn(const char *submodule);
+typedef int ref_init_db_fn(struct ref_store *refs, struct strbuf *err);
+
typedef int ref_transaction_commit_fn(struct ref_store *refs,
struct ref_transaction *transaction,
struct strbuf *err);
@@ -583,6 +585,7 @@ struct ref_storage_be {
struct ref_storage_be *next;
const char *name;
ref_store_init_fn *init;
+ ref_init_db_fn *init_db;
ref_transaction_commit_fn *transaction_commit;
ref_transaction_commit_fn *initial_transaction_commit;