#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"
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);
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));
/* 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));
{
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" },
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" \
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" \
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
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));
/* 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));
{ 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));
{
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[] = {
{ 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));
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);
}
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);
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);
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));
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));