mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-06 09:41:04 +00:00
Change signature of git_merge
to take merge and checkout opts
This commit is contained in:
parent
1c0b6a38ba
commit
02105a27f0
@ -274,32 +274,6 @@ GIT_EXTERN(int) git_merge_status(
|
||||
const git_merge_head **their_heads,
|
||||
size_t their_heads_len);
|
||||
|
||||
typedef struct {
|
||||
unsigned int version;
|
||||
|
||||
/** Options for handling the merges of individual files. */
|
||||
git_merge_tree_opts merge_tree_opts;
|
||||
|
||||
/** Options for writing the merge result to the working directory. */
|
||||
git_checkout_options checkout_opts;
|
||||
} git_merge_opts;
|
||||
|
||||
#define GIT_MERGE_OPTS_VERSION 1
|
||||
#define GIT_MERGE_OPTS_INIT {GIT_MERGE_OPTS_VERSION, GIT_MERGE_TREE_OPTS_INIT, GIT_CHECKOUT_OPTIONS_INIT}
|
||||
|
||||
/**
|
||||
* Initializes a `git_merge_opts` with default values. Equivalent to creating
|
||||
* an instance with GIT_MERGE_OPTS_INIT.
|
||||
*
|
||||
* @param opts the `git_merge_opts` instance to initialize.
|
||||
* @param version the version of the struct; you should pass
|
||||
* `GIT_MERGE_OPTS_VERSION` here.
|
||||
* @return Zero on success; -1 on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_merge_init_opts(
|
||||
git_merge_opts* opts,
|
||||
int version);
|
||||
|
||||
/**
|
||||
* Find a merge base between two commits
|
||||
*
|
||||
@ -522,7 +496,8 @@ GIT_EXTERN(int) git_merge_commits(
|
||||
* @param repo the repository to merge
|
||||
* @param merge_heads the heads to merge into
|
||||
* @param merge_heads_len the number of heads to merge
|
||||
* @param opts merge options
|
||||
* @param checkout_opts merge options
|
||||
* @param checkout_opts checkout options
|
||||
* @return 0 on success or error code
|
||||
*/
|
||||
GIT_EXTERN(int) git_merge(
|
||||
@ -530,7 +505,8 @@ GIT_EXTERN(int) git_merge(
|
||||
git_repository *repo,
|
||||
const git_merge_head **their_heads,
|
||||
size_t their_heads_len,
|
||||
const git_merge_opts *opts);
|
||||
const git_merge_tree_opts *merge_opts,
|
||||
const git_checkout_options *checkout_opts);
|
||||
|
||||
/**
|
||||
* Returns true if a merge is "up-to-date", meaning that the commit(s)
|
||||
|
64
src/merge.c
64
src/merge.c
@ -2168,10 +2168,10 @@ const char *merge_their_label(const char *branchname)
|
||||
return slash+1;
|
||||
}
|
||||
|
||||
static int merge_normalize_opts(
|
||||
static int merge_normalize_checkout_opts(
|
||||
git_repository *repo,
|
||||
git_merge_opts *opts,
|
||||
const git_merge_opts *given,
|
||||
git_checkout_options *checkout_opts,
|
||||
const git_checkout_options *given_checkout_opts,
|
||||
const git_merge_head *ancestor_head,
|
||||
const git_merge_head *our_head,
|
||||
size_t their_heads_len,
|
||||
@ -2183,38 +2183,38 @@ static int merge_normalize_opts(
|
||||
|
||||
GIT_UNUSED(repo);
|
||||
|
||||
if (given != NULL)
|
||||
memcpy(opts, given, sizeof(git_merge_opts));
|
||||
if (given_checkout_opts != NULL)
|
||||
memcpy(checkout_opts, given_checkout_opts, sizeof(git_checkout_options));
|
||||
else {
|
||||
git_merge_opts default_opts = GIT_MERGE_OPTS_INIT;
|
||||
memcpy(opts, &default_opts, sizeof(git_merge_opts));
|
||||
git_checkout_options default_checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
|
||||
memcpy(checkout_opts, &default_checkout_opts, sizeof(git_checkout_options));
|
||||
}
|
||||
|
||||
if (!opts->checkout_opts.checkout_strategy)
|
||||
opts->checkout_opts.checkout_strategy = default_checkout_strategy;
|
||||
if (!checkout_opts->checkout_strategy)
|
||||
checkout_opts->checkout_strategy = default_checkout_strategy;
|
||||
|
||||
/* TODO: for multiple ancestors in merge-recursive, this is "merged common ancestors" */
|
||||
if (!opts->checkout_opts.ancestor_label) {
|
||||
if (!checkout_opts->ancestor_label) {
|
||||
if (ancestor_head && ancestor_head->commit)
|
||||
opts->checkout_opts.ancestor_label = git_commit_summary(ancestor_head->commit);
|
||||
checkout_opts->ancestor_label = git_commit_summary(ancestor_head->commit);
|
||||
else
|
||||
opts->checkout_opts.ancestor_label = "ancestor";
|
||||
checkout_opts->ancestor_label = "ancestor";
|
||||
}
|
||||
|
||||
if (!opts->checkout_opts.our_label) {
|
||||
if (!checkout_opts->our_label) {
|
||||
if (our_head && our_head->ref_name)
|
||||
opts->checkout_opts.our_label = our_head->ref_name;
|
||||
checkout_opts->our_label = our_head->ref_name;
|
||||
else
|
||||
opts->checkout_opts.our_label = "ours";
|
||||
checkout_opts->our_label = "ours";
|
||||
}
|
||||
|
||||
if (!opts->checkout_opts.their_label) {
|
||||
if (!checkout_opts->their_label) {
|
||||
if (their_heads_len == 1 && their_heads[0]->ref_name)
|
||||
opts->checkout_opts.their_label = merge_their_label(their_heads[0]->ref_name);
|
||||
checkout_opts->their_label = merge_their_label(their_heads[0]->ref_name);
|
||||
else if (their_heads_len == 1)
|
||||
opts->checkout_opts.their_label = their_heads[0]->oid_str;
|
||||
checkout_opts->their_label = their_heads[0]->oid_str;
|
||||
else
|
||||
opts->checkout_opts.their_label = "theirs";
|
||||
checkout_opts->their_label = "theirs";
|
||||
}
|
||||
|
||||
return error;
|
||||
@ -2552,11 +2552,12 @@ int git_merge(
|
||||
git_repository *repo,
|
||||
const git_merge_head **their_heads,
|
||||
size_t their_heads_len,
|
||||
const git_merge_opts *given_opts)
|
||||
const git_merge_tree_opts *merge_opts,
|
||||
const git_checkout_options *given_checkout_opts)
|
||||
{
|
||||
git_merge_result *result;
|
||||
git_merge_opts opts;
|
||||
git_reference *our_ref = NULL;
|
||||
git_checkout_options checkout_opts;
|
||||
git_merge_head *ancestor_head = NULL, *our_head = NULL;
|
||||
git_tree *ancestor_tree = NULL, *our_tree = NULL, **their_trees = NULL;
|
||||
git_index *index_new = NULL, *index_repo = NULL;
|
||||
@ -2567,8 +2568,6 @@ int git_merge(
|
||||
|
||||
*out = NULL;
|
||||
|
||||
GITERR_CHECK_VERSION(given_opts, GIT_MERGE_OPTS_VERSION, "git_merge_opts");
|
||||
|
||||
if (their_heads_len != 1) {
|
||||
giterr_set(GITERR_MERGE, "Can only merge a single branch");
|
||||
return -1;
|
||||
@ -2583,7 +2582,8 @@ int git_merge(
|
||||
if ((error = merge_heads(&ancestor_head, &our_head, repo, their_heads, their_heads_len)) < 0)
|
||||
goto on_error;
|
||||
|
||||
if ((error = merge_normalize_opts(repo, &opts, given_opts, ancestor_head, our_head, their_heads_len, their_heads)) < 0)
|
||||
if ((error = merge_normalize_checkout_opts(repo, &checkout_opts, given_checkout_opts,
|
||||
ancestor_head, our_head, their_heads_len, their_heads)) < 0)
|
||||
goto on_error;
|
||||
|
||||
/* Write the merge files to the repository. */
|
||||
@ -2604,10 +2604,10 @@ int git_merge(
|
||||
|
||||
/* TODO: recursive, octopus, etc... */
|
||||
|
||||
if ((error = git_merge_trees(&index_new, repo, ancestor_tree, our_tree, their_trees[0], &opts.merge_tree_opts)) < 0 ||
|
||||
if ((error = git_merge_trees(&index_new, repo, ancestor_tree, our_tree, their_trees[0], merge_opts)) < 0 ||
|
||||
(error = git_merge__indexes(repo, index_new)) < 0 ||
|
||||
(error = git_repository_index(&index_repo, repo)) < 0 ||
|
||||
(error = git_checkout_index(repo, index_repo, &opts.checkout_opts)) < 0)
|
||||
(error = git_checkout_index(repo, index_repo, &checkout_opts)) < 0)
|
||||
goto on_error;
|
||||
|
||||
result->index = index_new;
|
||||
@ -2779,18 +2779,6 @@ void git_merge_head_free(git_merge_head *head)
|
||||
git__free(head);
|
||||
}
|
||||
|
||||
int git_merge_init_opts(git_merge_opts* opts, int version)
|
||||
{
|
||||
if (version != GIT_MERGE_OPTS_VERSION) {
|
||||
giterr_set(GITERR_INVALID, "Invalid version %d for git_merge_opts", version);
|
||||
return -1;
|
||||
} else {
|
||||
git_merge_opts o = GIT_MERGE_OPTS_INIT;
|
||||
memcpy(opts, &o, sizeof(o));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int git_merge_tree_init_opts(git_merge_tree_opts* opts, int version)
|
||||
{
|
||||
if (version != GIT_MERGE_TREE_OPTS_VERSION) {
|
||||
|
@ -79,7 +79,9 @@ int merge_commits_from_branches(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int merge_branches(git_merge_result **result, git_repository *repo, const char *ours_branch, const char *theirs_branch, git_merge_opts *opts)
|
||||
int merge_branches(git_merge_result **result, git_repository *repo,
|
||||
const char *ours_branch, const char *theirs_branch,
|
||||
git_merge_tree_opts *merge_opts, git_checkout_options *checkout_opts)
|
||||
{
|
||||
git_reference *head_ref, *theirs_ref;
|
||||
git_merge_head *theirs_head;
|
||||
@ -93,7 +95,7 @@ int merge_branches(git_merge_result **result, git_repository *repo, const char *
|
||||
cl_git_pass(git_reference_lookup(&theirs_ref, repo, theirs_branch));
|
||||
cl_git_pass(git_merge_head_from_ref(&theirs_head, repo, theirs_ref));
|
||||
|
||||
cl_git_pass(git_merge(result, repo, (const git_merge_head **)&theirs_head, 1, opts));
|
||||
cl_git_pass(git_merge(result, repo, (const git_merge_head **)&theirs_head, 1, merge_opts, checkout_opts));
|
||||
|
||||
git_reference_free(head_ref);
|
||||
git_reference_free(theirs_ref);
|
||||
|
@ -93,7 +93,8 @@ int merge_commits_from_branches(
|
||||
git_merge_tree_opts *opts);
|
||||
|
||||
int merge_branches(git_merge_result **result, git_repository *repo,
|
||||
const char *ours_branch, const char *theirs_branch, git_merge_opts *opts);
|
||||
const char *ours_branch, const char *theirs_branch,
|
||||
git_merge_tree_opts *merge_opts, git_checkout_options *checkout_opts);
|
||||
|
||||
int merge_test_diff_list(git_merge_diff_list *diff_list, const struct merge_index_entry expected[], size_t expected_len);
|
||||
|
||||
|
@ -90,15 +90,16 @@ static int merge_branch(git_merge_result **result, int merge_file_favor, int che
|
||||
{
|
||||
git_oid their_oids[1];
|
||||
git_merge_head *their_heads[1];
|
||||
git_merge_opts opts = GIT_MERGE_OPTS_INIT;
|
||||
git_merge_tree_opts merge_opts = GIT_MERGE_TREE_OPTS_INIT;
|
||||
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
|
||||
int error;
|
||||
|
||||
cl_git_pass(git_oid_fromstr(&their_oids[0], MERGE_BRANCH_OID));
|
||||
cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &their_oids[0]));
|
||||
|
||||
opts.merge_tree_opts.file_favor = merge_file_favor;
|
||||
opts.checkout_opts.checkout_strategy = checkout_strategy;
|
||||
error = git_merge(result, repo, (const git_merge_head **)their_heads, 1, &opts);
|
||||
merge_opts.file_favor = merge_file_favor;
|
||||
checkout_opts.checkout_strategy = checkout_strategy;
|
||||
error = git_merge(result, repo, (const git_merge_head **)their_heads, 1, &merge_opts, &checkout_opts);
|
||||
|
||||
git_merge_head_free(their_heads[0]);
|
||||
|
||||
|
@ -35,7 +35,7 @@ void test_merge_workdir_renames__cleanup(void)
|
||||
void test_merge_workdir_renames__renames(void)
|
||||
{
|
||||
git_merge_result *result;
|
||||
git_merge_opts opts = GIT_MERGE_OPTS_INIT;
|
||||
git_merge_tree_opts merge_opts = GIT_MERGE_TREE_OPTS_INIT;
|
||||
|
||||
struct merge_index_entry merge_index_entries[] = {
|
||||
{ 0100644, "68c6c84b091926c7d90aa6a79b2bc3bb6adccd8e", 0, "0a-no-change.txt" },
|
||||
@ -64,10 +64,10 @@ void test_merge_workdir_renames__renames(void)
|
||||
{ 0100644, "b69fe837e4cecfd4c9a40cdca7c138468687df07", 0, "7-both-renamed.txt~rename_conflict_theirs" },
|
||||
};
|
||||
|
||||
opts.merge_tree_opts.flags |= GIT_MERGE_TREE_FIND_RENAMES;
|
||||
opts.merge_tree_opts.rename_threshold = 50;
|
||||
merge_opts.flags |= GIT_MERGE_TREE_FIND_RENAMES;
|
||||
merge_opts.rename_threshold = 50;
|
||||
|
||||
cl_git_pass(merge_branches(&result, repo, GIT_REFS_HEADS_DIR BRANCH_RENAME_OURS, GIT_REFS_HEADS_DIR BRANCH_RENAME_THEIRS, &opts));
|
||||
cl_git_pass(merge_branches(&result, repo, GIT_REFS_HEADS_DIR BRANCH_RENAME_OURS, GIT_REFS_HEADS_DIR BRANCH_RENAME_THEIRS, &merge_opts, NULL));
|
||||
cl_assert(merge_test_workdir(repo, merge_index_entries, 24));
|
||||
|
||||
git_merge_result_free(result);
|
||||
@ -77,7 +77,8 @@ void test_merge_workdir_renames__ours(void)
|
||||
{
|
||||
git_index *index;
|
||||
git_merge_result *result;
|
||||
git_merge_opts opts = GIT_MERGE_OPTS_INIT;
|
||||
git_merge_tree_opts merge_opts = GIT_MERGE_TREE_OPTS_INIT;
|
||||
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
|
||||
|
||||
struct merge_index_entry merge_index_entries[] = {
|
||||
{ 0100644, "68c6c84b091926c7d90aa6a79b2bc3bb6adccd8e", 0, "0a-no-change.txt" },
|
||||
@ -102,11 +103,11 @@ void test_merge_workdir_renames__ours(void)
|
||||
{ 0100644, "b42712cfe99a1a500b2a51fe984e0b8a7702ba11", 0, "7-both-renamed.txt" },
|
||||
};
|
||||
|
||||
opts.merge_tree_opts.flags |= GIT_MERGE_TREE_FIND_RENAMES;
|
||||
opts.merge_tree_opts.rename_threshold = 50;
|
||||
opts.checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_USE_OURS;
|
||||
merge_opts.flags |= GIT_MERGE_TREE_FIND_RENAMES;
|
||||
merge_opts.rename_threshold = 50;
|
||||
checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE | GIT_CHECKOUT_USE_OURS;
|
||||
|
||||
cl_git_pass(merge_branches(&result, repo, GIT_REFS_HEADS_DIR BRANCH_RENAME_OURS, GIT_REFS_HEADS_DIR BRANCH_RENAME_THEIRS, &opts));
|
||||
cl_git_pass(merge_branches(&result, repo, GIT_REFS_HEADS_DIR BRANCH_RENAME_OURS, GIT_REFS_HEADS_DIR BRANCH_RENAME_THEIRS, &merge_opts, &checkout_opts));
|
||||
cl_git_pass(git_repository_index(&index, repo));
|
||||
cl_git_pass(git_index_write(index));
|
||||
cl_assert(merge_test_workdir(repo, merge_index_entries, 20));
|
||||
@ -118,7 +119,7 @@ void test_merge_workdir_renames__ours(void)
|
||||
void test_merge_workdir_renames__similar(void)
|
||||
{
|
||||
git_merge_result *result;
|
||||
git_merge_opts opts = GIT_MERGE_OPTS_INIT;
|
||||
git_merge_tree_opts merge_opts = GIT_MERGE_TREE_OPTS_INIT;
|
||||
|
||||
/*
|
||||
* Note: this differs slightly from the core git merge result - there, 4a is
|
||||
@ -152,10 +153,10 @@ void test_merge_workdir_renames__similar(void)
|
||||
{ 0100644, "b69fe837e4cecfd4c9a40cdca7c138468687df07", 0, "7-both-renamed.txt~rename_conflict_theirs" },
|
||||
};
|
||||
|
||||
opts.merge_tree_opts.flags |= GIT_MERGE_TREE_FIND_RENAMES;
|
||||
opts.merge_tree_opts.rename_threshold = 50;
|
||||
merge_opts.flags |= GIT_MERGE_TREE_FIND_RENAMES;
|
||||
merge_opts.rename_threshold = 50;
|
||||
|
||||
cl_git_pass(merge_branches(&result, repo, GIT_REFS_HEADS_DIR BRANCH_RENAME_OURS, GIT_REFS_HEADS_DIR BRANCH_RENAME_THEIRS, &opts));
|
||||
cl_git_pass(merge_branches(&result, repo, GIT_REFS_HEADS_DIR BRANCH_RENAME_OURS, GIT_REFS_HEADS_DIR BRANCH_RENAME_THEIRS, &merge_opts, NULL));
|
||||
cl_assert(merge_test_workdir(repo, merge_index_entries, 24));
|
||||
|
||||
git_merge_result_free(result);
|
||||
|
@ -970,7 +970,6 @@ void test_merge_workdir_setup__retained_after_success(void)
|
||||
git_oid our_oid;
|
||||
git_reference *octo1_ref;
|
||||
git_merge_head *our_head, *their_heads[1];
|
||||
git_merge_opts opts = GIT_MERGE_OPTS_INIT;
|
||||
git_merge_result *result;
|
||||
|
||||
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
|
||||
@ -980,7 +979,7 @@ void test_merge_workdir_setup__retained_after_success(void)
|
||||
|
||||
cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, octo1_ref));
|
||||
|
||||
cl_git_pass(git_merge(&result, repo, (const git_merge_head **)&their_heads[0], 1, &opts));
|
||||
cl_git_pass(git_merge(&result, repo, (const git_merge_head **)&their_heads[0], 1, NULL, NULL));
|
||||
|
||||
cl_assert(test_file_contents(GIT_MERGE_HEAD_FILE, OCTO1_OID "\n"));
|
||||
cl_assert(test_file_contents(GIT_ORIG_HEAD_FILE, ORIG_HEAD "\n"));
|
||||
@ -1000,7 +999,6 @@ void test_merge_workdir_setup__removed_after_failure(void)
|
||||
git_reference *octo1_ref;
|
||||
git_merge_head *our_head, *their_heads[1];
|
||||
git_merge_result *result;
|
||||
git_merge_opts opts = GIT_MERGE_OPTS_INIT;
|
||||
|
||||
cl_git_pass(git_oid_fromstr(&our_oid, ORIG_HEAD));
|
||||
cl_git_pass(git_merge_head_from_id(&our_head, repo, &our_oid));
|
||||
@ -1012,7 +1010,7 @@ void test_merge_workdir_setup__removed_after_failure(void)
|
||||
"Conflicting file!\n\nMerge will fail!\n");
|
||||
|
||||
cl_git_fail(git_merge(
|
||||
&result, repo, (const git_merge_head **)&their_heads[0], 1, &opts));
|
||||
&result, repo, (const git_merge_head **)&their_heads[0], 1, NULL, NULL));
|
||||
|
||||
cl_assert(!git_path_exists("merge-resolve/" GIT_MERGE_HEAD_FILE));
|
||||
cl_assert(!git_path_exists("merge-resolve/" GIT_ORIG_HEAD_FILE));
|
||||
|
@ -97,14 +97,15 @@ static git_merge_result *merge_simple_branch(int merge_file_favor, int checkout_
|
||||
git_oid their_oids[1];
|
||||
git_merge_head *their_heads[1];
|
||||
git_merge_result *result;
|
||||
git_merge_opts opts = GIT_MERGE_OPTS_INIT;
|
||||
git_merge_tree_opts merge_opts = GIT_MERGE_TREE_OPTS_INIT;
|
||||
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
|
||||
|
||||
cl_git_pass(git_oid_fromstr(&their_oids[0], THEIRS_SIMPLE_OID));
|
||||
cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &their_oids[0]));
|
||||
|
||||
opts.merge_tree_opts.file_favor = merge_file_favor;
|
||||
opts.checkout_opts.checkout_strategy = checkout_strategy;
|
||||
cl_git_pass(git_merge(&result, repo, (const git_merge_head **)their_heads, 1, &opts));
|
||||
merge_opts.file_favor = merge_file_favor;
|
||||
checkout_opts.checkout_strategy = checkout_strategy;
|
||||
cl_git_pass(git_merge(&result, repo, (const git_merge_head **)their_heads, 1, &merge_opts, &checkout_opts));
|
||||
|
||||
git_merge_head_free(their_heads[0]);
|
||||
|
||||
@ -522,7 +523,7 @@ void test_merge_workdir_simple__directory_file(void)
|
||||
git_oid their_oids[1], head_commit_id;
|
||||
git_merge_head *their_heads[1];
|
||||
git_merge_result *result;
|
||||
git_merge_opts opts = GIT_MERGE_OPTS_INIT;
|
||||
git_merge_tree_opts merge_opts = GIT_MERGE_TREE_OPTS_INIT;
|
||||
git_commit *head_commit;
|
||||
|
||||
struct merge_index_entry merge_index_entries[] = {
|
||||
@ -556,8 +557,8 @@ void test_merge_workdir_simple__directory_file(void)
|
||||
cl_git_pass(git_oid_fromstr(&their_oids[0], THEIRS_DIRECTORY_FILE));
|
||||
cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &their_oids[0]));
|
||||
|
||||
opts.merge_tree_opts.file_favor = 0;
|
||||
cl_git_pass(git_merge(&result, repo, (const git_merge_head **)their_heads, 1, &opts));
|
||||
merge_opts.file_favor = 0;
|
||||
cl_git_pass(git_merge(&result, repo, (const git_merge_head **)their_heads, 1, &merge_opts, NULL));
|
||||
|
||||
cl_assert(merge_test_index(repo_index, merge_index_entries, 20));
|
||||
|
||||
@ -572,7 +573,7 @@ void test_merge_workdir_simple__unrelated(void)
|
||||
git_oid their_oids[1];
|
||||
git_merge_head *their_heads[1];
|
||||
git_merge_result *result;
|
||||
git_merge_opts opts = GIT_MERGE_OPTS_INIT;
|
||||
git_merge_tree_opts merge_opts = GIT_MERGE_TREE_OPTS_INIT;
|
||||
|
||||
struct merge_index_entry merge_index_entries[] = {
|
||||
{ 0100644, "233c0919c998ed110a4b6ff36f353aec8b713487", 0, "added-in-master.txt" },
|
||||
@ -589,8 +590,8 @@ void test_merge_workdir_simple__unrelated(void)
|
||||
cl_git_pass(git_oid_fromstr(&their_oids[0], THEIRS_UNRELATED_PARENT));
|
||||
cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &their_oids[0]));
|
||||
|
||||
opts.merge_tree_opts.file_favor = 0;
|
||||
cl_git_pass(git_merge(&result, repo, (const git_merge_head **)their_heads, 1, &opts));
|
||||
merge_opts.file_favor = 0;
|
||||
cl_git_pass(git_merge(&result, repo, (const git_merge_head **)their_heads, 1, &merge_opts, NULL));
|
||||
|
||||
cl_assert(merge_test_index(repo_index, merge_index_entries, 9));
|
||||
|
||||
@ -603,7 +604,7 @@ void test_merge_workdir_simple__unrelated_with_conflicts(void)
|
||||
git_oid their_oids[1];
|
||||
git_merge_head *their_heads[1];
|
||||
git_merge_result *result;
|
||||
git_merge_opts opts = GIT_MERGE_OPTS_INIT;
|
||||
git_merge_tree_opts merge_opts = GIT_MERGE_TREE_OPTS_INIT;
|
||||
|
||||
struct merge_index_entry merge_index_entries[] = {
|
||||
{ 0100644, "233c0919c998ed110a4b6ff36f353aec8b713487", 0, "added-in-master.txt" },
|
||||
@ -622,8 +623,8 @@ void test_merge_workdir_simple__unrelated_with_conflicts(void)
|
||||
cl_git_pass(git_oid_fromstr(&their_oids[0], THEIRS_UNRELATED_OID));
|
||||
cl_git_pass(git_merge_head_from_id(&their_heads[0], repo, &their_oids[0]));
|
||||
|
||||
opts.merge_tree_opts.file_favor = 0;
|
||||
cl_git_pass(git_merge(&result, repo, (const git_merge_head **)their_heads, 1, &opts));
|
||||
merge_opts.file_favor = 0;
|
||||
cl_git_pass(git_merge(&result, repo, (const git_merge_head **)their_heads, 1, &merge_opts, NULL));
|
||||
|
||||
cl_assert(merge_test_index(repo_index, merge_index_entries, 11));
|
||||
|
||||
@ -638,7 +639,6 @@ void test_merge_workdir_simple__binary(void)
|
||||
git_merge_head *their_head;
|
||||
git_merge_result *result;
|
||||
const git_index_entry *binary_entry;
|
||||
git_merge_opts opts = GIT_MERGE_OPTS_INIT;
|
||||
|
||||
struct merge_index_entry merge_index_entries[] = {
|
||||
{ 0100644, "1c51d885170f57a0c4e8c69ff6363d91a5b51f85", 1, "binary" },
|
||||
@ -654,7 +654,7 @@ void test_merge_workdir_simple__binary(void)
|
||||
|
||||
cl_git_pass(git_merge_head_from_id(&their_head, repo, &their_oid));
|
||||
|
||||
cl_git_pass(git_merge(&result, repo, (const git_merge_head **)&their_head, 1, &opts));
|
||||
cl_git_pass(git_merge(&result, repo, (const git_merge_head **)&their_head, 1, NULL, NULL));
|
||||
|
||||
cl_assert(merge_test_index(repo_index, merge_index_entries, 3));
|
||||
|
||||
|
@ -32,7 +32,6 @@ void test_merge_workdir_submodules__automerge(void)
|
||||
git_commit *our_commit;
|
||||
git_merge_head *their_head;
|
||||
git_merge_result *result;
|
||||
git_merge_opts opts = GIT_MERGE_OPTS_INIT;
|
||||
git_index *index;
|
||||
|
||||
struct merge_index_entry merge_index_entries[] = {
|
||||
@ -51,7 +50,7 @@ void test_merge_workdir_submodules__automerge(void)
|
||||
cl_git_pass(git_reference_lookup(&their_ref, repo, "refs/heads/" SUBMODULE_OTHER_BRANCH));
|
||||
cl_git_pass(git_merge_head_from_ref(&their_head, repo, their_ref));
|
||||
|
||||
cl_git_pass(git_merge(&result, repo, (const git_merge_head **)&their_head, 1, &opts));
|
||||
cl_git_pass(git_merge(&result, repo, (const git_merge_head **)&their_head, 1, NULL, NULL));
|
||||
|
||||
cl_git_pass(git_repository_index(&index, repo));
|
||||
cl_assert(merge_test_index(index, merge_index_entries, 6));
|
||||
@ -70,7 +69,6 @@ void test_merge_workdir_submodules__take_changed(void)
|
||||
git_commit *our_commit;
|
||||
git_merge_head *their_head;
|
||||
git_merge_result *result;
|
||||
git_merge_opts opts = GIT_MERGE_OPTS_INIT;
|
||||
git_index *index;
|
||||
|
||||
struct merge_index_entry merge_index_entries[] = {
|
||||
@ -87,7 +85,7 @@ void test_merge_workdir_submodules__take_changed(void)
|
||||
cl_git_pass(git_reference_lookup(&their_ref, repo, "refs/heads/" SUBMODULE_OTHER2_BRANCH));
|
||||
cl_git_pass(git_merge_head_from_ref(&their_head, repo, their_ref));
|
||||
|
||||
cl_git_pass(git_merge(&result, repo, (const git_merge_head **)&their_head, 1, &opts));
|
||||
cl_git_pass(git_merge(&result, repo, (const git_merge_head **)&their_head, 1, NULL, NULL));
|
||||
|
||||
cl_git_pass(git_repository_index(&index, repo));
|
||||
cl_assert(merge_test_index(index, merge_index_entries, 4));
|
||||
|
@ -34,7 +34,6 @@ static int merge_trivial(const char *ours, const char *theirs)
|
||||
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
|
||||
git_reference *our_ref, *their_ref;
|
||||
git_merge_head *their_heads[1];
|
||||
git_merge_opts opts = GIT_MERGE_OPTS_INIT;
|
||||
git_merge_result *result;
|
||||
|
||||
checkout_opts.checkout_strategy = GIT_CHECKOUT_FORCE;
|
||||
@ -49,7 +48,7 @@ static int merge_trivial(const char *ours, const char *theirs)
|
||||
cl_git_pass(git_reference_lookup(&their_ref, repo, branch_buf.ptr));
|
||||
cl_git_pass(git_merge_head_from_ref(&their_heads[0], repo, their_ref));
|
||||
|
||||
cl_git_pass(git_merge(&result, repo, (const git_merge_head **)their_heads, 1, &opts));
|
||||
cl_git_pass(git_merge(&result, repo, (const git_merge_head **)their_heads, 1, NULL, NULL));
|
||||
|
||||
git_buf_free(&branch_buf);
|
||||
git_reference_free(our_ref);
|
||||
|
@ -80,11 +80,6 @@ void test_structinit_structinit__compare(void)
|
||||
git_merge_tree_opts, GIT_MERGE_TREE_OPTS_VERSION, \
|
||||
GIT_MERGE_TREE_OPTS_INIT, git_merge_tree_init_opts);
|
||||
|
||||
/* merge */
|
||||
CHECK_MACRO_FUNC_INIT_EQUAL( \
|
||||
git_merge_opts, GIT_MERGE_OPTS_VERSION, \
|
||||
GIT_MERGE_OPTS_INIT, git_merge_init_opts);
|
||||
|
||||
/* push */
|
||||
CHECK_MACRO_FUNC_INIT_EQUAL( \
|
||||
git_push_options, GIT_PUSH_OPTIONS_VERSION, \
|
||||
|
Loading…
Reference in New Issue
Block a user