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 <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
7c22bc8a18
commit
e00d1a4ff7
@ -432,7 +432,7 @@ static void add_packed_ref(struct files_ref_store *refs,
|
||||
*/
|
||||
void read_loose_refs(const char *dirname, struct ref_dir *dir)
|
||||
{
|
||||
struct files_ref_store *refs = dir->ref_store;
|
||||
struct files_ref_store *refs = dir->cache->ref_store;
|
||||
DIR *d;
|
||||
struct dirent *de;
|
||||
int dirnamelen = strlen(dirname);
|
||||
@ -468,7 +468,7 @@ void read_loose_refs(const char *dirname, struct ref_dir *dir)
|
||||
} else if (S_ISDIR(st.st_mode)) {
|
||||
strbuf_addch(&refname, '/');
|
||||
add_entry_to_dir(dir,
|
||||
create_dir_entry(refs, refname.buf,
|
||||
create_dir_entry(dir->cache, refname.buf,
|
||||
refname.len, 1));
|
||||
} else {
|
||||
if (!refs_resolve_ref_unsafe(&refs->base,
|
||||
@ -525,7 +525,7 @@ static struct ref_dir *get_loose_refs(struct files_ref_store *refs)
|
||||
* lazily):
|
||||
*/
|
||||
add_entry_to_dir(get_ref_dir(refs->loose->root),
|
||||
create_dir_entry(refs, "refs/", 5, 1));
|
||||
create_dir_entry(refs->loose, "refs/", 5, 1));
|
||||
}
|
||||
return get_ref_dir(refs->loose->root);
|
||||
}
|
||||
|
Reference in New Issue
Block a user