Commit 70e2377c0226613312687962277bc22835bbf250

Stefan Sperling 2019-01-28T23:54:46

move definition of cmp_entries() closer to point of use

diff --git a/lib/fileindex.c b/lib/fileindex.c
index 54dd0e8..0116d68 100644
--- a/lib/fileindex.c
+++ b/lib/fileindex.c
@@ -547,25 +547,6 @@ got_fileindex_read(struct got_fileindex *fileindex, FILE *infile)
 	return NULL;
 }
 
-/*
- * Decide whether ie or te are equivalent, and if they aren't,
- * then decide which should be processed first.
- */
-static int
-cmp_entries(struct got_fileindex_entry *ie, const char *parent_path,
-    size_t parent_len, struct got_tree_entry *te)
-{
-	int cmp = strncmp(ie->path, parent_path, parent_len);
-	if (cmp == 0 || parent_len == 0) {
-		char *ie_name = ie->path + parent_len;
-		while (ie_name[0] == '/')
-			ie_name++;
-		cmp = strcmp(ie_name, te->name);
-	}
-	return cmp;
-
-}
-
 static const struct got_error *
 diff_fileindex_tree(struct got_fileindex *, struct got_fileindex_entry **,
     struct got_tree_object *, const char *, struct got_repository *,
@@ -619,6 +600,25 @@ walk_tree(struct got_tree_entry **next, struct got_fileindex *fileindex,
 	return NULL;
 }
 
+/*
+ * Decide whether ie or te are equivalent, and if they aren't,
+ * then decide which should be processed first.
+ */
+static int
+cmp_entries(struct got_fileindex_entry *ie, const char *parent_path,
+    size_t parent_len, struct got_tree_entry *te)
+{
+	int cmp = strncmp(ie->path, parent_path, parent_len);
+	if (cmp == 0 || parent_len == 0) {
+		char *ie_name = ie->path + parent_len;
+		while (ie_name[0] == '/')
+			ie_name++;
+		cmp = strcmp(ie_name, te->name);
+	}
+	return cmp;
+
+}
+
 static const struct got_error *
 diff_fileindex_tree(struct got_fileindex *fileindex,
     struct got_fileindex_entry **ie, struct got_tree_object *tree,