Commit 63de41366136877da3e3da97069a20bd177f0d3a

Stefan Sperling 2019-01-28T23:51:52

turns out in_same_subdir() check is mostly redundant

diff --git a/lib/fileindex.c b/lib/fileindex.c
index ae241b0..54dd0e8 100644
--- a/lib/fileindex.c
+++ b/lib/fileindex.c
@@ -547,14 +547,6 @@ got_fileindex_read(struct got_fileindex *fileindex, FILE *infile)
 	return NULL;
 }
 
-static int
-in_same_subdir(struct got_fileindex_entry *ie, const char *ie_name,
-    const char *parent_path, size_t parent_len)
-{
-	return (got_path_is_child(ie->path, parent_path, parent_len) &&
-	    strchr(ie_name, '/') == NULL);
-}
-
 /*
  * Decide whether ie or te are equivalent, and if they aren't,
  * then decide which should be processed first.
@@ -564,11 +556,12 @@ 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);
-	char *ie_name = ie->path + parent_len;
-	while (ie_name[0] == '/')
-		ie_name++;
-	if (cmp == 0 || in_same_subdir(ie, ie_name, 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;
 
 }