Thread (32 messages) flat view 32 messages, 1 author, 2016-06-15
STALE3741d

Revision v1 of 2 in this series.

Revisions (2)
  1. v1 current
  2. v2 [diff vs current]

[PATCH 16/30] add_ref(): take (ref_entry *) instead of (ref_dir *)

From: <hidden>
Date: 2016-06-15 22:53:39
Subsystem: the rest · Maintainer: Linus Torvalds

From: Michael Haggerty <redacted>

Signed-off-by: Michael Haggerty <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help