diff options
Diffstat (limited to 'tests/refs/reflog/reflog.c')
-rw-r--r-- | tests/refs/reflog/reflog.c | 86 |
1 files changed, 43 insertions, 43 deletions
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) |