Commit Diff


commit - 51c68690d59d65748712cc9a7e2dfc9bffd8fe23
commit + 63da309a4f2c5978e3fe9ec99266313333116218
blob - 2100b9659fd0c6f802370276d8c1dbd456b205ae
blob + abcc58ce90a553a46ea4f2b1e67cd05d0477a72a
--- lib/object.c
+++ lib/object.c
@@ -707,8 +707,14 @@ find_entry_by_name(struct got_tree_object *tree, const
 {
 	struct got_tree_entry *te;
 
+	/* Note that tree entries are sorted in strncmp() order. */
 	SIMPLEQ_FOREACH(te, &tree->entries.head, entry) {
-		if (strncmp(te->name, name, len) == 0 && te->name[len] == '\0')
+		int cmp = strncmp(te->name, name, len);
+		if (cmp < 0)
+			continue;
+		if (cmp > 0)
+			break;
+		if (te->name[len] == '\0')
 			return te;
 	}
 	return NULL;