[PATCH 28/30] read_loose_refs(): access ref_cache via the ref_dir field
- From
mhagger@alum.mit.edu <mhagger@alum.mit.edu>
- Date
- Apr 24, 2012, 22:45 UTC
- Message-ID
- <1335307536-26914-29-git-send-email-mhagger@alum.mit.edu>
- In-Reply-To
- <1335307536-26914-1-git-send-email-mhagger@alum.mit.edu>
From: Michael Haggerty <mhagger@alum.mit.edu>
This means that all we need to read loose references is the ref_entry that will receive them.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> --- refs.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/refs.c b/refs.c index 0f5aab2..4eca965 100644 --- a/refs.c +++ b/refs.c @@ -791,7 +791,7 @@ void add_packed_ref(const char *refname, const unsigned char *sha1) /* * Read the loose references for direntry in refs. */ -static void read_loose_refs(struct ref_cache *refs, struct ref_entry *direntry) +static void read_loose_refs(struct ref_entry *direntry) { DIR *d; const char *path; @@ -799,9 +799,11 @@ static void read_loose_refs(struct ref_cache *refs, struct ref_entry *direntry) const char *dirname = direntry->name; int dirnamelen = strlen(dirname); struct strbuf refname; + struct ref_cache *refs; assert(direntry->flag & REF_DIR); + refs = direntry->u.subdir.ref_cache; if (*refs->name) path = git_path_submodule(refs->name, "%s", dirname); else @@ -832,8 +834,7 @@ static void read_loose_refs(struct ref_cache *refs, struct ref_entry *direntry) /* Silently ignore. */ } else if (S_ISDIR(st.st_mode)) { strbuf_addch(&refname, '/'); - read_loose_refs(refs, - search_for_subdir(direntry, + read_loose_refs(search_for_subdir(direntry, refname.buf, 1)); } else { if (*refs->name) { @@ -860,8 +861,7 @@ static struct ref_entry *get_loose_refs(struct ref_cache *refs) { if (!refs->loose) { refs->loose = create_dir_entry(refs, ""); - read_loose_refs(refs, - search_for_subdir(refs->loose, "refs/", 1)); + read_loose_refs(search_for_subdir(refs->loose, "refs/", 1)); } return refs->loose; }
-- 1.7.10