summaryrefslogtreecommitdiff
path: root/tests/refs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/refs')
-rw-r--r--tests/refs/basic.c10
-rw-r--r--tests/refs/branches/create.c8
-rw-r--r--tests/refs/branches/delete.c20
-rw-r--r--tests/refs/branches/move.c25
-rw-r--r--tests/refs/branches/remote.c9
-rw-r--r--tests/refs/branches/upstreamname.c5
-rw-r--r--tests/refs/delete.c6
-rw-r--r--tests/refs/pack.c14
-rw-r--r--tests/refs/read.c6
-rw-r--r--tests/refs/ref_helpers.c7
-rw-r--r--tests/refs/reflog/messages.c8
-rw-r--r--tests/refs/reflog/reflog.c86
-rw-r--r--tests/refs/reflog/reflog_helpers.c32
-rw-r--r--tests/refs/rename.c22
-rw-r--r--tests/refs/revparse.c21
15 files changed, 136 insertions, 143 deletions
diff --git a/tests/refs/basic.c b/tests/refs/basic.c
index 9e4c22964..32742f9cc 100644
--- a/tests/refs/basic.c
+++ b/tests/refs/basic.c
@@ -49,7 +49,7 @@ void test_refs_basic__longpaths(void)
const char *base;
size_t base_len, extra_len;
ssize_t remain_len, i;
- git_buf refname = GIT_BUF_INIT;
+ git_str refname = GIT_STR_INIT;
git_reference *one = NULL, *two = NULL;
git_oid id;
@@ -62,10 +62,10 @@ void test_refs_basic__longpaths(void)
remain_len = (ssize_t)MAX_PATH - (base_len + extra_len);
cl_assert(remain_len > 0);
- cl_git_pass(git_buf_puts(&refname, "refs/heads/"));
+ cl_git_pass(git_str_puts(&refname, "refs/heads/"));
for (i = 0; i < remain_len; i++) {
- cl_git_pass(git_buf_putc(&refname, 'a'));
+ cl_git_pass(git_str_putc(&refname, 'a'));
}
/*
@@ -75,11 +75,11 @@ void test_refs_basic__longpaths(void)
cl_git_pass(git_reference_create(&one, g_repo, refname.ptr, &id, 0, NULL));
/* Adding one more character gives us a path that is too long. */
- cl_git_pass(git_buf_putc(&refname, 'z'));
+ cl_git_pass(git_str_putc(&refname, 'z'));
cl_git_fail(git_reference_create(&two, g_repo, refname.ptr, &id, 0, NULL));
git_reference_free(one);
git_reference_free(two);
- git_buf_dispose(&refname);
+ git_str_dispose(&refname);
#endif
}
diff --git a/tests/refs/branches/create.c b/tests/refs/branches/create.c
index 70ffad88d..7a49ad548 100644
--- a/tests/refs/branches/create.c
+++ b/tests/refs/branches/create.c
@@ -120,19 +120,19 @@ static void assert_branch_matches_name(
const char *expected, const char *lookup_as)
{
git_reference *ref;
- git_buf b = GIT_BUF_INIT;
+ git_str b = GIT_STR_INIT;
cl_git_pass(git_branch_lookup(&ref, repo, lookup_as, GIT_BRANCH_LOCAL));
- cl_git_pass(git_buf_sets(&b, "refs/heads/"));
- cl_git_pass(git_buf_puts(&b, expected));
+ cl_git_pass(git_str_sets(&b, "refs/heads/"));
+ cl_git_pass(git_str_puts(&b, expected));
cl_assert_equal_s(b.ptr, git_reference_name(ref));
cl_git_pass(
git_oid_cmp(git_reference_target(ref), git_commit_id(target)));
git_reference_free(ref);
- git_buf_dispose(&b);
+ git_str_dispose(&b);
}
void test_refs_branches_create__can_create_branch_with_unicode(void)
diff --git a/tests/refs/branches/delete.c b/tests/refs/branches/delete.c
index 6093c7886..aad5c090f 100644
--- a/tests/refs/branches/delete.c
+++ b/tests/refs/branches/delete.c
@@ -153,8 +153,8 @@ void test_refs_branches_delete__removes_empty_folders(void)
git_oid oidzero = {{0}};
git_signature *sig;
- git_buf ref_folder = GIT_BUF_INIT;
- git_buf reflog_folder = GIT_BUF_INIT;
+ git_str ref_folder = GIT_STR_INIT;
+ git_str reflog_folder = GIT_STR_INIT;
/* Create a new branch with a nested name */
cl_git_pass(git_oid_fromstr(&commit_id, "a65fedf39aefe402d3bb6e24df4d4f5fe4547750"));
@@ -170,19 +170,19 @@ void test_refs_branches_delete__removes_empty_folders(void)
git_signature_free(sig);
git_reflog_free(log);
- cl_git_pass(git_buf_joinpath(&ref_folder, commondir, "refs/heads/some/deep"));
- cl_git_pass(git_buf_join3(&reflog_folder, '/', commondir, GIT_REFLOG_DIR, "refs/heads/some/deep"));
+ cl_git_pass(git_str_joinpath(&ref_folder, commondir, "refs/heads/some/deep"));
+ cl_git_pass(git_str_join3(&reflog_folder, '/', commondir, GIT_REFLOG_DIR, "refs/heads/some/deep"));
- cl_assert(git_path_exists(git_buf_cstr(&ref_folder)) == true);
- cl_assert(git_path_exists(git_buf_cstr(&reflog_folder)) == true);
+ cl_assert(git_path_exists(git_str_cstr(&ref_folder)) == true);
+ cl_assert(git_path_exists(git_str_cstr(&reflog_folder)) == true);
cl_git_pass(git_branch_delete(branch));
- cl_assert(git_path_exists(git_buf_cstr(&ref_folder)) == false);
- cl_assert(git_path_exists(git_buf_cstr(&reflog_folder)) == false);
+ cl_assert(git_path_exists(git_str_cstr(&ref_folder)) == false);
+ cl_assert(git_path_exists(git_str_cstr(&reflog_folder)) == false);
git_reference_free(branch);
- git_buf_dispose(&ref_folder);
- git_buf_dispose(&reflog_folder);
+ git_str_dispose(&ref_folder);
+ git_str_dispose(&reflog_folder);
}
diff --git a/tests/refs/branches/move.c b/tests/refs/branches/move.c
index 2cba9dfd3..46a5082d2 100644
--- a/tests/refs/branches/move.c
+++ b/tests/refs/branches/move.c
@@ -67,16 +67,14 @@ void test_refs_branches_move__can_not_move_a_branch_if_its_destination_name_coll
{
git_reference *original_ref, *new_ref;
git_config *config;
- git_buf buf = GIT_BUF_INIT;
- char *original_remote, *original_merge;
+ git_buf original_remote = GIT_BUF_INIT,
+ original_merge = GIT_BUF_INIT;
const char *str;
cl_git_pass(git_repository_config_snapshot(&config, repo));
- cl_git_pass(git_config_get_string_buf(&buf, config, "branch.master.remote"));
- original_remote = git_buf_detach(&buf);
- cl_git_pass(git_config_get_string_buf(&buf, config, "branch.master.merge"));
- original_merge = git_buf_detach(&buf);
+ cl_git_pass(git_config_get_string_buf(&original_remote, config, "branch.master.remote"));
+ cl_git_pass(git_config_get_string_buf(&original_merge, config, "branch.master.merge"));
git_config_free(config);
cl_git_pass(git_reference_lookup(&original_ref, repo, "refs/heads/br2"));
@@ -88,9 +86,9 @@ void test_refs_branches_move__can_not_move_a_branch_if_its_destination_name_coll
cl_git_pass(git_repository_config_snapshot(&config, repo));
cl_git_pass(git_config_get_string(&str, config, "branch.master.remote"));
- cl_assert_equal_s(original_remote, str);
+ cl_assert_equal_s(original_remote.ptr, str);
cl_git_pass(git_config_get_string(&str, config, "branch.master.merge"));
- cl_assert_equal_s(original_merge, str);
+ cl_assert_equal_s(original_merge.ptr, str);
git_config_free(config);
cl_assert_equal_i(GIT_EEXISTS,
@@ -100,9 +98,9 @@ void test_refs_branches_move__can_not_move_a_branch_if_its_destination_name_coll
cl_git_pass(git_repository_config_snapshot(&config, repo));
cl_git_pass(git_config_get_string(&str, config, "branch.master.remote"));
- cl_assert_equal_s(original_remote, str);
+ cl_assert_equal_s(original_remote.ptr, str);
cl_git_pass(git_config_get_string(&str, config, "branch.master.merge"));
- cl_assert_equal_s(original_merge, str);
+ cl_assert_equal_s(original_merge.ptr, str);
git_config_free(config);
git_reference_free(original_ref);
@@ -115,11 +113,12 @@ void test_refs_branches_move__can_not_move_a_branch_if_its_destination_name_coll
cl_git_pass(git_repository_config_snapshot(&config, repo));
cl_git_pass(git_config_get_string(&str, config, "branch.master.remote"));
- cl_assert_equal_s(original_remote, str);
+ cl_assert_equal_s(original_remote.ptr, str);
cl_git_pass(git_config_get_string(&str, config, "branch.master.merge"));
- cl_assert_equal_s(original_merge, str);
+ cl_assert_equal_s(original_merge.ptr, str);
- git__free(original_remote); git__free(original_merge);
+ git_buf_dispose(&original_remote);
+ git_buf_dispose(&original_merge);
git_reference_free(original_ref);
git_config_free(config);
}
diff --git a/tests/refs/branches/remote.c b/tests/refs/branches/remote.c
index 27a3b0c44..e2bd3485a 100644
--- a/tests/refs/branches/remote.c
+++ b/tests/refs/branches/remote.c
@@ -32,10 +32,9 @@ void test_refs_branches_remote__can_get_remote_for_branch(void)
void test_refs_branches_remote__no_matching_remote_returns_error(void)
{
const char *unknown = "refs/remotes/nonexistent/master";
- git_buf buf;
+ git_buf buf = GIT_BUF_INIT;
git_error_clear();
- memset(&buf, 0, sizeof(git_buf));
cl_git_fail_with(git_branch_remote_name(&buf, g_repo, unknown), GIT_ENOTFOUND);
cl_assert(git_error_last() != NULL);
}
@@ -43,10 +42,9 @@ void test_refs_branches_remote__no_matching_remote_returns_error(void)
void test_refs_branches_remote__local_remote_returns_error(void)
{
const char *local = "refs/heads/master";
- git_buf buf;
+ git_buf buf = GIT_BUF_INIT;
git_error_clear();
- memset(&buf, 0, sizeof(git_buf));
cl_git_fail_with(git_branch_remote_name(&buf, g_repo, local), GIT_ERROR);
cl_assert(git_error_last() != NULL);
}
@@ -54,7 +52,7 @@ void test_refs_branches_remote__local_remote_returns_error(void)
void test_refs_branches_remote__ambiguous_remote_returns_error(void)
{
git_remote *remote;
- git_buf buf;
+ git_buf buf = GIT_BUF_INIT;
/* Create the remote */
cl_git_pass(git_remote_create_with_fetchspec(&remote, g_repo, "addtest", "http://github.com/libgit2/libgit2", "refs/heads/*:refs/remotes/test/*"));
@@ -62,7 +60,6 @@ void test_refs_branches_remote__ambiguous_remote_returns_error(void)
git_remote_free(remote);
git_error_clear();
- memset(&buf, 0, sizeof(git_buf));
cl_git_fail_with(git_branch_remote_name(&buf, g_repo, remote_tracking_branch_name), GIT_EAMBIGUOUS);
cl_assert(git_error_last() != NULL);
}
diff --git a/tests/refs/branches/upstreamname.c b/tests/refs/branches/upstreamname.c
index 2eb639738..5bae154d2 100644
--- a/tests/refs/branches/upstreamname.c
+++ b/tests/refs/branches/upstreamname.c
@@ -8,7 +8,6 @@ void test_refs_branches_upstreamname__initialize(void)
{
cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
- git_buf_init(&upstream_name, 0);
}
void test_refs_branches_upstreamname__cleanup(void)
@@ -24,7 +23,7 @@ void test_refs_branches_upstreamname__can_retrieve_the_remote_tracking_reference
cl_git_pass(git_branch_upstream_name(
&upstream_name, repo, "refs/heads/master"));
- cl_assert_equal_s("refs/remotes/test/master", git_buf_cstr(&upstream_name));
+ cl_assert_equal_s("refs/remotes/test/master", upstream_name.ptr);
}
void test_refs_branches_upstreamname__can_retrieve_the_local_upstream_reference_name_of_a_local_branch(void)
@@ -32,5 +31,5 @@ void test_refs_branches_upstreamname__can_retrieve_the_local_upstream_reference_
cl_git_pass(git_branch_upstream_name(
&upstream_name, repo, "refs/heads/track-local"));
- cl_assert_equal_s("refs/heads/master", git_buf_cstr(&upstream_name));
+ cl_assert_equal_s("refs/heads/master", upstream_name.ptr);
}
diff --git a/tests/refs/delete.c b/tests/refs/delete.c
index 3e99a7959..c76d126eb 100644
--- a/tests/refs/delete.c
+++ b/tests/refs/delete.c
@@ -29,10 +29,10 @@ void test_refs_delete__packed_loose(void)
{
/* deleting a ref which is both packed and loose should remove both tracks in the filesystem */
git_reference *looked_up_ref, *another_looked_up_ref;
- git_buf temp_path = GIT_BUF_INIT;
+ git_str temp_path = GIT_STR_INIT;
/* Ensure the loose reference exists on the file system */
- cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), packed_test_head_name));
+ cl_git_pass(git_str_joinpath(&temp_path, git_repository_path(g_repo), packed_test_head_name));
cl_assert(git_path_exists(temp_path.ptr));
/* Lookup the reference */
@@ -52,7 +52,7 @@ void test_refs_delete__packed_loose(void)
cl_assert(!git_path_exists(temp_path.ptr));
git_reference_free(another_looked_up_ref);
- git_buf_dispose(&temp_path);
+ git_str_dispose(&temp_path);
}
void test_refs_delete__packed_only(void)
diff --git a/tests/refs/pack.c b/tests/refs/pack.c
index 676fb1759..125b1adb0 100644
--- a/tests/refs/pack.c
+++ b/tests/refs/pack.c
@@ -33,11 +33,11 @@ static void packall(void)
void test_refs_pack__empty(void)
{
/* create a packfile for an empty folder */
- git_buf temp_path = GIT_BUF_INIT;
+ git_str temp_path = GIT_STR_INIT;
- cl_git_pass(git_buf_join_n(&temp_path, '/', 3, git_repository_path(g_repo), GIT_REFS_HEADS_DIR, "empty_dir"));
+ cl_git_pass(git_str_join_n(&temp_path, '/', 3, git_repository_path(g_repo), GIT_REFS_HEADS_DIR, "empty_dir"));
cl_git_pass(git_futils_mkdir_r(temp_path.ptr, GIT_REFS_DIR_MODE));
- git_buf_dispose(&temp_path);
+ git_str_dispose(&temp_path);
packall();
}
@@ -46,7 +46,7 @@ void test_refs_pack__loose(void)
{
/* create a packfile from all the loose refs in a repo */
git_reference *reference;
- git_buf temp_path = GIT_BUF_INIT;
+ git_str temp_path = GIT_STR_INIT;
/* Ensure a known loose ref can be looked up */
cl_git_pass(git_reference_lookup(&reference, g_repo, loose_tag_ref_name));
@@ -62,7 +62,7 @@ void test_refs_pack__loose(void)
packall();
/* Ensure the packed-refs file exists */
- cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), GIT_PACKEDREFS_FILE));
+ cl_git_pass(git_str_joinpath(&temp_path, git_repository_path(g_repo), GIT_PACKEDREFS_FILE));
cl_assert(git_path_exists(temp_path.ptr));
/* Ensure the known ref can still be looked up but is now packed */
@@ -71,11 +71,11 @@ void test_refs_pack__loose(void)
cl_assert_equal_s(reference->name, loose_tag_ref_name);
/* Ensure the known ref has been removed from the loose folder structure */
- cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), loose_tag_ref_name));
+ cl_git_pass(git_str_joinpath(&temp_path, git_repository_path(g_repo), loose_tag_ref_name));
cl_assert(!git_path_exists(temp_path.ptr));
git_reference_free(reference);
- git_buf_dispose(&temp_path);
+ git_str_dispose(&temp_path);
}
void test_refs_pack__symbolic(void)
diff --git a/tests/refs/read.c b/tests/refs/read.c
index 1bbc38766..a622c770b 100644
--- a/tests/refs/read.c
+++ b/tests/refs/read.c
@@ -31,7 +31,7 @@ void test_refs_read__loose_tag(void)
/* lookup a loose tag reference */
git_reference *reference;
git_object *object;
- git_buf ref_name_from_tag_name = GIT_BUF_INIT;
+ git_str ref_name_from_tag_name = GIT_STR_INIT;
cl_git_pass(git_reference_lookup(&reference, g_repo, loose_tag_ref_name));
cl_assert(git_reference_type(reference) & GIT_REFERENCE_DIRECT);
@@ -43,9 +43,9 @@ void test_refs_read__loose_tag(void)
cl_assert(git_object_type(object) == GIT_OBJECT_TAG);
/* Ensure the name of the tag matches the name of the reference */
- cl_git_pass(git_buf_joinpath(&ref_name_from_tag_name, GIT_REFS_TAGS_DIR, git_tag_name((git_tag *)object)));
+ cl_git_pass(git_str_joinpath(&ref_name_from_tag_name, GIT_REFS_TAGS_DIR, git_tag_name((git_tag *)object)));
cl_assert_equal_s(ref_name_from_tag_name.ptr, loose_tag_ref_name);
- git_buf_dispose(&ref_name_from_tag_name);
+ git_str_dispose(&ref_name_from_tag_name);
git_object_free(object);
diff --git a/tests/refs/ref_helpers.c b/tests/refs/ref_helpers.c
index 42b49216c..e55364c6e 100644
--- a/tests/refs/ref_helpers.c
+++ b/tests/refs/ref_helpers.c
@@ -2,24 +2,23 @@
#include "git2/refs.h"
#include "common.h"
#include "util.h"
-#include "buffer.h"
#include "path.h"
int reference_is_packed(git_reference *ref)
{
- git_buf ref_path = GIT_BUF_INIT;
+ git_str ref_path = GIT_STR_INIT;
int packed;
assert(ref);
- if (git_buf_joinpath(&ref_path,
+ if (git_str_joinpath(&ref_path,
git_repository_path(git_reference_owner(ref)),
git_reference_name(ref)) < 0)
return -1;
packed = !git_path_isfile(ref_path.ptr);
- git_buf_dispose(&ref_path);
+ git_str_dispose(&ref_path);
return packed;
}
diff --git a/tests/refs/reflog/messages.c b/tests/refs/reflog/messages.c
index 53b8c6f3e..ed183d2f2 100644
--- a/tests/refs/reflog/messages.c
+++ b/tests/refs/reflog/messages.c
@@ -338,7 +338,7 @@ void test_refs_reflog_messages__updating_a_direct_reference(void)
void test_refs_reflog_messages__creating_branches_default_messages(void)
{
- git_buf buf = GIT_BUF_INIT;
+ git_str buf = GIT_STR_INIT;
git_annotated_commit *annotated;
git_object *obj;
git_commit *target;
@@ -350,11 +350,11 @@ void test_refs_reflog_messages__creating_branches_default_messages(void)
cl_git_pass(git_branch_create(&branch1, g_repo, NEW_BRANCH_NAME, target, false));
- cl_git_pass(git_buf_printf(&buf, "branch: Created from %s", git_oid_tostr_s(git_commit_id(target))));
+ cl_git_pass(git_str_printf(&buf, "branch: Created from %s", git_oid_tostr_s(git_commit_id(target))));
cl_reflog_check_entry(g_repo, "refs/heads/" NEW_BRANCH_NAME, 0,
GIT_OID_HEX_ZERO,
git_oid_tostr_s(git_commit_id(target)),
- g_email, git_buf_cstr(&buf));
+ g_email, git_str_cstr(&buf));
cl_git_pass(git_reference_remove(g_repo, "refs/heads/" NEW_BRANCH_NAME));
@@ -367,7 +367,7 @@ void test_refs_reflog_messages__creating_branches_default_messages(void)
g_email, "branch: Created from e90810b8df3");
git_annotated_commit_free(annotated);
- git_buf_dispose(&buf);
+ git_str_dispose(&buf);
git_commit_free(target);
git_reference_free(branch1);
git_reference_free(branch2);
diff --git a/tests/refs/reflog/reflog.c b/tests/refs/reflog/reflog.c
index 5cefc3227..5bb6138df 100644
--- a/tests/refs/reflog/reflog.c
+++ b/tests/refs/reflog/reflog.c
@@ -100,60 +100,60 @@ void test_refs_reflog_reflog__append_then_read(void)
void test_refs_reflog_reflog__renaming_the_reference_moves_the_reflog(void)
{
git_reference *master, *new_master;
- git_buf master_log_path = GIT_BUF_INIT, moved_log_path = GIT_BUF_INIT;
+ git_str master_log_path = GIT_STR_INIT, moved_log_path = GIT_STR_INIT;
- git_buf_joinpath(&master_log_path, git_repository_path(g_repo), GIT_REFLOG_DIR);
- git_buf_puts(&moved_log_path, git_buf_cstr(&master_log_path));
- git_buf_joinpath(&master_log_path, git_buf_cstr(&master_log_path), "refs/heads/master");
- git_buf_joinpath(&moved_log_path, git_buf_cstr(&moved_log_path), "refs/moved");
+ git_str_joinpath(&master_log_path, git_repository_path(g_repo), GIT_REFLOG_DIR);
+ git_str_puts(&moved_log_path, git_str_cstr(&master_log_path));
+ git_str_joinpath(&master_log_path, git_str_cstr(&master_log_path), "refs/heads/master");
+ git_str_joinpath(&moved_log_path, git_str_cstr(&moved_log_path), "refs/moved");
- cl_assert_equal_i(true, git_path_isfile(git_buf_cstr(&master_log_path)));
- cl_assert_equal_i(false, git_path_isfile(git_buf_cstr(&moved_log_path)));
+ cl_assert_equal_i(true, git_path_isfile(git_str_cstr(&master_log_path)));
+ cl_assert_equal_i(false, git_path_isfile(git_str_cstr(&moved_log_path)));
cl_git_pass(git_reference_lookup(&master, g_repo, "refs/heads/master"));
cl_git_pass(git_reference_rename(&new_master, master, "refs/moved", 0, NULL));
git_reference_free(master);
- cl_assert_equal_i(false, git_path_isfile(git_buf_cstr(&master_log_path)));
- cl_assert_equal_i(true, git_path_isfile(git_buf_cstr(&moved_log_path)));
+ cl_assert_equal_i(false, git_path_isfile(git_str_cstr(&master_log_path)));
+ cl_assert_equal_i(true, git_path_isfile(git_str_cstr(&moved_log_path)));
git_reference_free(new_master);
- git_buf_dispose(&moved_log_path);
- git_buf_dispose(&master_log_path);
+ git_str_dispose(&moved_log_path);
+ git_str_dispose(&master_log_path);
}
void test_refs_reflog_reflog__deleting_the_reference_deletes_the_reflog(void)
{
git_reference *master;
- git_buf master_log_path = GIT_BUF_INIT;
+ git_str master_log_path = GIT_STR_INIT;
- git_buf_joinpath(&master_log_path, git_repository_path(g_repo), GIT_REFLOG_DIR);
- git_buf_joinpath(&master_log_path, git_buf_cstr(&master_log_path), "refs/heads/master");
+ git_str_joinpath(&master_log_path, git_repository_path(g_repo), GIT_REFLOG_DIR);
+ git_str_joinpath(&master_log_path, git_str_cstr(&master_log_path), "refs/heads/master");
- cl_assert_equal_i(true, git_path_isfile(git_buf_cstr(&master_log_path)));
+ cl_assert_equal_i(true, git_path_isfile(git_str_cstr(&master_log_path)));
cl_git_pass(git_reference_lookup(&master, g_repo, "refs/heads/master"));
cl_git_pass(git_reference_delete(master));
git_reference_free(master);
- cl_assert_equal_i(false, git_path_isfile(git_buf_cstr(&master_log_path)));
- git_buf_dispose(&master_log_path);
+ cl_assert_equal_i(false, git_path_isfile(git_str_cstr(&master_log_path)));
+ git_str_dispose(&master_log_path);
}
void test_refs_reflog_reflog__removes_empty_reflog_dir(void)
{
git_reference *ref;
- git_buf log_path = GIT_BUF_INIT;
+ git_str log_path = GIT_STR_INIT;
git_oid id;
/* Create a new branch pointing at the HEAD */
git_oid_fromstr(&id, current_master_tip);
cl_git_pass(git_reference_create(&ref, g_repo, "refs/heads/new-dir/new-head", &id, 0, NULL));
- git_buf_joinpath(&log_path, git_repository_path(g_repo), GIT_REFLOG_DIR);
- git_buf_joinpath(&log_path, git_buf_cstr(&log_path), "refs/heads/new-dir/new-head");
+ git_str_joinpath(&log_path, git_repository_path(g_repo), GIT_REFLOG_DIR);
+ git_str_joinpath(&log_path, git_str_cstr(&log_path), "refs/heads/new-dir/new-head");
- cl_assert_equal_i(true, git_path_isfile(git_buf_cstr(&log_path)));
+ cl_assert_equal_i(true, git_path_isfile(git_str_cstr(&log_path)));
cl_git_pass(git_reference_delete(ref));
git_reference_free(ref);
@@ -163,13 +163,13 @@ void test_refs_reflog_reflog__removes_empty_reflog_dir(void)
cl_git_pass(git_reference_create(&ref, g_repo, "refs/heads/new-dir", &id, 0, NULL));
git_reference_free(ref);
- git_buf_dispose(&log_path);
+ git_str_dispose(&log_path);
}
void test_refs_reflog_reflog__fails_gracefully_on_nonempty_reflog_dir(void)
{
git_reference *ref;
- git_buf log_path = GIT_BUF_INIT;
+ git_str log_path = GIT_STR_INIT;
git_oid id;
/* Create a new branch pointing at the HEAD */
@@ -177,10 +177,10 @@ void test_refs_reflog_reflog__fails_gracefully_on_nonempty_reflog_dir(void)
cl_git_pass(git_reference_create(&ref, g_repo, "refs/heads/new-dir/new-head", &id, 0, NULL));
git_reference_free(ref);
- git_buf_joinpath(&log_path, git_repository_path(g_repo), GIT_REFLOG_DIR);
- git_buf_joinpath(&log_path, git_buf_cstr(&log_path), "refs/heads/new-dir/new-head");
+ git_str_joinpath(&log_path, git_repository_path(g_repo), GIT_REFLOG_DIR);
+ git_str_joinpath(&log_path, git_str_cstr(&log_path), "refs/heads/new-dir/new-head");
- cl_assert_equal_i(true, git_path_isfile(git_buf_cstr(&log_path)));
+ cl_assert_equal_i(true, git_path_isfile(git_str_cstr(&log_path)));
/* delete the ref manually, leave the reflog */
cl_must_pass(p_unlink("testrepo.git/refs/heads/new-dir/new-head"));
@@ -190,7 +190,7 @@ void test_refs_reflog_reflog__fails_gracefully_on_nonempty_reflog_dir(void)
cl_git_fail_with(GIT_EDIRECTORY, git_reference_create(&ref, g_repo, "refs/heads/new-dir", &id, 0, NULL));
git_reference_free(ref);
- git_buf_dispose(&log_path);
+ git_str_dispose(&log_path);
}
static void assert_has_reflog(bool expected_result, const char *name)
@@ -209,17 +209,17 @@ void test_refs_reflog_reflog__reading_the_reflog_from_a_reference_with_no_log_re
{
git_reflog *reflog;
const char *refname = "refs/heads/subtrees";
- git_buf subtrees_log_path = GIT_BUF_INIT;
+ git_str subtrees_log_path = GIT_STR_INIT;
- git_buf_join_n(&subtrees_log_path, '/', 3, git_repository_path(g_repo), GIT_REFLOG_DIR, refname);
- cl_assert_equal_i(false, git_path_isfile(git_buf_cstr(&subtrees_log_path)));
+ git_str_join_n(&subtrees_log_path, '/', 3, git_repository_path(g_repo), GIT_REFLOG_DIR, refname);
+ cl_assert_equal_i(false, git_path_isfile(git_str_cstr(&subtrees_log_path)));
cl_git_pass(git_reflog_read(&reflog, g_repo, refname));
cl_assert_equal_i(0, (int)git_reflog_entrycount(reflog));
git_reflog_free(reflog);
- git_buf_dispose(&subtrees_log_path);
+ git_str_dispose(&subtrees_log_path);
}
void test_refs_reflog_reflog__reading_a_reflog_with_invalid_format_succeeds(void)
@@ -231,7 +231,7 @@ void test_refs_reflog_reflog__reading_a_reflog_with_invalid_format_succeeds(void
const git_reflog_entry *entry;
git_reference *ref;
git_oid id;
- git_buf logpath = GIT_BUF_INIT, logcontents = GIT_BUF_INIT;
+ git_str logpath = GIT_STR_INIT, logcontents = GIT_STR_INIT;
char *star;
/* Create a new branch. */
@@ -242,18 +242,18 @@ void test_refs_reflog_reflog__reading_a_reflog_with_invalid_format_succeeds(void
* Corrupt the branch reflog by introducing a newline inside the reflog message.
* We do this by replacing '*' with '\n'
*/
- cl_git_pass(git_buf_join_n(&logpath, '/', 3, git_repository_path(g_repo), GIT_REFLOG_DIR, refname));
- cl_git_pass(git_futils_readbuffer(&logcontents, git_buf_cstr(&logpath)));
- cl_assert((star = strchr(git_buf_cstr(&logcontents), '*')) != NULL);
+ cl_git_pass(git_str_join_n(&logpath, '/', 3, git_repository_path(g_repo), GIT_REFLOG_DIR, refname));
+ cl_git_pass(git_futils_readbuffer(&logcontents, git_str_cstr(&logpath)));
+ cl_assert((star = strchr(git_str_cstr(&logcontents), '*')) != NULL);
*star = '\n';
- cl_git_rewritefile(git_buf_cstr(&logpath), git_buf_cstr(&logcontents));
+ cl_git_rewritefile(git_str_cstr(&logpath), git_str_cstr(&logcontents));
/*
* Confirm that the file was rewritten successfully
* and now contains a '\n' in the expected location
*/
- cl_git_pass(git_futils_readbuffer(&logcontents, git_buf_cstr(&logpath)));
- cl_assert(strstr(git_buf_cstr(&logcontents), "Reflog\nmessage") != NULL);
+ cl_git_pass(git_futils_readbuffer(&logcontents, git_str_cstr(&logpath)));
+ cl_assert(strstr(git_str_cstr(&logcontents), "Reflog\nmessage") != NULL);
cl_git_pass(git_reflog_read(&reflog, g_repo, refname));
cl_assert(entry = git_reflog_entry_byindex(reflog, 0));
@@ -261,14 +261,14 @@ void test_refs_reflog_reflog__reading_a_reflog_with_invalid_format_succeeds(void
git_reference_free(ref);
git_reflog_free(reflog);
- git_buf_dispose(&logpath);
- git_buf_dispose(&logcontents);
+ git_str_dispose(&logpath);
+ git_str_dispose(&logcontents);
}
void test_refs_reflog_reflog__cannot_write_a_moved_reflog(void)
{
git_reference *master, *new_master;
- git_buf master_log_path = GIT_BUF_INIT, moved_log_path = GIT_BUF_INIT;
+ git_str master_log_path = GIT_STR_INIT, moved_log_path = GIT_STR_INIT;
git_reflog *reflog;
cl_git_pass(git_reference_lookup(&master, g_repo, "refs/heads/master"));
@@ -283,8 +283,8 @@ void test_refs_reflog_reflog__cannot_write_a_moved_reflog(void)
git_reflog_free(reflog);
git_reference_free(new_master);
- git_buf_dispose(&moved_log_path);
- git_buf_dispose(&master_log_path);
+ git_str_dispose(&moved_log_path);
+ git_str_dispose(&master_log_path);
}
void test_refs_reflog_reflog__renaming_with_an_invalid_name_returns_EINVALIDSPEC(void)
diff --git a/tests/refs/reflog/reflog_helpers.c b/tests/refs/reflog/reflog_helpers.c
index aecb78b02..22619a4e3 100644
--- a/tests/refs/reflog/reflog_helpers.c
+++ b/tests/refs/reflog/reflog_helpers.c
@@ -3,7 +3,7 @@
#include "repository.h"
#include "reflog.h"
-static int reflog_entry_tostr(git_buf *out, const git_reflog_entry *entry)
+static int reflog_entry_tostr(git_str *out, const git_reflog_entry *entry)
{
char old_oid[GIT_OID_HEXSZ], new_oid[GIT_OID_HEXSZ];
@@ -12,7 +12,7 @@ static int reflog_entry_tostr(git_buf *out, const git_reflog_entry *entry)
git_oid_tostr((char *)&old_oid, GIT_OID_HEXSZ, git_reflog_entry_id_old(entry));
git_oid_tostr((char *)&new_oid, GIT_OID_HEXSZ, git_reflog_entry_id_new(entry));
- return git_buf_printf(out, "%s %s %s %s", old_oid, new_oid, "somesig", git_reflog_entry_message(entry));
+ return git_str_printf(out, "%s %s %s %s", old_oid, new_oid, "somesig", git_reflog_entry_message(entry));
}
size_t reflog_entrycount(git_repository *repo, const char *name)
@@ -34,7 +34,7 @@ void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx
{
git_reflog *log;
const git_reflog_entry *entry;
- git_buf result = GIT_BUF_INIT;
+ git_str result = GIT_STR_INIT;
cl_git_pass(git_reflog_read(&log, repo, reflog));
entry = git_reflog_entry_byindex(log, idx);
@@ -47,7 +47,7 @@ void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx
if (git_oid_cmp(git_object_id(obj), git_reflog_entry_id_old(entry)) != 0) {
git_oid__writebuf(&result, "\tOld OID: \"", git_object_id(obj));
git_oid__writebuf(&result, "\" != \"", git_reflog_entry_id_old(entry));
- git_buf_puts(&result, "\"\n");
+ git_str_puts(&result, "\"\n");
}
git_object_free(obj);
} else {
@@ -56,7 +56,7 @@ void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx
if (git_oid_cmp(oid, git_reflog_entry_id_old(entry)) != 0) {
git_oid__writebuf(&result, "\tOld OID: \"", oid);
git_oid__writebuf(&result, "\" != \"", git_reflog_entry_id_old(entry));
- git_buf_puts(&result, "\"\n");
+ git_str_puts(&result, "\"\n");
}
git__free(oid);
}
@@ -67,7 +67,7 @@ void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx
if (git_oid_cmp(git_object_id(obj), git_reflog_entry_id_new(entry)) != 0) {
git_oid__writebuf(&result, "\tNew OID: \"", git_object_id(obj));
git_oid__writebuf(&result, "\" != \"", git_reflog_entry_id_new(entry));
- git_buf_puts(&result, "\"\n");
+ git_str_puts(&result, "\"\n");
}
git_object_free(obj);
} else {
@@ -76,26 +76,26 @@ void cl_reflog_check_entry_(git_repository *repo, const char *reflog, size_t idx
if (git_oid_cmp(oid, git_reflog_entry_id_new(entry)) != 0) {
git_oid__writebuf(&result, "\tNew OID: \"", oid);
git_oid__writebuf(&result, "\" != \"", git_reflog_entry_id_new(entry));
- git_buf_puts(&result, "\"\n");
+ git_str_puts(&result, "\"\n");
}
git__free(oid);
}
}
if (email && strcmp(email, git_reflog_entry_committer(entry)->email) != 0)
- git_buf_printf(&result, "\tEmail: \"%s\" != \"%s\"\n", email, git_reflog_entry_committer(entry)->email);
+ git_str_printf(&result, "\tEmail: \"%s\" != \"%s\"\n", email, git_reflog_entry_committer(entry)->email);
if (message) {
const char *entry_msg = git_reflog_entry_message(entry);
if (entry_msg == NULL) entry_msg = "";
if (entry_msg && strcmp(message, entry_msg) != 0)
- git_buf_printf(&result, "\tMessage: \"%s\" != \"%s\"\n", message, entry_msg);
+ git_str_printf(&result, "\tMessage: \"%s\" != \"%s\"\n", message, entry_msg);
}
- if (git_buf_len(&result) != 0)
- clar__fail(file, func, line, "Reflog entry mismatch", git_buf_cstr(&result), 1);
+ if (git_str_len(&result) != 0)
+ clar__fail(file, func, line, "Reflog entry mismatch", git_str_cstr(&result), 1);
- git_buf_dispose(&result);
+ git_str_dispose(&result);
git_reflog_free(log);
}
@@ -103,17 +103,17 @@ void reflog_print(git_repository *repo, const char *reflog_name)
{
git_reflog *reflog;
size_t idx;
- git_buf out = GIT_BUF_INIT;
+ git_str out = GIT_STR_INIT;
git_reflog_read(&reflog, repo, reflog_name);
for (idx = 0; idx < git_reflog_entrycount(reflog); idx++) {
const git_reflog_entry *entry = git_reflog_entry_byindex(reflog, idx);
reflog_entry_tostr(&out, entry);
- git_buf_putc(&out, '\n');
+ git_str_putc(&out, '\n');
}
- fprintf(stderr, "%s", git_buf_cstr(&out));
- git_buf_dispose(&out);
+ fprintf(stderr, "%s", git_str_cstr(&out));
+ git_str_dispose(&out);
git_reflog_free(reflog);
}
diff --git a/tests/refs/rename.c b/tests/refs/rename.c
index b1b75cd64..fa732234a 100644
--- a/tests/refs/rename.c
+++ b/tests/refs/rename.c
@@ -36,11 +36,11 @@ void test_refs_rename__loose(void)
{
/* rename a loose reference */
git_reference *looked_up_ref, *new_ref, *another_looked_up_ref;
- git_buf temp_path = GIT_BUF_INIT;
+ git_str temp_path = GIT_STR_INIT;
const char *new_name = "refs/tags/Nemo/knows/refs.kung-fu";
/* Ensure the ref doesn't exist on the file system */
- cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), new_name));
+ cl_git_pass(git_str_joinpath(&temp_path, git_repository_path(g_repo), new_name));
cl_assert(!git_path_exists(temp_path.ptr));
/* Retrieval of the reference to rename */
@@ -66,23 +66,23 @@ void test_refs_rename__loose(void)
cl_assert(reference_is_packed(new_ref) == 0);
/* ...and the ref can be found in the file system */
- cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), new_name));
+ cl_git_pass(git_str_joinpath(&temp_path, git_repository_path(g_repo), new_name));
cl_assert(git_path_exists(temp_path.ptr));
git_reference_free(new_ref);
git_reference_free(another_looked_up_ref);
- git_buf_dispose(&temp_path);
+ git_str_dispose(&temp_path);
}
void test_refs_rename__packed(void)
{
/* rename a packed reference (should make it loose) */
git_reference *looked_up_ref, *new_ref, *another_looked_up_ref;
- git_buf temp_path = GIT_BUF_INIT;
+ git_str temp_path = GIT_STR_INIT;
const char *brand_new_name = "refs/heads/brand_new_name";
/* Ensure the ref doesn't exist on the file system */
- cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), packed_head_name));
+ cl_git_pass(git_str_joinpath(&temp_path, git_repository_path(g_repo), packed_head_name));
cl_assert(!git_path_exists(temp_path.ptr));
/* The reference can however be looked-up... */
@@ -108,23 +108,23 @@ void test_refs_rename__packed(void)
cl_assert(reference_is_packed(new_ref) == 0);
/* ...and the ref now happily lives in the file system */
- cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), brand_new_name));
+ cl_git_pass(git_str_joinpath(&temp_path, git_repository_path(g_repo), brand_new_name));
cl_assert(git_path_exists(temp_path.ptr));
git_reference_free(new_ref);
git_reference_free(another_looked_up_ref);
- git_buf_dispose(&temp_path);
+ git_str_dispose(&temp_path);
}
void test_refs_rename__packed_doesnt_pack_others(void)
{
/* renaming a packed reference does not pack another reference which happens to be in both loose and pack state */
git_reference *looked_up_ref, *another_looked_up_ref, *renamed_ref;
- git_buf temp_path = GIT_BUF_INIT;
+ git_str temp_path = GIT_STR_INIT;
const char *brand_new_name = "refs/heads/brand_new_name";
/* Ensure the other reference exists on the file system */
- cl_git_pass(git_buf_joinpath(&temp_path, git_repository_path(g_repo), packed_test_head_name));
+ cl_git_pass(git_str_joinpath(&temp_path, git_repository_path(g_repo), packed_test_head_name));
cl_assert(git_path_exists(temp_path.ptr));
/* Lookup the other reference */
@@ -155,7 +155,7 @@ void test_refs_rename__packed_doesnt_pack_others(void)
git_reference_free(renamed_ref);
git_reference_free(another_looked_up_ref);
- git_buf_dispose(&temp_path);
+ git_str_dispose(&temp_path);
}
void test_refs_rename__name_collision(void)
diff --git a/tests/refs/revparse.c b/tests/refs/revparse.c
index bc6e0a4c4..9c960702a 100644
--- a/tests/refs/revparse.c
+++ b/tests/refs/revparse.c
@@ -1,7 +1,6 @@
#include "clar_libgit2.h"
#include "git2/revparse.h"
-#include "buffer.h"
#include "refs.h"
#include "path.h"
@@ -292,7 +291,7 @@ void test_refs_revparse__upstream(void)
void test_refs_revparse__ordinal(void)
{
assert_invalid_single_spec("master@{-2}");
-
+
/* TODO: make the test below actually fail
* cl_git_fail(git_revparse_single(&g_obj, g_repo, "master@{1a}"));
*/
@@ -326,19 +325,19 @@ void test_refs_revparse__previous_head(void)
static void create_fake_stash_reference_and_reflog(git_repository *repo)
{
git_reference *master, *new_master;
- git_buf log_path = GIT_BUF_INIT;
+ git_str log_path = GIT_STR_INIT;
- git_buf_joinpath(&log_path, git_repository_path(repo), "logs/refs/fakestash");
+ git_str_joinpath(&log_path, git_repository_path(repo), "logs/refs/fakestash");
- cl_assert_equal_i(false, git_path_isfile(git_buf_cstr(&log_path)));
+ cl_assert_equal_i(false, git_path_isfile(git_str_cstr(&log_path)));
cl_git_pass(git_reference_lookup(&master, repo, "refs/heads/master"));
cl_git_pass(git_reference_rename(&new_master, master, "refs/fakestash", 0, NULL));
git_reference_free(master);
- cl_assert_equal_i(true, git_path_isfile(git_buf_cstr(&log_path)));
+ cl_assert_equal_i(true, git_path_isfile(git_str_cstr(&log_path)));
- git_buf_dispose(&log_path);
+ git_str_dispose(&log_path);
git_reference_free(new_master);
}
@@ -555,7 +554,7 @@ void test_refs_revparse__a_too_short_objectid_returns_EAMBIGUOUS(void)
/*
* $ echo "aabqhq" | git hash-object -t blob --stdin
* dea509d0b3cb8ee0650f6ca210bc83f4678851ba
- *
+ *
* $ echo "aaazvc" | git hash-object -t blob --stdin
* dea509d097ce692e167dfc6a48a7a280cc5e877e
*/
@@ -569,11 +568,11 @@ void test_refs_revparse__a_not_precise_enough_objectid_returns_EAMBIGUOUS(void)
cl_git_mkfile("testrepo/one.txt", "aabqhq\n");
cl_git_mkfile("testrepo/two.txt", "aaazvc\n");
-
+
cl_git_pass(git_repository_index(&index, repo));
cl_git_pass(git_index_add_bypath(index, "one.txt"));
cl_git_pass(git_index_add_bypath(index, "two.txt"));
-
+
cl_git_fail_with(git_revparse_single(&obj, repo, "dea509d0"), GIT_EAMBIGUOUS);
cl_git_pass(git_revparse_single(&obj, repo, "dea509d09"));
@@ -588,7 +587,7 @@ void test_refs_revparse__issue_994(void)
git_repository *repo;
git_reference *head, *with_at;
git_object *target;
-
+
repo = cl_git_sandbox_init("testrepo.git");
cl_assert_equal_i(GIT_ENOTFOUND,