diff options
Diffstat (limited to 'tests/pack')
| -rw-r--r-- | tests/pack/filelimit.c | 18 | ||||
| -rw-r--r-- | tests/pack/indexer.c | 26 | ||||
| -rw-r--r-- | tests/pack/midx.c | 51 | ||||
| -rw-r--r-- | tests/pack/packbuilder.c | 10 |
4 files changed, 53 insertions, 52 deletions
diff --git a/tests/pack/filelimit.c b/tests/pack/filelimit.c index 5e0b77e9b..2b7bf6e95 100644 --- a/tests/pack/filelimit.c +++ b/tests/pack/filelimit.c @@ -34,12 +34,12 @@ void test_pack_filelimit__initialize_unlimited(void) void test_pack_filelimit__cleanup(void) { - git_buf path = GIT_BUF_INIT; + git_str path = GIT_STR_INIT; cl_git_pass(git_libgit2_opts(GIT_OPT_SET_MWINDOW_FILE_LIMIT, original_mwindow_file_limit)); - cl_git_pass(git_buf_joinpath(&path, clar_sandbox_path(), "repo.git")); + cl_git_pass(git_str_joinpath(&path, clar_sandbox_path(), "repo.git")); cl_fixture_cleanup(path.ptr); - git_buf_dispose(&path); + git_str_dispose(&path); } /* @@ -54,7 +54,7 @@ void create_packfile_commit( size_t commit_index, size_t commit_count) { - git_buf file_contents = GIT_BUF_INIT; + git_str file_contents = GIT_STR_INIT; git_treebuilder *treebuilder; git_packbuilder *packbuilder; git_signature *s; @@ -67,7 +67,7 @@ void create_packfile_commit( cl_git_pass(git_blob_create_from_buffer(&oid, repo, "", 0)); cl_git_pass(git_treebuilder_insert(NULL, treebuilder, "README.md", &oid, 0100644)); - cl_git_pass(git_buf_printf(&file_contents, "Commit %zd/%zd", commit_index, commit_count)); + cl_git_pass(git_str_printf(&file_contents, "Commit %zd/%zd", commit_index, commit_count)); cl_git_pass(git_blob_create_from_buffer(&oid, repo, file_contents.ptr, file_contents.size)); cl_git_pass(git_treebuilder_insert(NULL, treebuilder, "file.txt", &oid, 0100644)); @@ -82,7 +82,7 @@ void create_packfile_commit( cl_git_pass(git_oid_cpy(out_commit_id, &commit_id)); - git_buf_dispose(&file_contents); + git_str_dispose(&file_contents); git_treebuilder_free(treebuilder); git_packbuilder_free(packbuilder); git_signature_free(s); @@ -90,7 +90,7 @@ void create_packfile_commit( void test_pack_filelimit__open_repo_with_multiple_packfiles(void) { - git_buf path = GIT_BUF_INIT; + git_str path = GIT_STR_INIT; git_mwindow_ctl *ctl = &git_mwindow__mem_ctl; git_repository *repo; git_revwalk *walk; @@ -103,7 +103,7 @@ void test_pack_filelimit__open_repo_with_multiple_packfiles(void) * Create a repository and populate it with 16 commits, each in its own * packfile. */ - cl_git_pass(git_buf_joinpath(&path, clar_sandbox_path(), "repo.git")); + cl_git_pass(git_str_joinpath(&path, clar_sandbox_path(), "repo.git")); cl_git_pass(git_repository_init(&repo, path.ptr, true)); for (i = 0; i < commit_count; ++i) { create_packfile_commit(repo, &id, parent_id, i + 1, commit_count); @@ -130,7 +130,7 @@ void test_pack_filelimit__open_repo_with_multiple_packfiles(void) cl_assert_equal_i(expected_open_mwindow_files, open_windows); - git_buf_dispose(&path); + git_str_dispose(&path); git_revwalk_free(walk); git_repository_free(repo); } diff --git a/tests/pack/indexer.c b/tests/pack/indexer.c index 422c3def4..5958bc4ba 100644 --- a/tests/pack/indexer.c +++ b/tests/pack/indexer.c @@ -279,10 +279,10 @@ void test_pack_indexer__out_of_order_with_connectivity_checks(void) git_indexer_free(idx); } -static int find_tmp_file_recurs(void *opaque, git_buf *path) +static int find_tmp_file_recurs(void *opaque, git_str *path) { int error = 0; - git_buf *first_tmp_file = opaque; + git_str *first_tmp_file = opaque; struct stat st; if ((error = p_lstat_posixly(path->ptr, &st)) < 0) @@ -292,8 +292,8 @@ static int find_tmp_file_recurs(void *opaque, git_buf *path) return git_path_direach(path, 0, find_tmp_file_recurs, opaque); /* This is the template that's used in git_futils_mktmp. */ - if (strstr(git_buf_cstr(path), "_git2_") != NULL) - return git_buf_sets(first_tmp_file, git_buf_cstr(path)); + if (strstr(git_str_cstr(path), "_git2_") != NULL) + return git_str_sets(first_tmp_file, git_str_cstr(path)); return 0; } @@ -301,21 +301,21 @@ static int find_tmp_file_recurs(void *opaque, git_buf *path) void test_pack_indexer__no_tmp_files(void) { git_indexer *idx = NULL; - git_buf path = GIT_BUF_INIT; - git_buf first_tmp_file = GIT_BUF_INIT; + git_str path = GIT_STR_INIT; + git_str first_tmp_file = GIT_STR_INIT; /* Precondition: there are no temporary files. */ - cl_git_pass(git_buf_sets(&path, clar_sandbox_path())); + cl_git_pass(git_str_sets(&path, clar_sandbox_path())); cl_git_pass(find_tmp_file_recurs(&first_tmp_file, &path)); - git_buf_dispose(&path); - cl_assert(git_buf_len(&first_tmp_file) == 0); + git_str_dispose(&path); + cl_assert(git_str_len(&first_tmp_file) == 0); cl_git_pass(git_indexer_new(&idx, ".", 0, NULL, NULL)); git_indexer_free(idx); - cl_git_pass(git_buf_sets(&path, clar_sandbox_path())); + cl_git_pass(git_str_sets(&path, clar_sandbox_path())); cl_git_pass(find_tmp_file_recurs(&first_tmp_file, &path)); - git_buf_dispose(&path); - cl_assert(git_buf_len(&first_tmp_file) == 0); - git_buf_dispose(&first_tmp_file); + git_str_dispose(&path); + cl_assert(git_str_len(&first_tmp_file) == 0); + git_str_dispose(&first_tmp_file); } diff --git a/tests/pack/midx.c b/tests/pack/midx.c index d5b91d28b..9dd949363 100644 --- a/tests/pack/midx.c +++ b/tests/pack/midx.c @@ -12,12 +12,12 @@ void test_pack_midx__parse(void) struct git_midx_file *idx; struct git_midx_entry e; git_oid id; - git_buf midx_path = GIT_BUF_INIT; + git_str midx_path = GIT_STR_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_assert_equal_i(git_midx_needs_refresh(idx, git_buf_cstr(&midx_path)), 0); + cl_git_pass(git_str_joinpath(&midx_path, git_repository_path(repo), "objects/pack/multi-pack-index")); + cl_git_pass(git_midx_open(&idx, git_str_cstr(&midx_path))); + cl_assert_equal_i(git_midx_needs_refresh(idx, git_str_cstr(&midx_path)), 0); cl_git_pass(git_oid_fromstr(&id, "5001298e0c09ad9c34e4249bc5801c75e9754fa5")); cl_git_pass(git_midx_entry_find(&e, idx, &id, GIT_OID_HEXSZ)); @@ -28,7 +28,7 @@ void test_pack_midx__parse(void) git_midx_free(idx); git_repository_free(repo); - git_buf_dispose(&midx_path); + git_str_dispose(&midx_path); } void test_pack_midx__lookup(void) @@ -51,27 +51,28 @@ void test_pack_midx__writer(void) { git_repository *repo; git_midx_writer *w = NULL; - git_buf midx = GIT_BUF_INIT, expected_midx = GIT_BUF_INIT, path = GIT_BUF_INIT; + git_buf midx = GIT_BUF_INIT; + git_str expected_midx = GIT_STR_INIT, path = GIT_STR_INIT; cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git"))); - cl_git_pass(git_buf_joinpath(&path, git_repository_path(repo), "objects/pack")); - cl_git_pass(git_midx_writer_new(&w, git_buf_cstr(&path))); + cl_git_pass(git_str_joinpath(&path, git_repository_path(repo), "objects/pack")); + cl_git_pass(git_midx_writer_new(&w, git_str_cstr(&path))); cl_git_pass(git_midx_writer_add(w, "pack-d7c6adf9f61318f041845b01440d09aa7a91e1b5.idx")); cl_git_pass(git_midx_writer_add(w, "pack-d85f5d483273108c9d8dd0e4728ccf0b2982423a.idx")); cl_git_pass(git_midx_writer_add(w, "pack-a81e489679b7d3418f9ab594bda8ceb37dd4c695.idx")); cl_git_pass(git_midx_writer_dump(&midx, w)); - cl_git_pass(git_buf_joinpath(&path, git_repository_path(repo), "objects/pack/multi-pack-index")); - cl_git_pass(git_futils_readbuffer(&expected_midx, git_buf_cstr(&path))); + cl_git_pass(git_str_joinpath(&path, git_repository_path(repo), "objects/pack/multi-pack-index")); + cl_git_pass(git_futils_readbuffer(&expected_midx, git_str_cstr(&path))); - cl_assert_equal_i(git_buf_len(&midx), git_buf_len(&expected_midx)); - cl_assert_equal_strn(git_buf_cstr(&midx), git_buf_cstr(&expected_midx), git_buf_len(&midx)); + cl_assert_equal_i(midx.size, git_str_len(&expected_midx)); + cl_assert_equal_strn(midx.ptr, git_str_cstr(&expected_midx), midx.size); git_buf_dispose(&midx); - git_buf_dispose(&expected_midx); - git_buf_dispose(&path); + git_str_dispose(&expected_midx); + git_str_dispose(&path); git_midx_writer_free(w); git_repository_free(repo); } @@ -81,30 +82,30 @@ void test_pack_midx__odb_create(void) git_repository *repo; git_odb *odb; git_clone_options opts = GIT_CLONE_OPTIONS_INIT; - git_buf midx = GIT_BUF_INIT, expected_midx = GIT_BUF_INIT, midx_path = GIT_BUF_INIT; + git_str midx = GIT_STR_INIT, expected_midx = GIT_STR_INIT, midx_path = GIT_STR_INIT; struct stat st; opts.bare = true; opts.local = GIT_CLONE_LOCAL; cl_git_pass(git_clone(&repo, cl_fixture("testrepo/.gitted"), "./clone.git", &opts)); - cl_git_pass(git_buf_joinpath(&midx_path, git_repository_path(repo), "objects/pack/multi-pack-index")); - cl_git_fail(p_stat(git_buf_cstr(&midx_path), &st)); + cl_git_pass(git_str_joinpath(&midx_path, git_repository_path(repo), "objects/pack/multi-pack-index")); + cl_git_fail(p_stat(git_str_cstr(&midx_path), &st)); cl_git_pass(git_repository_odb(&odb, repo)); cl_git_pass(git_odb_write_multi_pack_index(odb)); git_odb_free(odb); - cl_git_pass(p_stat(git_buf_cstr(&midx_path), &st)); + cl_git_pass(p_stat(git_str_cstr(&midx_path), &st)); cl_git_pass(git_futils_readbuffer(&expected_midx, cl_fixture("testrepo.git/objects/pack/multi-pack-index"))); - cl_git_pass(git_futils_readbuffer(&midx, git_buf_cstr(&midx_path))); - cl_assert_equal_i(git_buf_len(&midx), git_buf_len(&expected_midx)); - cl_assert_equal_strn(git_buf_cstr(&midx), git_buf_cstr(&expected_midx), git_buf_len(&midx)); + cl_git_pass(git_futils_readbuffer(&midx, git_str_cstr(&midx_path))); + cl_assert_equal_i(git_str_len(&midx), git_str_len(&expected_midx)); + cl_assert_equal_strn(git_str_cstr(&midx), git_str_cstr(&expected_midx), git_str_len(&midx)); git_repository_free(repo); - git_buf_dispose(&midx); - git_buf_dispose(&midx_path); - git_buf_dispose(&expected_midx); + git_str_dispose(&midx); + git_str_dispose(&midx_path); + git_str_dispose(&expected_midx); cl_git_pass(git_futils_rmdir_r("./clone.git", NULL, GIT_RMDIR_REMOVE_FILES)); -}
\ No newline at end of file +} diff --git a/tests/pack/packbuilder.c b/tests/pack/packbuilder.c index 5d93ede06..b4c655c5e 100644 --- a/tests/pack/packbuilder.c +++ b/tests/pack/packbuilder.c @@ -96,7 +96,7 @@ static int feed_indexer(void *ptr, size_t len, void *payload) void test_pack_packbuilder__create_pack(void) { git_indexer_progress stats; - git_buf buf = GIT_BUF_INIT, path = GIT_BUF_INIT; + git_str buf = GIT_STR_INIT, path = GIT_STR_INIT; git_hash_ctx ctx; git_oid hash; char hex[GIT_OID_HEXSZ+1]; hex[GIT_OID_HEXSZ] = '\0'; @@ -108,7 +108,7 @@ void test_pack_packbuilder__create_pack(void) cl_git_pass(git_indexer_commit(_indexer, &stats)); git_oid_fmt(hex, git_indexer_hash(_indexer)); - git_buf_printf(&path, "pack-%s.pack", hex); + git_str_printf(&path, "pack-%s.pack", hex); /* * By default, packfiles are created with only one thread. @@ -124,15 +124,15 @@ void test_pack_packbuilder__create_pack(void) * */ - cl_git_pass(git_futils_readbuffer(&buf, git_buf_cstr(&path))); + cl_git_pass(git_futils_readbuffer(&buf, git_str_cstr(&path))); cl_git_pass(git_hash_ctx_init(&ctx, GIT_HASH_ALGORITHM_SHA1)); cl_git_pass(git_hash_update(&ctx, buf.ptr, buf.size)); cl_git_pass(git_hash_final(hash.id, &ctx)); git_hash_ctx_cleanup(&ctx); - git_buf_dispose(&path); - git_buf_dispose(&buf); + git_str_dispose(&path); + git_str_dispose(&buf); git_oid_fmt(hex, &hash); |
