Commit 52d1d0d9000cbe48a58be36218471edd0965e42c

Stefan Sperling 2019-07-07T18:07:51

fix bug where match_loose_object() skipped some objects

diff --git a/lib/repository.c b/lib/repository.c
index db26cff..42b69ef 100644
--- a/lib/repository.c
+++ b/lib/repository.c
@@ -1005,13 +1005,14 @@ match_loose_object(struct got_object_id **unique_id, const char *path_objects,
 		if (!got_parse_sha1_digest(id.sha1, id_str))
 			continue;
 
+		/*
+		 * Directory entries do not necessarily appear in
+		 * sorted order, so we must iterate over all of them.
+		 */
 		cmp = strncmp(id_str, id_str_prefix, strlen(id_str_prefix));
-		if (cmp < 0) {
+		if (cmp != 0) {
 			free(id_str);
 			continue;
-		} else if (cmp > 0) {
-			free(id_str);
-			break;
 		}
 
 		if (*unique_id == NULL) {