summaryrefslogtreecommitdiff
path: root/tests/object
diff options
context:
space:
mode:
Diffstat (limited to 'tests/object')
-rw-r--r--tests/object/blob/filter.c18
-rw-r--r--tests/object/blob/fromstream.c13
-rw-r--r--tests/object/blob/write.c17
-rw-r--r--tests/object/commit/commitstagedfile.c3
-rw-r--r--tests/object/lookup.c18
-rw-r--r--tests/object/message.c4
-rw-r--r--tests/object/raw/hash.c2
-rw-r--r--tests/object/tree/write.c6
8 files changed, 38 insertions, 43 deletions
diff --git a/tests/object/blob/filter.c b/tests/object/blob/filter.c
index a8e3d3097..00b553e71 100644
--- a/tests/object/blob/filter.c
+++ b/tests/object/blob/filter.c
@@ -24,7 +24,7 @@ static off64_t g_crlf_raw_len[CRLF_NUM_TEST_OBJECTS] = {
static git_oid g_crlf_oids[CRLF_NUM_TEST_OBJECTS];
-static git_buf g_crlf_filtered[CRLF_NUM_TEST_OBJECTS] = {
+static git_str g_crlf_filtered[CRLF_NUM_TEST_OBJECTS] = {
{ "", 0, 0 },
{ "foo\nbar\n", 0, 8 },
{ "foo\rbar\r", 0, 8 },
@@ -36,16 +36,16 @@ static git_buf g_crlf_filtered[CRLF_NUM_TEST_OBJECTS] = {
{ "\xFE\xFF\x00T\x00h\x00i\x00s\x00!", 0, 12 }
};
-static git_buf_text_stats g_crlf_filtered_stats[CRLF_NUM_TEST_OBJECTS] = {
+static git_str_text_stats g_crlf_filtered_stats[CRLF_NUM_TEST_OBJECTS] = {
{ 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 2, 0, 6, 0 },
{ 0, 0, 2, 0, 0, 6, 0 },
{ 0, 0, 2, 2, 2, 6, 0 },
{ 0, 0, 4, 4, 1, 31, 0 },
{ 0, 1, 1, 2, 1, 9, 5 },
- { GIT_BUF_BOM_UTF8, 0, 0, 1, 0, 16, 0 },
- { GIT_BUF_BOM_UTF8, 0, 2, 2, 2, 27, 0 },
- { GIT_BUF_BOM_UTF16_BE, 5, 0, 0, 0, 7, 5 },
+ { GIT_STR_BOM_UTF8, 0, 0, 1, 0, 16, 0 },
+ { GIT_STR_BOM_UTF8, 0, 2, 2, 2, 27, 0 },
+ { GIT_STR_BOM_UTF16_BE, 5, 0, 0, 0, 7, 5 },
};
void test_object_blob_filter__initialize(void)
@@ -90,19 +90,19 @@ void test_object_blob_filter__stats(void)
{
int i;
git_blob *blob;
- git_buf buf = GIT_BUF_INIT;
- git_buf_text_stats stats;
+ git_str buf = GIT_STR_INIT;
+ git_str_text_stats stats;
for (i = 0; i < CRLF_NUM_TEST_OBJECTS; i++) {
cl_git_pass(git_blob_lookup(&blob, g_repo, &g_crlf_oids[i]));
cl_git_pass(git_blob__getbuf(&buf, blob));
- git_buf_gather_text_stats(&stats, &buf, false);
+ git_str_gather_text_stats(&stats, &buf, false);
cl_assert_equal_i(
0, memcmp(&g_crlf_filtered_stats[i], &stats, sizeof(stats)));
git_blob_free(blob);
}
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
void test_object_blob_filter__to_odb(void)
diff --git a/tests/object/blob/fromstream.c b/tests/object/blob/fromstream.c
index df229f98f..60ff3991b 100644
--- a/tests/object/blob/fromstream.c
+++ b/tests/object/blob/fromstream.c
@@ -1,5 +1,4 @@
#include "clar_libgit2.h"
-#include "buffer.h"
#include "posix.h"
#include "path.h"
#include "futils.h"
@@ -48,15 +47,15 @@ void test_object_blob_fromstream__multiple_write(void)
static void write_attributes(git_repository *repo)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
- cl_git_pass(git_buf_joinpath(&buf, git_repository_path(repo), "info"));
- cl_git_pass(git_buf_joinpath(&buf, git_buf_cstr(&buf), "attributes"));
+ cl_git_pass(git_str_joinpath(&buf, git_repository_path(repo), "info"));
+ cl_git_pass(git_str_joinpath(&buf, git_str_cstr(&buf), "attributes"));
- cl_git_pass(git_futils_mkpath2file(git_buf_cstr(&buf), 0777));
- cl_git_rewritefile(git_buf_cstr(&buf), GITATTR);
+ cl_git_pass(git_futils_mkpath2file(git_str_cstr(&buf), 0777));
+ cl_git_rewritefile(git_str_cstr(&buf), GITATTR);
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
}
static void assert_named_chunked_blob(const char *expected_sha, const char *fake_name)
diff --git a/tests/object/blob/write.c b/tests/object/blob/write.c
index 9a18d7cd4..802467498 100644
--- a/tests/object/blob/write.c
+++ b/tests/object/blob/write.c
@@ -1,5 +1,4 @@
#include "clar_libgit2.h"
-#include "buffer.h"
#include "posix.h"
#include "path.h"
#include "futils.h"
@@ -38,32 +37,32 @@ void test_object_blob_write__can_create_a_blob_in_a_standard_repo_from_a_file_lo
void test_object_blob_write__can_create_a_blob_in_a_standard_repo_from_a_absolute_filepath_pointing_outside_of_the_working_directory(void)
{
- git_buf full_path = GIT_BUF_INIT;
+ git_str full_path = GIT_STR_INIT;
repo = cl_git_sandbox_init(WORKDIR);
cl_must_pass(p_mkdir(ELSEWHERE, 0777));
cl_must_pass(git_path_prettify_dir(&full_path, ELSEWHERE, NULL));
- cl_must_pass(git_buf_puts(&full_path, "test.txt"));
+ cl_must_pass(git_str_puts(&full_path, "test.txt"));
- assert_blob_creation(ELSEWHERE "/test.txt", git_buf_cstr(&full_path), &git_blob_create_from_disk);
+ assert_blob_creation(ELSEWHERE "/test.txt", git_str_cstr(&full_path), &git_blob_create_from_disk);
- git_buf_dispose(&full_path);
+ git_str_dispose(&full_path);
cl_must_pass(git_futils_rmdir_r(ELSEWHERE, NULL, GIT_RMDIR_REMOVE_FILES));
}
void test_object_blob_write__can_create_a_blob_in_a_bare_repo_from_a_absolute_filepath(void)
{
- git_buf full_path = GIT_BUF_INIT;
+ git_str full_path = GIT_STR_INIT;
repo = cl_git_sandbox_init(BARE_REPO);
cl_must_pass(p_mkdir(ELSEWHERE, 0777));
cl_must_pass(git_path_prettify_dir(&full_path, ELSEWHERE, NULL));
- cl_must_pass(git_buf_puts(&full_path, "test.txt"));
+ cl_must_pass(git_str_puts(&full_path, "test.txt"));
- assert_blob_creation(ELSEWHERE "/test.txt", git_buf_cstr(&full_path), &git_blob_create_from_disk);
+ assert_blob_creation(ELSEWHERE "/test.txt", git_str_cstr(&full_path), &git_blob_create_from_disk);
- git_buf_dispose(&full_path);
+ git_str_dispose(&full_path);
cl_must_pass(git_futils_rmdir_r(ELSEWHERE, NULL, GIT_RMDIR_REMOVE_FILES));
}
diff --git a/tests/object/commit/commitstagedfile.c b/tests/object/commit/commitstagedfile.c
index f7ff05c01..7322a4e86 100644
--- a/tests/object/commit/commitstagedfile.c
+++ b/tests/object/commit/commitstagedfile.c
@@ -25,7 +25,7 @@ void test_object_commit_commitstagedfile__generate_predictable_object_ids(void)
git_oid expected_blob_oid, tree_oid, expected_tree_oid, commit_oid, expected_commit_oid;
git_signature *signature;
git_tree *tree;
- git_buf buffer;
+ git_buf buffer = GIT_BUF_INIT;
/*
* The test below replicates the following git scenario
@@ -111,7 +111,6 @@ void test_object_commit_commitstagedfile__generate_predictable_object_ids(void)
cl_git_pass(git_signature_new(&signature, "nulltoken", "emeric.fermas@gmail.com", 1323847743, 60));
cl_git_pass(git_tree_lookup(&tree, repo, &tree_oid));
- memset(&buffer, 0, sizeof(git_buf));
cl_git_pass(git_message_prettify(&buffer, "Initial commit", 0, '#'));
cl_git_pass(git_commit_create_v(
diff --git a/tests/object/lookup.c b/tests/object/lookup.c
index 2458537fc..a7b1ceeb4 100644
--- a/tests/object/lookup.c
+++ b/tests/object/lookup.c
@@ -66,13 +66,13 @@ void test_object_lookup__lookup_corrupt_object_returns_error(void)
{
const char *commit = "8e73b769e97678d684b809b163bebdae2911720f",
*file = "objects/8e/73b769e97678d684b809b163bebdae2911720f";
- git_buf path = GIT_BUF_INIT, contents = GIT_BUF_INIT;
+ git_str path = GIT_STR_INIT, contents = GIT_STR_INIT;
git_oid oid;
git_object *object;
size_t i;
cl_git_pass(git_oid_fromstr(&oid, commit));
- cl_git_pass(git_buf_joinpath(&path, git_repository_path(g_repo), file));
+ cl_git_pass(git_str_joinpath(&path, git_repository_path(g_repo), file));
cl_git_pass(git_futils_readbuffer(&contents, path.ptr));
/* Corrupt and try to read the object */
@@ -88,8 +88,8 @@ void test_object_lookup__lookup_corrupt_object_returns_error(void)
cl_git_pass(git_object_lookup(&object, g_repo, &oid, GIT_OBJECT_COMMIT));
git_object_free(object);
- git_buf_dispose(&path);
- git_buf_dispose(&contents);
+ git_str_dispose(&path);
+ git_str_dispose(&contents);
}
void test_object_lookup__lookup_object_with_wrong_hash_returns_error(void)
@@ -97,15 +97,15 @@ void test_object_lookup__lookup_object_with_wrong_hash_returns_error(void)
const char *oldloose = "objects/8e/73b769e97678d684b809b163bebdae2911720f",
*newloose = "objects/8e/73b769e97678d684b809b163bebdae2911720e",
*commit = "8e73b769e97678d684b809b163bebdae2911720e";
- git_buf oldpath = GIT_BUF_INIT, newpath = GIT_BUF_INIT;
+ git_str oldpath = GIT_STR_INIT, newpath = GIT_STR_INIT;
git_object *object;
git_oid oid;
cl_git_pass(git_oid_fromstr(&oid, commit));
/* Copy object to another location with wrong hash */
- cl_git_pass(git_buf_joinpath(&oldpath, git_repository_path(g_repo), oldloose));
- cl_git_pass(git_buf_joinpath(&newpath, git_repository_path(g_repo), newloose));
+ cl_git_pass(git_str_joinpath(&oldpath, git_repository_path(g_repo), oldloose));
+ cl_git_pass(git_str_joinpath(&newpath, git_repository_path(g_repo), newloose));
cl_git_pass(git_futils_cp(oldpath.ptr, newpath.ptr, 0644));
/* Verify that lookup fails due to a hashsum mismatch */
@@ -117,6 +117,6 @@ void test_object_lookup__lookup_object_with_wrong_hash_returns_error(void)
cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION, 1));
git_object_free(object);
- git_buf_dispose(&oldpath);
- git_buf_dispose(&newpath);
+ git_str_dispose(&oldpath);
+ git_str_dispose(&newpath);
}
diff --git a/tests/object/message.c b/tests/object/message.c
index bc005340b..d87c8ef70 100644
--- a/tests/object/message.c
+++ b/tests/object/message.c
@@ -1,13 +1,11 @@
#include "clar_libgit2.h"
-#include "buffer.h"
-#include "message.h"
static void assert_message_prettifying(char *expected_output, char *input, int strip_comments)
{
git_buf prettified_message = GIT_BUF_INIT;
git_message_prettify(&prettified_message, input, strip_comments, '#');
- cl_assert_equal_s(expected_output, git_buf_cstr(&prettified_message));
+ cl_assert_equal_s(expected_output, prettified_message.ptr);
git_buf_dispose(&prettified_message);
}
diff --git a/tests/object/raw/hash.c b/tests/object/raw/hash.c
index 3be1f83b3..5a3e81855 100644
--- a/tests/object/raw/hash.c
+++ b/tests/object/raw/hash.c
@@ -56,7 +56,7 @@ void test_object_raw_hash__hash_buffer_in_single_call(void)
void test_object_raw_hash__hash_vector(void)
{
git_oid id1, id2;
- git_buf_vec vec[2];
+ git_str_vec vec[2];
cl_git_pass(git_oid_fromstr(&id1, hello_id));
diff --git a/tests/object/tree/write.c b/tests/object/tree/write.c
index 1bc5a50a0..a4ceb35b6 100644
--- a/tests/object/tree/write.c
+++ b/tests/object/tree/write.c
@@ -394,12 +394,12 @@ void test_object_tree_write__cruel_paths(void)
for (i = 0; i < count; ++i) {
for (j = 0; j < count; ++j) {
- git_buf b = GIT_BUF_INIT;
- cl_git_pass(git_buf_joinpath(&b, the_paths[i], the_paths[j]));
+ git_str b = GIT_STR_INIT;
+ cl_git_pass(git_str_joinpath(&b, the_paths[i], the_paths[j]));
cl_git_pass(git_tree_entry_bypath(&te, tree, b.ptr));
cl_assert_equal_s(the_paths[j], git_tree_entry_name(te));
git_tree_entry_free(te);
- git_buf_dispose(&b);
+ git_str_dispose(&b);
}
}