From e00d1a4ff7d79b403bf97a0746138d584c9ebf9a Mon Sep 17 00:00:00 2001 From: Michael Haggerty Date: Sun, 16 Apr 2017 08:41:33 +0200 Subject: refs: record the ref_store in ref_cache, not ref_dir Instead of keeping a pointer to the `ref_store` in every `ref_dir` entry, store it once in `struct ref_cache`, and change `struct ref_dir` to include a pointer to its containing `ref_cache` instead. This makes it easier to add to the information that is accessible from a `ref_dir` without increasing the size of every `ref_dir` instance. Note that previously, every `ref_dir` pointed at the containing `files_ref_store` regardless of whether it was a part of the loose or packed reference cache. Now we have to be sure to initialize the instances to point at the correct containing `ref_cache`. So change `create_dir_entry()` to take a `ref_cache` parameter, and change its callers to pass the correct `ref_cache` depending on the purpose of the new `dir_entry`. Signed-off-by: Michael Haggerty Signed-off-by: Junio C Hamano --- refs/ref-cache.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'refs/ref-cache.h') diff --git a/refs/ref-cache.h b/refs/ref-cache.h index da5388c136..83051854ff 100644 --- a/refs/ref-cache.h +++ b/refs/ref-cache.h @@ -3,6 +3,9 @@ struct ref_cache { struct ref_entry *root; + + /* A pointer to the files_ref_store whose cache this is: */ + struct files_ref_store *ref_store; }; /* @@ -66,8 +69,8 @@ struct ref_dir { */ int sorted; - /* A pointer to the files_ref_store that contains this ref_dir. */ - struct files_ref_store *ref_store; + /* The ref_cache containing this entry: */ + struct ref_cache *cache; struct ref_entry **entries; }; @@ -161,7 +164,7 @@ struct ref_dir *get_ref_dir(struct ref_entry *entry); * dirname is the name of the directory with a trailing slash (e.g., * "refs/heads/") or "" for the top-level directory. */ -struct ref_entry *create_dir_entry(struct files_ref_store *ref_store, +struct ref_entry *create_dir_entry(struct ref_cache *cache, const char *dirname, size_t len, int incomplete); -- cgit v1.3