[PATCH v2 40/51] 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 | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/refs.c b/refs.c
index 0d8fdf0..439545b 100644
--- a/refs.c
+++ b/refs.c
@@ -338,9 +338,11 @@ static struct ref_entry *find_ref(struct ref_entry *direntry, const char *refnam
* subdirectories as necessary. dir 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);
@@ -693,7 +695,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 &&
@@ -709,7 +711,7 @@ void add_extra_ref(const char *refname, const unsigned char *sha1, int flag)
{
if (!extra_refs)
extra_refs = create_dir_entry("");
- add_ref(&extra_refs->u.subdir, create_ref_entry(refname, sha1, flag, 0));
+ add_ref(extra_refs, create_ref_entry(refname, sha1, flag, 0));
}
void clear_extra_refs(void)
--
1.7.8