]> git.proxmox.com Git - libgit2.git/blobdiff - tests/reset/hard.c
New upstream version 1.4.3+dfsg.1
[libgit2.git] / tests / reset / hard.c
index 1ea1d13fbbbc65d205822c2eb066c81218287e34..9d177c021712d82a081ed70bc69b4f50e4225ff3 100644 (file)
@@ -40,7 +40,7 @@ static int strequal_ignore_eol(const char *exp, const char *str)
 
 void test_reset_hard__resetting_reverts_modified_files(void)
 {
-       git_buf path = GIT_BUF_INIT, content = GIT_BUF_INIT;
+       git_str path = GIT_STR_INIT, content = GIT_STR_INIT;
        int i;
        static const char *files[4] = {
                "current_file",
@@ -64,7 +64,7 @@ void test_reset_hard__resetting_reverts_modified_files(void)
        cl_assert(wd);
 
        for (i = 0; i < 4; ++i) {
-               cl_git_pass(git_buf_joinpath(&path, wd, files[i]));
+               cl_git_pass(git_str_joinpath(&path, wd, files[i]));
                cl_git_pass(git_futils_readbuffer(&content, path.ptr));
                cl_assert_equal_s(before[i], content.ptr);
        }
@@ -74,17 +74,17 @@ void test_reset_hard__resetting_reverts_modified_files(void)
        cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL));
 
        for (i = 0; i < 4; ++i) {
-               cl_git_pass(git_buf_joinpath(&path, wd, files[i]));
+               cl_git_pass(git_str_joinpath(&path, wd, files[i]));
                if (after[i]) {
                        cl_git_pass(git_futils_readbuffer(&content, path.ptr));
                        cl_assert(strequal_ignore_eol(after[i], content.ptr));
                } else {
-                       cl_assert(!git_path_exists(path.ptr));
+                       cl_assert(!git_fs_path_exists(path.ptr));
                }
        }
 
-       git_buf_dispose(&content);
-       git_buf_dispose(&path);
+       git_str_dispose(&content);
+       git_str_dispose(&path);
 }
 
 void test_reset_hard__cannot_reset_in_a_bare_repository(void)
@@ -154,7 +154,7 @@ void test_reset_hard__resetting_reverts_unmerged(void)
                cl_git_pass(git_revparse_single(&target, repo, "26a125e"));
                cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL));
 
-               cl_assert(git_path_exists("status/conflicting_file") == 0);
+               cl_assert(git_fs_path_exists("status/conflicting_file") == 0);
 
                git_object_free(target);
                target = NULL;
@@ -165,42 +165,42 @@ void test_reset_hard__resetting_reverts_unmerged(void)
 
 void test_reset_hard__cleans_up_merge(void)
 {
-       git_buf merge_head_path = GIT_BUF_INIT,
-               merge_msg_path = GIT_BUF_INIT,
-               merge_mode_path = GIT_BUF_INIT,
-               orig_head_path = GIT_BUF_INIT;
+       git_str merge_head_path = GIT_STR_INIT,
+               merge_msg_path = GIT_STR_INIT,
+               merge_mode_path = GIT_STR_INIT,
+               orig_head_path = GIT_STR_INIT;
 
-       cl_git_pass(git_buf_joinpath(&merge_head_path, git_repository_path(repo), "MERGE_HEAD"));
-       cl_git_mkfile(git_buf_cstr(&merge_head_path), "beefbeefbeefbeefbeefbeefbeefbeefbeefbeef\n");
+       cl_git_pass(git_str_joinpath(&merge_head_path, git_repository_path(repo), "MERGE_HEAD"));
+       cl_git_mkfile(git_str_cstr(&merge_head_path), "beefbeefbeefbeefbeefbeefbeefbeefbeefbeef\n");
 
-       cl_git_pass(git_buf_joinpath(&merge_msg_path, git_repository_path(repo), "MERGE_MSG"));
-       cl_git_mkfile(git_buf_cstr(&merge_msg_path), "Merge commit 0017bd4ab1ec30440b17bae1680cff124ab5f1f6\n");
+       cl_git_pass(git_str_joinpath(&merge_msg_path, git_repository_path(repo), "MERGE_MSG"));
+       cl_git_mkfile(git_str_cstr(&merge_msg_path), "Merge commit 0017bd4ab1ec30440b17bae1680cff124ab5f1f6\n");
 
-       cl_git_pass(git_buf_joinpath(&merge_mode_path, git_repository_path(repo), "MERGE_MODE"));
-       cl_git_mkfile(git_buf_cstr(&merge_mode_path), "");
+       cl_git_pass(git_str_joinpath(&merge_mode_path, git_repository_path(repo), "MERGE_MODE"));
+       cl_git_mkfile(git_str_cstr(&merge_mode_path), "");
 
-       cl_git_pass(git_buf_joinpath(&orig_head_path, git_repository_path(repo), "ORIG_HEAD"));
-       cl_git_mkfile(git_buf_cstr(&orig_head_path), "0017bd4ab1ec30440b17bae1680cff124ab5f1f6");
+       cl_git_pass(git_str_joinpath(&orig_head_path, git_repository_path(repo), "ORIG_HEAD"));
+       cl_git_mkfile(git_str_cstr(&orig_head_path), "0017bd4ab1ec30440b17bae1680cff124ab5f1f6");
 
        cl_git_pass(git_revparse_single(&target, repo, "0017bd4"));
        cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL));
 
