summaryrefslogtreecommitdiff
path: root/tests/pack
diff options
context:
space:
mode:
authorlhchavez <lhchavez@lhchavez.com>2020-02-23 22:28:52 +0000
committerlhchavez <lhchavez@lhchavez.com>2020-10-05 05:08:38 -0700
commit005e77157d5eef9d9c0765ff201e6ec07e7f5d00 (patch)
treea65b1b054b394fca1237d5f8c001d21547ffcee1 /tests/pack
parent6d1f19269f6bdce126689535e86819f704f25d1a (diff)
downloadlibgit2-005e77157d5eef9d9c0765ff201e6ec07e7f5d00.tar.gz
multipack: Introduce a parser for multi-pack-index files
This change is the first in a series to add support for git's multi-pack-index. This should speed up large repositories significantly. Part of: #5399
Diffstat (limited to 'tests/pack')
-rw-r--r--tests/pack/midx.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/pack/midx.c b/tests/pack/midx.c
new file mode 100644
index 000000000..1f47d9502
--- /dev/null
+++ b/tests/pack/midx.c
@@ -0,0 +1,29 @@
+#include "clar_libgit2.h"
+
+#include <git2.h>
+
+#include "midx.h"
+
+void test_pack_midx__parse(void)
+{
+ git_repository *repo;
+ struct git_midx_file *idx;
+ struct git_midx_entry e;
+ git_oid id;
+ git_buf midx_path = GIT_BUF_INIT;
+
+ cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
+ cl_git_pass(git_buf_joinpath(&midx_path, git_repository_path(repo), "objects/pack/multi-pack-index"));
+ cl_git_pass(git_midx_open(&idx, git_buf_cstr(&midx_path)));
+
+ cl_git_pass(git_oid_fromstr(&id, "5001298e0c09ad9c34e4249bc5801c75e9754fa5"));
+ cl_git_pass(git_midx_entry_find(&e, idx, &id, GIT_OID_HEXSZ));
+ cl_assert_equal_oid(&e.sha1, &id);
+ cl_assert_equal_s(
+ (const char *)git_vector_get(&idx->packfile_names, e.pack_index),
+ "pack-d7c6adf9f61318f041845b01440d09aa7a91e1b5.idx");
+
+ git_midx_free(idx);
+ git_repository_free(repo);
+ git_buf_dispose(&midx_path);
+}