summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--refs.c8
-rw-r--r--repository.h8
-rw-r--r--sha1-name.c2
3 files changed, 11 insertions, 7 deletions
diff --git a/refs.c b/refs.c
index 92d1f6dbdd..4cc32e7aad 100644
--- a/refs.c
+++ b/refs.c
@@ -1774,14 +1774,14 @@ static struct ref_store *ref_store_init(const char *gitdir,
struct ref_store *get_main_ref_store(struct repository *r)
{
- if (r->refs)
- return r->refs;
+ if (r->refs_private)
+ return r->refs_private;
if (!r->gitdir)
BUG("attempting to get main_ref_store outside of repository");
- r->refs = ref_store_init(r->gitdir, REF_STORE_ALL_CAPS);
- return r->refs;
+ r->refs_private = ref_store_init(r->gitdir, REF_STORE_ALL_CAPS);
+ return r->refs_private;
}
/*
diff --git a/repository.h b/repository.h
index 4fb6a5885f..4ecc201f89 100644
--- a/repository.h
+++ b/repository.h
@@ -39,8 +39,12 @@ struct repository {
*/
struct parsed_object_pool *parsed_objects;
- /* The store in which the refs are held. */
- struct ref_store *refs;
+ /*
+ * The store in which the refs are held. This should generally only be
+ * accessed via get_main_ref_store(), as that will lazily initialize
+ * the ref object.
+ */
+ struct ref_store *refs_private;
/*
* Contains path to often used file names.
diff --git a/sha1-name.c b/sha1-name.c
index 3aba62938f..c679e246cd 100644
--- a/sha1-name.c
+++ b/sha1-name.c
@@ -1772,7 +1772,7 @@ static enum get_oid_result get_oid_with_context_1(struct repository *repo,
cb.repo = repo;
cb.list = &list;
refs_for_each_ref(get_main_ref_store(repo), handle_one_ref, &cb);
- refs_head_ref(repo->refs, handle_one_ref, &cb);
+ refs_head_ref(get_main_ref_store(repo), handle_one_ref, &cb);
commit_list_sort_by_date(&list);
return get_oid_oneline(repo, name + 2, oid, list);
}