search_for_subdir(): return (ref_dir *) instead of (ref_entry *)

That is what all the callers want, so give it to them. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed Apr 27, 2012 at 00:27 UTC 3f3aa1bc6215fad0d31d1eae5f4c599c6847a02f
1 file changed +10 -11
refs.c
+10 -11
@@ -289,8 +289,8 @@ static struct ref_entry *search_ref_dir(struct ref_dir *dir, const char *refname
289 * directory if it is missing; otherwise, return NULL if the desired
290 * directory cannot be found.
291 */
292 -static struct ref_entry *search_for_subdir(struct ref_dir *dir,
293 - const char *subdirname, int mkdir)
292 +static struct ref_dir *search_for_subdir(struct ref_dir *dir,
293 + const char *subdirname, int mkdir)
294 {
295 struct ref_entry *entry = search_ref_dir(dir, subdirname);
296 if (!entry) {
@@ -299,8 +299,7 @@ static struct ref_entry *search_for_subdir(struct ref_dir *dir,
299 entry = create_dir_entry(subdirname);
300 add_entry_to_dir(dir, entry);
301 }
302 - assert(entry->flag & REF_DIR);
303 - return entry;
302 + return get_ref_dir(entry);
303 }
304
305 /*
@@ -319,14 +318,14 @@ static struct ref_dir *find_containing_dir(struct ref_dir *dir,
318 const char *slash;
319 strbuf_init(&dirname, PATH_MAX);
320 for (slash = strchr(refname, '/'); slash; slash = strchr(slash + 1, '/')) {
322 - struct ref_entry *entry;
321 + struct ref_dir *subdir;
322 strbuf_add(&dirname,
323 refname + dirname.len,
324 (slash + 1) - (refname + dirname.len));
326 - entry = search_for_subdir(dir, dirname.buf, mkdir);
327 - if (!entry)
325 + subdir = search_for_subdir(dir, dirname.buf, mkdir);
326 + if (!subdir)
327 break;
329 - dir = get_ref_dir(entry);
328 + dir = subdir;
329 }
330
331 strbuf_release(&dirname);
@@ -819,7 +818,7 @@ static void read_loose_refs(struct ref_cache *refs, const char *dirname,
818 } else if (S_ISDIR(st.st_mode)) {
819 strbuf_addch(&refname, '/');
820 read_loose_refs(refs, refname.buf,
822 - get_ref_dir(search_for_subdir(dir, refname.buf, 1)));
821 + search_for_subdir(dir, refname.buf, 1));
822 } else {
823 if (*refs->name) {
824 hashclr(sha1);
@@ -846,8 +845,8 @@ static struct ref_dir *get_loose_refs(struct ref_cache *refs)
845 if (!refs->loose) {
846 refs->loose = create_dir_entry("");
847 read_loose_refs(refs, "refs/",
849 - get_ref_dir(search_for_subdir(get_ref_dir(refs->loose),
850 - "refs/", 1)));
848 + search_for_subdir(get_ref_dir(refs->loose),
849 + "refs/", 1));
850 }
851 return get_ref_dir(refs->loose);
852 }