-       cl_assert(!git_path_exists(git_buf_cstr(&merge_head_path)));
-       cl_assert(!git_path_exists(git_buf_cstr(&merge_msg_path)));
-       cl_assert(!git_path_exists(git_buf_cstr(&merge_mode_path)));
+       cl_assert(!git_fs_path_exists(git_str_cstr(&merge_head_path)));
+       cl_assert(!git_fs_path_exists(git_str_cstr(&merge_msg_path)));
+       cl_assert(!git_fs_path_exists(git_str_cstr(&merge_mode_path)));
 
-       cl_assert(git_path_exists(git_buf_cstr(&orig_head_path)));
-       cl_git_pass(p_unlink(git_buf_cstr(&orig_head_path)));
+       cl_assert(git_fs_path_exists(git_str_cstr(&orig_head_path)));
+       cl_git_pass(p_unlink(git_str_cstr(&orig_head_path)));
 
-       git_buf_dispose(&merge_head_path);
-       git_buf_dispose(&merge_msg_path);
-       git_buf_dispose(&merge_mode_path);
-       git_buf_dispose(&orig_head_path);
+       git_str_dispose(&merge_head_path);
+       git_str_dispose(&merge_msg_path);
+       git_str_dispose(&merge_mode_path);
+       git_str_dispose(&orig_head_path);
 }
 
 void test_reset_hard__reflog_is_correct(void)
 {
-       git_buf buf = GIT_BUF_INIT;
+       git_str buf = GIT_STR_INIT;
        git_annotated_commit *annotated;
        const char *exp_msg = "commit: Add a file which name should appear before the "
                "\"subdir/\" folder while being dealt with by the treewalker";
@@ -218,12 +218,12 @@ void test_reset_hard__reflog_is_correct(void)
 
        /* Moved branch, expect id in message */
        cl_git_pass(git_revparse_single(&target, repo, "HEAD~^{commit}"));
-       cl_git_pass(git_buf_printf(&buf, "reset: moving to %s", git_oid_tostr_s(git_object_id(target))));
+       cl_git_pass(git_str_printf(&buf, "reset: moving to %s", git_oid_tostr_s(git_object_id(target))));
        cl_git_pass(git_reset(repo, target, GIT_RESET_HARD, NULL));
-       reflog_check(repo, "HEAD", 4, NULL, git_buf_cstr(&buf));
-       reflog_check(repo, "refs/heads/master", 4, NULL, git_buf_cstr(&buf));
+       reflog_check(repo, "HEAD", 4, NULL, git_str_cstr(&buf));
+       reflog_check(repo, "refs/heads/master", 4, NULL, git_str_cstr(&buf));
 
-       git_buf_dispose(&buf);
+       git_str_dispose(&buf);
 
        /* Moved branch, expect revspec in message */
        exp_msg = "reset: moving to HEAD~^{commit}";