diff options
author | Edward Thomson <ethomson@microsoft.com> | 2013-12-02 14:10:04 -0500 |
---|---|---|
committer | Edward Thomson <ethomson@microsoft.com> | 2013-12-03 10:18:53 -0500 |
commit | eac938d96eccb39c30ce94adf7f8cdc06df098fe (patch) | |
tree | c988491670ff34769ebfc5ea041e40256935a4d9 /tests/merge/merge_helpers.c | |
parent | 553d33732aa69f5dab717181fc3a72b42ce07339 (diff) | |
download | libgit2-eac938d96eccb39c30ce94adf7f8cdc06df098fe.tar.gz |
Bare naked merge and rebase
Diffstat (limited to 'tests/merge/merge_helpers.c')
-rw-r--r-- | tests/merge/merge_helpers.c | 28 |
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; |