don't assume objects IDs are sorted by their values in packidx
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
diff --git a/lib/pack.c b/lib/pack.c
index e53d687..b00eb49 100644
--- a/lib/pack.c
+++ b/lib/pack.c
@@ -301,8 +301,6 @@ get_object_idx(struct got_packidx_v2_hdr *packidx, struct got_object_id *id)
if (cmp == 0)
return i;
- else if (cmp > 0)
- break;
i++;
}
diff --git a/regress/repository/repository_test.c b/regress/repository/repository_test.c
index 7028965..d3822a3 100644
--- a/regress/repository/repository_test.c
+++ b/regress/repository/repository_test.c
@@ -207,6 +207,37 @@ repo_read_log(const char *repo_path)
}
static int
+repo_read_tree(const char *repo_path)
+{
+ const char *tree_sha1 = "6cc96e0e093fb30630ba7f199d0a008b24c6a690";
+ const struct got_error *err;
+ struct got_repository *repo;
+ struct got_object_id id;
+ struct got_object *obj;
+ char hex[SHA1_DIGEST_STRING_LENGTH];
+ int i;
+ size_t len;
+
+ if (!got_parse_sha1_digest(id.sha1, tree_sha1))
+ return 0;
+
+ err = got_repo_open(&repo, repo_path);
+ if (err != NULL || repo == NULL)
+ return 0;
+ err = got_object_open(&obj, repo, &id);
+ if (err != NULL || obj == NULL)
+ return 0;
+ if (got_object_get_type(obj) != GOT_OBJ_TYPE_TREE)
+ return 0;
+
+ print_tree_object(obj, "", repo);
+ test_printf("\n");
+
+ got_object_close(obj);
+ got_repo_close(repo);
+ return (err == NULL);
+}
+static int
repo_read_blob(const char *repo_path)
{
const char *blob_sha1 = "141f5fdc96126c1f4195558560a3c915e3d9b4c3";
@@ -407,6 +438,7 @@ main(int argc, char *argv[])
return 1;
}
+ RUN_TEST(repo_read_tree(repo_path), "read_tree");
RUN_TEST(repo_read_log(repo_path), "read_log");
RUN_TEST(repo_read_blob(repo_path), "read_blob");
RUN_TEST(repo_diff_blob(repo_path), "diff_blob");