Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'tests/merge/merge_helpers.c')
-rw-r--r--tests/merge/merge_helpers.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/merge/merge_helpers.c b/tests/merge/merge_helpers.c
index 43619be0d..7ca1e6522 100644
--- a/tests/merge/merge_helpers.c
+++ b/tests/merge/merge_helpers.c
@@ -52,6 +52,34 @@ int merge_trees_from_branches(
return 0;
}
+int merge_commits_from_branches(
+ git_index **index, git_repository *repo,
+ const char *ours_name, const char *theirs_name,
+ git_merge_tree_opts *opts)
+{
+ git_commit *our_commit, *their_commit;
+ git_oid our_oid, their_oid;
+ git_buf branch_buf = GIT_BUF_INIT;
+ int error;
+
+ git_buf_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);
+ 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));
+
+ git_buf_free(&branch_buf);
+ git_commit_free(our_commit);
+ git_commit_free(their_commit);
+
+ return 0;
+}
+
int merge_branches(git_merge_result **result, git_repository *repo, const char *ours_branch, const char *theirs_branch, git_merge_opts *opts)
{
git_reference *head_ref, *theirs_ref;