]> git.proxmox.com Git - libgit2.git/blobdiff - tests/merge/merge_helpers.c
New upstream version 1.4.3+dfsg.1
[libgit2.git] / tests / merge / merge_helpers.c
index f814714241034c58467176336bcea7ca232281cc..ce3cd229bb015c07a8c7063e60892289ad4f6200 100644 (file)
@@ -1,9 +1,10 @@
 #include "clar_libgit2.h"
-#include "fileops.h"
+#include "futils.h"
 #include "refs.h"
 #include "tree.h"
 #include "merge_helpers.h"
 #include "merge.h"
+#include "index.h"
 #include "git2/merge.h"
 #include "git2/sys/index.h"
 #include "git2/annotated_commit.h"
@@ -16,15 +17,15 @@ int merge_trees_from_branches(
        git_commit *our_commit, *their_commit, *ancestor_commit = NULL;
        git_tree *our_tree, *their_tree, *ancestor_tree = NULL;
        git_oid our_oid, their_oid, ancestor_oid;
-       git_buf branch_buf = GIT_BUF_INIT;
+       git_str branch_buf = GIT_STR_INIT;
        int error;
 
-       git_buf_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, ours_name);
+       git_str_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, ours_name);
        cl_git_pass(git_reference_name_to_id(&our_oid, repo, branch_buf.ptr));
        cl_git_pass(git_commit_lookup(&our_commit, repo, &our_oid));
 
-       git_buf_clear(&branch_buf);
-       git_buf_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, theirs_name);
+       git_str_clear(&branch_buf);
+       git_str_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, theirs_name);
        cl_git_pass(git_reference_name_to_id(&their_oid, repo, branch_buf.ptr));
        cl_git_pass(git_commit_lookup(&their_commit, repo, &their_oid));
 
@@ -40,9 +41,9 @@ int merge_trees_from_branches(
        cl_git_pass(git_commit_tree(&our_tree, our_commit));
        cl_git_pass(git_commit_tree(&their_tree, their_commit));
 
-       cl_git_pass(git_merge_trees(index, repo, ancestor_tree, our_tree, their_tree, opts));
+       error = git_merge_trees(index, repo, ancestor_tree, our_tree, their_tree, opts);
 
-       git_buf_free(&branch_buf);
+       git_str_dispose(&branch_buf);
        git_tree_free(our_tree);
        git_tree_free(their_tree);
        git_tree_free(ancestor_tree);
@@ -50,7 +51,7 @@ int merge_trees_from_branches(
        git_commit_free(their_commit);
        git_commit_free(ancestor_commit);
 
-       return 0;
+       return error;
 }
 
 int merge_commits_from_branches(
@@ -60,24 +61,25 @@ int merge_commits_from_branches(
 {
        git_commit *our_commit, *their_commit;
        git_oid our_oid, their_oid;
-       git_buf branch_buf = GIT_BUF_INIT;
+       git_str branch_buf = GIT_STR_INIT;
+       int error;
 
-       git_buf_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, ours_name);
+       git_str_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, ours_name);
        cl_git_pass(git_reference_name_to_id(&our_oid, repo, branch_buf.ptr));
        cl_git_pass(git_commit_lookup(&our_commit, repo, &our_oid));
 
-       git_buf_clear(&branch_buf);
-       git_buf_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, theirs_name);
+       git_str_clear(&branch_buf);
+       git_str_printf(&branch_buf, "%s%s", GIT_REFS_HEADS_DIR, theirs_name);
        cl_git_pass(git_reference_name_to_id(&their_oid, repo, branch_buf.ptr));
        cl_git_pass(git_commit_lookup(&their_commit, repo, &their_oid));
 
-       cl_git_pass(git_merge_commits(index, repo, our_commit, their_commit, opts));
+       error = git_merge_commits(index, repo, our_commit, their_commit, opts);
 
-       git_buf_free(&branch_buf);
+       git_str_dispose(&branch_buf);
        git_commit_free(our_commit);
        git_commit_free(their_commit);
 
-       return 0;
+       return error;
 }
 
 int merge_branches(git_repository *repo,
@@ -238,7 +240,7 @@ int merge_test_index(git_index *index, const struct merge_index_entry expected[]
        const git_index_entry *index_entry;
 
        /*
-       dump_index_entries(&index->entries);
+       merge__dump_index_entries(&index->entries);
        */
 
        if (git_index_entrycount(index) != expected_len)
@@ -326,12 +328,12 @@ int merge_test_reuc(git_index *index, const struct merge_reuc_entry expected[],
        return 1;
 }
 
-int dircount(void *payload, git_buf *pathbuf)
+static int dircount(void *payload, git_str *pathbuf)
 {
        size_t *entries = payload;
-       size_t len = git_buf_len(pathbuf);
+       size_t len = git_str_len(pathbuf);
 
-       if (len < 5 || strcmp(pathbuf->ptr + (git_buf_len(pathbuf) - 5), "/.git") != 0)
+       if (len < 5 || strcmp(pathbuf->ptr + (git_str_len(pathbuf) - 5), "/.git") != 0)
                (*entries)++;
 
        return 0;
@@ -341,23 +343,23 @@ int merge_test_workdir(git_repository *repo, const struct merge_index_entry expe
 {
        size_t actual_len = 0, i;
        git_oid actual_oid, expected_oid;
-       git_buf wd = GIT_BUF_INIT;
+       git_str wd = GIT_STR_INIT;
 
-       git_buf_puts(&wd, repo->workdir);
-       git_path_direach(&wd, 0, dircount, &actual_len);
+       git_str_puts(&wd, repo->workdir);
+       git_fs_path_direach(&wd, 0, dircount, &actual_len);
 
        if (actual_len != expected_len)
                return 0;
 
        for (i = 0; i < expected_len; i++) {
-               git_blob_create_fromworkdir(&actual_oid, repo, expected[i].path);
+               git_blob_create_from_workdir(&actual_oid, repo, expected[i].path);
                git_oid_fromstr(&expected_oid, expected[i].oid_str);
 
                if (git_oid_cmp(&actual_oid, &expected_oid) != 0)
                        return 0;
        }
 
-       git_buf_free(&wd);
+       git_str_dispose(&wd);
 
        return 1;
 }