[PATCH 16/30] add_ref(): take (ref_entry *) instead of (ref_dir *)
From: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
refs.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/refs.c b/refs.c
index 694d802..6077cfb 100644
--- a/refs.c
+++ b/refs.c
@@ -345,13 +345,15 @@ static struct ref_entry *find_ref(struct ref_entry *direntry, const char *refnam
}
/*
- * Add a ref_entry to the ref_dir (unsorted), recursing into
- * subdirectories as necessary. dir must represent the top-level
- * directory. Return 0 on success.
+ * Add ref to the direntry (unsorted), recursing into subdirectories
+ * as necessary. direntry must represent the top-level directory.
+ * Return 0 on success.
*/
-static int add_ref(struct ref_dir *dir, struct ref_entry *ref)
+static int add_ref(struct ref_entry *direntry, struct ref_entry *ref)
{
- dir = find_containing_dir(dir, ref->name, 1);
+ struct ref_dir *dir;
+ assert(direntry->flag & REF_DIR);
+ dir = find_containing_dir(&direntry->u.subdir, ref->name, 1);
if (!dir)
return -1;
add_entry_to_dir(dir, ref);
@@ -731,7 +733,7 @@ static void read_packed_refs(FILE *f, struct ref_entry *direntry)
refname = parse_ref_line(refline, sha1);
if (refname) {
last = create_ref_entry(refname, sha1, flag, 1);
- add_ref(&direntry->u.subdir, last);
+ add_ref(direntry, last);
continue;
}
if (last &&
@@ -765,7 +767,7 @@ static struct ref_entry *get_packed_refs(struct ref_cache *refs)
void add_packed_ref(const char *refname, const unsigned char *sha1)
{
- add_ref(&get_packed_refs(get_ref_cache(NULL))->u.subdir,
+ add_ref(get_packed_refs(get_ref_cache(NULL)),
create_ref_entry(refname, sha1, REF_ISPACKED, 1));
}
--
1.7.10