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 /src/merge.c | |
parent | 553d33732aa69f5dab717181fc3a72b42ce07339 (diff) | |
download | libgit2-eac938d96eccb39c30ce94adf7f8cdc06df098fe.tar.gz |
Bare naked merge and rebase
Diffstat (limited to 'src/merge.c')
-rw-r--r-- | src/merge.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/merge.c b/src/merge.c index 05e656d1e..ef138c284 100644 --- a/src/merge.c +++ b/src/merge.c @@ -1609,6 +1609,40 @@ done: return error; } +int git_merge_commits( + git_index **out, + git_repository *repo, + const git_commit *our_commit, + const git_commit *their_commit, + const git_merge_tree_opts *opts) +{ + git_oid ancestor_oid; + git_commit *ancestor_commit = NULL; + git_tree *our_tree = NULL, *their_tree = NULL, *ancestor_tree = NULL; + int error = 0; + + if ((error = git_merge_base(&ancestor_oid, repo, git_commit_id(our_commit), git_commit_id(their_commit))) < 0 && + error == GIT_ENOTFOUND) + giterr_clear(); + else if (error < 0 || + (error = git_commit_lookup(&ancestor_commit, repo, &ancestor_oid)) < 0 || + (error = git_commit_tree(&ancestor_tree, ancestor_commit)) < 0) + goto done; + + if ((error = git_commit_tree(&our_tree, our_commit)) < 0 || + (error = git_commit_tree(&their_tree, their_commit)) < 0 || + (error = git_merge_trees(out, repo, ancestor_tree, our_tree, their_tree, opts)) < 0) + goto done; + +done: + git_commit_free(ancestor_commit); + git_tree_free(our_tree); + git_tree_free(their_tree); + git_tree_free(ancestor_tree); + + return error; +} + /* Merge setup / cleanup */ static int write_orig_head( |