[PATCH 23/30] do_for_each_ref_in_dirs(): take (ref_entry *) instead of (ref_dir *)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Michael Haggerty <mhagger@xxxxxxxxxxxx>


Signed-off-by: Michael Haggerty <mhagger@xxxxxxxxxxxx>
---
 refs.c |   48 +++++++++++++++++++++++++-----------------------
 1 file changed, 25 insertions(+), 23 deletions(-)

diff --git a/refs.c b/refs.c
index a794d3a..4448b14 100644
--- a/refs.c
+++ b/refs.c
@@ -468,35 +468,38 @@ static int do_for_each_ref_in_dir(struct ref_dir *dir, int offset,
 }
 
 /*
- * Call fn for each reference in the union of dir1 and dir2, in order
- * by refname.  Recurse into subdirectories.  If a value entry appears
- * in both dir1 and dir2, then only process the version that is in
- * dir2.  The input dirs must already be sorted, but subdirs will be
- * sorted as needed.
+ * Call fn for each reference in the union of direntry1 and direntry2,
+ * in order by refname.  Recurse into subdirectories.  If a value
+ * entry appears in both direntry1 and direntry2, then only process
+ * the version that is in direntry2.  The input direntries must
+ * already be sorted, but subdirs will be sorted as needed.
  */
-static int do_for_each_ref_in_dirs(struct ref_dir *dir1,
-				   struct ref_dir *dir2,
+static int do_for_each_ref_in_dirs(struct ref_entry *direntry1,
+				   struct ref_entry *direntry2,
 				   const char *base, each_ref_fn fn, int trim,
 				   int flags, void *cb_data)
 {
 	int retval;
 	int i1 = 0, i2 = 0;
 
-	assert(dir1->sorted == dir1->nr);
-	assert(dir2->sorted == dir2->nr);
+	assert(direntry1->flag & REF_DIR);
+	assert(direntry2->flag & REF_DIR);
+	assert(direntry1->u.subdir.sorted == direntry1->u.subdir.nr);
+	assert(direntry2->u.subdir.sorted == direntry2->u.subdir.nr);
+
 	while (1) {
 		struct ref_entry *e1, *e2;
 		int cmp;
-		if (i1 == dir1->nr) {
-			return do_for_each_ref_in_dir(dir2, i2,
+		if (i1 == direntry1->u.subdir.nr) {
+			return do_for_each_ref_in_dir(&direntry2->u.subdir, i2,
 						      base, fn, trim, flags, cb_data);
 		}
-		if (i2 == dir2->nr) {
-			return do_for_each_ref_in_dir(dir1, i1,
+		if (i2 == direntry2->u.subdir.nr) {
+			return do_for_each_ref_in_dir(&direntry1->u.subdir, i1,
 						      base, fn, trim, flags, cb_data);
 		}
-		e1 = dir1->entries[i1];
-		e2 = dir2->entries[i2];
+		e1 = direntry1->u.subdir.entries[i1];
+		e2 = direntry2->u.subdir.entries[i2];
 		cmp = strcmp(e1->name, e2->name);
 		if (cmp == 0) {
 			if ((e1->flag & REF_DIR) && (e2->flag & REF_DIR)) {
@@ -504,12 +507,12 @@ static int do_for_each_ref_in_dirs(struct ref_dir *dir1,
 				sort_ref_dir(&e1->u.subdir);
 				sort_ref_dir(&e2->u.subdir);
 				retval = do_for_each_ref_in_dirs(
-						&e1->u.subdir, &e2->u.subdir,
+						e1, e2,
 						base, fn, trim, flags, cb_data);
 				i1++;
 				i2++;
 			} else if (!(e1->flag & REF_DIR) && !(e2->flag & REF_DIR)) {
-				/* Both are references; ignore the one from dir1. */
+				/* Both are references; ignore the one from direntry1. */
 				retval = do_one_ref(base, fn, trim, flags, cb_data, e2);
 				i1++;
 				i2++;
@@ -538,11 +541,11 @@ static int do_for_each_ref_in_dirs(struct ref_dir *dir1,
 		if (retval)
 			return retval;
 	}
-	if (i1 < dir1->nr)
-		return do_for_each_ref_in_dir(dir1, i1,
+	if (i1 < direntry1->u.subdir.nr)
+		return do_for_each_ref_in_dir(&direntry1->u.subdir, i1,
 					      base, fn, trim, flags, cb_data);
-	if (i2 < dir2->nr)
-		return do_for_each_ref_in_dir(dir2, i2,
+	if (i2 < direntry2->u.subdir.nr)
+		return do_for_each_ref_in_dir(&direntry2->u.subdir, i2,
 					      base, fn, trim, flags, cb_data);
 	return 0;
 }
@@ -1186,8 +1189,7 @@ static int do_for_each_ref(const char *submodule, const char *base, each_ref_fn
 		sort_ref_dir(&packed_direntry->u.subdir);
 		sort_ref_dir(&loose_direntry->u.subdir);
 		retval = do_for_each_ref_in_dirs(
-				&packed_direntry->u.subdir,
-				&loose_direntry->u.subdir,
+				packed_direntry, loose_direntry,
 				base, fn, trim, flags, cb_data);
 	} else if (packed_direntry) {
 		sort_ref_dir(&packed_direntry->u.subdir);
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]