]> git.proxmox.com Git - libgit2.git/blobdiff - tests/cherrypick/workdir.c
New upstream version 1.4.3+dfsg.1
[libgit2.git] / tests / cherrypick / workdir.c
index feacde323b97fc4c098d4690e3fefeb30c14aa8c..8fd1ecbdfa2d67c6c451363cdd242e670f604c27 100644 (file)
@@ -1,8 +1,7 @@
 #include "clar.h"
 #include "clar_libgit2.h"
 
-#include "buffer.h"
-#include "fileops.h"
+#include "futils.h"
 #include "git2/cherrypick.h"
 
 #include "../merge/merge_helpers.h"
@@ -12,7 +11,7 @@
 static git_repository *repo;
 static git_index *repo_index;
 
-// Fixture setup and teardown
+/* Fixture setup and teardown */
 void test_cherrypick_workdir__initialize(void)
 {
        repo = cl_git_sandbox_init(TEST_REPO_PATH);
@@ -66,14 +65,14 @@ void test_cherrypick_workdir__automerge(void)
                git_tree *cherrypicked_tree = NULL;
 
                cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
-               cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
+               cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL));
 
                git_oid_fromstr(&cherry_oid, cherrypick_oids[i]);
                cl_git_pass(git_commit_lookup(&commit, repo, &cherry_oid));
                cl_git_pass(git_cherrypick(repo, commit, NULL));
 
-               cl_assert(git_path_exists(TEST_REPO_PATH "/.git/CHERRY_PICK_HEAD"));
-               cl_assert(git_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG"));
+               cl_assert(git_fs_path_exists(TEST_REPO_PATH "/.git/CHERRY_PICK_HEAD"));
+               cl_assert(git_fs_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG"));
 
                cl_git_pass(git_index_write_tree(&cherrypicked_tree_oid, repo_index));
                cl_git_pass(git_tree_lookup(&cherrypicked_tree, repo, &cherrypicked_tree_oid));
@@ -115,10 +114,10 @@ void test_cherrypick_workdir__empty_result(void)
 
        /* Create an untracked file that should not conflict */
        cl_git_mkfile(TEST_REPO_PATH "/file4.txt", "");
-       cl_assert(git_path_exists(TEST_REPO_PATH "/file4.txt"));
+       cl_assert(git_fs_path_exists(TEST_REPO_PATH "/file4.txt"));
 
        cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
-       cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
+       cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL));
 
        git_oid_fromstr(&cherry_oid, cherrypick_oid);
        cl_git_pass(git_commit_lookup(&commit, repo, &cherry_oid));
@@ -140,7 +139,7 @@ void test_cherrypick_workdir__conflicts(void)
 {
        git_commit *head = NULL, *commit = NULL;
        git_oid head_oid, cherry_oid;
-       git_buf conflicting_buf = GIT_BUF_INIT, mergemsg_buf = GIT_BUF_INIT;
+       git_str conflicting_buf = GIT_STR_INIT, mergemsg_buf = GIT_STR_INIT;
 
        struct merge_index_entry merge_index_entries[] = {
                { 0100644, "242e7977ba73637822ffb265b46004b9b0e5153b", 0, "file1.txt" },
@@ -155,30 +154,30 @@ void test_cherrypick_workdir__conflicts(void)
        git_oid_fromstr(&head_oid, "bafbf6912c09505ac60575cd43d3f2aba3bd84d8");
 
        cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
-       cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
+       cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL));
 
        git_oid_fromstr(&cherry_oid, "e9b63f3655b2ad80c0ff587389b5a9589a3a7110");
        cl_git_pass(git_commit_lookup(&commit, repo, &cherry_oid));
        cl_git_pass(git_cherrypick(repo, commit, NULL));
 
