]> git.ipfire.org Git - thirdparty/git.git/commitdiff
refs: store the main ref store inside the repository struct
authorStefan Beller <sbeller@google.com>
Thu, 12 Apr 2018 00:21:14 +0000 (17:21 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 12 Apr 2018 02:38:56 +0000 (11:38 +0900)
This moves the 'main_ref_store', which was a global variable in refs.c
into the repository struct.

This patch does not deal with the parts in the refs subsystem which deal
with the submodules there. A later patch needs to get rid of the submodule
exposure in the refs API, such as 'get_submodule_ref_store(path)'.

Acked-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c
refs.h
refs/files-backend.c
repository.h

diff --git a/refs.c b/refs.c
index f58b9fb7dfc05d66dda2d08e88a3a7b537c40d10..36df1bc73af60eefa7902d6065d2bc8ca58dc18a 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -1608,9 +1608,6 @@ static struct ref_store_hash_entry *alloc_ref_store_hash_entry(
        return entry;
 }
 
-/* A pointer to the ref_store for the main repository: */
-static struct ref_store *main_ref_store;
-
 /* A hashmap of ref_stores, stored by submodule name: */
 static struct hashmap submodule_ref_stores;
 
@@ -1652,13 +1649,13 @@ static struct ref_store *ref_store_init(const char *gitdir,
        return refs;
 }
 
-struct ref_store *get_main_ref_store_the_repository(void)
+struct ref_store *get_main_ref_store(struct repository *r)
 {
-       if (main_ref_store)
-               return main_ref_store;
+       if (r->refs)
+               return r->refs;
 
-       main_ref_store = ref_store_init(get_git_dir(), REF_STORE_ALL_CAPS);
-       return main_ref_store;
+       r->refs = ref_store_init(r->gitdir, REF_STORE_ALL_CAPS);
+       return r->refs;
 }
 
 /*
diff --git a/refs.h b/refs.h
index ab3d2bec2f33b442f369002bc9b8349d49968839..f5ab68c0edd4756a30e31b60708ffa1cf5993c7e 100644 (file)
--- a/refs.h
+++ b/refs.h
@@ -760,9 +760,7 @@ int reflog_expire(const char *refname, const struct object_id *oid,
 
 int ref_storage_backend_exists(const char *name);
 
-#define get_main_ref_store(r) \
-       get_main_ref_store_##r()
-struct ref_store *get_main_ref_store_the_repository(void);
+struct ref_store *get_main_ref_store(struct repository *r);
 /*
  * Return the ref_store instance for the specified submodule. For the
  * main repository, use submodule==NULL; such a call cannot fail. For
index bec8e30e9e3e2995739dfff7cc971f8de623610d..5c76a7581781440c27ddc1f5ffa96eeca2e4c1a4 100644 (file)
@@ -61,10 +61,6 @@ struct ref_lock {
        struct object_id old_oid;
 };
 
-/*
- * Future: need to be in "struct repository"
- * when doing a full libification.
- */
 struct files_ref_store {
        struct ref_store base;
        unsigned int store_flags;
index 09df94a4722dacc40ab106e3b3ca348167daa764..e6e00f541bdc7f61b08ad881b8d66047cc0f1d02 100644 (file)
@@ -26,6 +26,9 @@ struct repository {
         */
        struct raw_object_store *objects;
 
+       /* The store in which the refs are held. */
+       struct ref_store *refs;
+
        /*
         * Path to the repository's graft file.
         * Cannot be NULL after initialization.