-       cl_assert(git_path_exists(TEST_REPO_PATH "/.git/CHERRY_PICK_HEAD"));
-       cl_assert(git_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG"));
+       cl_assert(git_fs_path_exists(TEST_REPO_PATH "/.git/CHERRY_PICK_HEAD"));
+       cl_assert(git_fs_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG"));
 
        cl_assert(merge_test_index(repo_index, merge_index_entries, 7));
 
        cl_git_pass(git_futils_readbuffer(&mergemsg_buf,
                TEST_REPO_PATH "/.git/MERGE_MSG"));
-       cl_assert(strcmp(git_buf_cstr(&mergemsg_buf),
+       cl_assert(strcmp(git_str_cstr(&mergemsg_buf),
                "Change all files\n" \
                "\n" \
-               "Conflicts:\n" \
-               "\tfile2.txt\n" \
-               "\tfile3.txt\n") == 0);
+               "#Conflicts:\n" \
+               "#\tfile2.txt\n" \
+               "#\tfile3.txt\n") == 0);
 
        cl_git_pass(git_futils_readbuffer(&conflicting_buf,
                TEST_REPO_PATH "/file2.txt"));
 
-       cl_assert(strcmp(git_buf_cstr(&conflicting_buf),
+       cl_assert(strcmp(git_str_cstr(&conflicting_buf),
                "!File 2\n" \
                "File 2\n" \
                "File 2\n" \
@@ -204,7 +203,7 @@ void test_cherrypick_workdir__conflicts(void)
        cl_git_pass(git_futils_readbuffer(&conflicting_buf,
                TEST_REPO_PATH "/file3.txt"));
 
-       cl_assert(strcmp(git_buf_cstr(&conflicting_buf),
+       cl_assert(strcmp(git_str_cstr(&conflicting_buf),
                "!File 3\n" \
                "File 3\n" \
                "File 3\n" \
@@ -228,8 +227,8 @@ void test_cherrypick_workdir__conflicts(void)
 
        git_commit_free(commit);
        git_commit_free(head);
-       git_buf_free(&mergemsg_buf);
-       git_buf_free(&conflicting_buf);
+       git_str_dispose(&mergemsg_buf);
+       git_str_dispose(&conflicting_buf);
 }
 
 /* git reset --hard bafbf6912c09505ac60575cd43d3f2aba3bd84d8
@@ -263,7 +262,7 @@ void test_cherrypick_workdir__conflict_use_ours(void)
        git_oid_fromstr(&head_oid, "bafbf6912c09505ac60575cd43d3f2aba3bd84d8");
 
        cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
-       cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
+       cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL));
 
        git_oid_fromstr(&cherry_oid, "e9b63f3655b2ad80c0ff587389b5a9589a3a7110");
        cl_git_pass(git_commit_lookup(&commit, repo, &cherry_oid));
@@ -275,7 +274,7 @@ void test_cherrypick_workdir__conflict_use_ours(void)
        /* resolve conflicts in the index by taking "ours" */
        opts.merge_opts.file_favor = GIT_MERGE_FILE_FAVOR_OURS;
 
-       cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
+       cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL));
        cl_git_pass(git_cherrypick(repo, commit, &opts));
 
        cl_assert(merge_test_index(repo_index, merge_filesystem_entries, 3));
@@ -300,12 +299,12 @@ void test_cherrypick_workdir__rename(void)
                { 0100644, "28d9eb4208074ad1cc84e71ccc908b34573f05d2", 0, "file3.txt.renamed" },
        };
 
-       opts.merge_opts.flags |= GIT_MERGE_TREE_FIND_RENAMES;
+       opts.merge_opts.flags |= GIT_MERGE_FIND_RENAMES;
        opts.merge_opts.rename_threshold = 50;
 
        git_oid_fromstr(&head_oid, "cfc4f0999a8367568e049af4f72e452d40828a15");
        cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
-       cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
+       cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL));
 
        git_oid_fromstr(&cherry_oid, "2a26c7e88b285613b302ba76712bc998863f3cbc");
        cl_git_pass(git_commit_lookup(&commit, repo, &cherry_oid));
@@ -324,7 +323,7 @@ void test_cherrypick_workdir__both_renamed(void)
 {
        git_commit *head, *commit;
        git_oid head_oid, cherry_oid;
-       git_buf mergemsg_buf = GIT_BUF_INIT;
+       git_str mergemsg_buf = GIT_STR_INIT;
        git_cherrypick_options opts = GIT_CHERRYPICK_OPTIONS_INIT;
 
        struct merge_index_entry merge_index_entries[] = {
@@ -335,12 +334,12 @@ void test_cherrypick_workdir__both_renamed(void)
                { 0100644, "28d9eb4208074ad1cc84e71ccc908b34573f05d2", 2, "file3.txt.renamed_on_branch" },
        };
 
-       opts.merge_opts.flags |= GIT_MERGE_TREE_FIND_RENAMES;
+       opts.merge_opts.flags |= GIT_MERGE_FIND_RENAMES;
        opts.merge_opts.rename_threshold = 50;
 
        git_oid_fromstr(&head_oid, "44cd2ed2052c9c68f9a439d208e9614dc2a55c70");
        cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
-       cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
+       cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL));
 
        git_oid_fromstr(&cherry_oid, "2a26c7e88b285613b302ba76712bc998863f3cbc");
        cl_git_pass(git_commit_lookup(&commit, repo, &cherry_oid));
@@ -350,15 +349,15 @@ void test_cherrypick_workdir__both_renamed(void)
 
        cl_git_pass(git_futils_readbuffer(&mergemsg_buf,
                TEST_REPO_PATH "/.git/MERGE_MSG"));
-       cl_assert(strcmp(git_buf_cstr(&mergemsg_buf),
+       cl_assert(strcmp(git_str_cstr(&mergemsg_buf),
                "Renamed file3.txt -> file3.txt.renamed\n" \
                "\n" \
-               "Conflicts:\n" \
-               "\tfile3.txt\n" \
-               "\tfile3.txt.renamed\n" \
-               "\tfile3.txt.renamed_on_branch\n") == 0);
+               "#Conflicts:\n" \
+               "#\tfile3.txt\n" \
+               "#\tfile3.txt.renamed\n" \
+               "#\tfile3.txt.renamed_on_branch\n") == 0);
 
-       git_buf_free(&mergemsg_buf);
+       git_str_dispose(&mergemsg_buf);
        git_commit_free(commit);
        git_commit_free(head);
 }
@@ -370,12 +369,12 @@ void test_cherrypick_workdir__nonmerge_fails_mainline_specified(void)
        git_cherrypick_options opts = GIT_CHERRYPICK_OPTIONS_INIT;
 
        cl_git_pass(git_repository_head(&head, repo));
-       cl_git_pass(git_reference_peel((git_object **)&commit, head, GIT_OBJ_COMMIT));
+       cl_git_pass(git_reference_peel((git_object **)&commit, head, GIT_OBJECT_COMMIT));
 
        opts.mainline = 1;
        cl_must_fail(git_cherrypick(repo, commit, &opts));
-       cl_assert(!git_path_exists(TEST_REPO_PATH "/.git/CHERRY_PICK_HEAD"));
-       cl_assert(!git_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG"));
+       cl_assert(!git_fs_path_exists(TEST_REPO_PATH "/.git/CHERRY_PICK_HEAD"));
+       cl_assert(!git_fs_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG"));
 
        git_reference_free(head);
        git_commit_free(commit);
@@ -391,14 +390,14 @@ void test_cherrypick_workdir__merge_fails_without_mainline_specified(void)
 
        git_oid_fromstr(&head_oid, "cfc4f0999a8367568e049af4f72e452d40828a15");
        cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
-       cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
+       cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL));
 
        git_oid_fromstr(&cherry_oid, "abe4603bc7cd5b8167a267e0e2418fd2348f8cff");
        cl_git_pass(git_commit_lookup(&commit, repo, &cherry_oid));
 
        cl_must_fail(git_cherrypick(repo, commit, NULL));
-       cl_assert(!git_path_exists(TEST_REPO_PATH "/.git/CHERRY_PICK_HEAD"));
-       cl_assert(!git_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG"));
+       cl_assert(!git_fs_path_exists(TEST_REPO_PATH "/.git/CHERRY_PICK_HEAD"));
+       cl_assert(!git_fs_path_exists(TEST_REPO_PATH "/.git/MERGE_MSG"));
 
        git_commit_free(commit);
        git_commit_free(head);
@@ -423,7 +422,7 @@ void test_cherrypick_workdir__merge_first_parent(void)
 
        git_oid_fromstr(&head_oid, "cfc4f0999a8367568e049af4f72e452d40828a15");
        cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
-       cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
+       cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL));
 
        git_oid_fromstr(&cherry_oid, "abe4603bc7cd5b8167a267e0e2418fd2348f8cff");
        cl_git_pass(git_commit_lookup(&commit, repo, &cherry_oid));
@@ -455,7 +454,7 @@ void test_cherrypick_workdir__merge_second_parent(void)
 
        git_oid_fromstr(&head_oid, "cfc4f0999a8367568e049af4f72e452d40828a15");
        cl_git_pass(git_commit_lookup(&head, repo, &head_oid));
-       cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL, NULL));
+       cl_git_pass(git_reset(repo, (git_object *)head, GIT_RESET_HARD, NULL));
 
        git_oid_fromstr(&cherry_oid, "abe4603bc7cd5b8167a267e0e2418fd2348f8cff");
        cl_git_pass(git_commit_lookup(&commit, repo, &cherry_oid));