diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2017-03-23 09:49:09 +0000 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2017-03-23 09:49:09 +0000 |
commit | 69873685650ab1b6e1e523b6a5826fac1f3aaed7 (patch) | |
tree | f35f2afcecdcd91a004076f8d9412b4d8fdb08fb | |
parent | 6ad091dcebb5582413b0ed474da76ca0f702970e (diff) | |
parent | b53d834fcaf278739d20a9fe155b73cb04744069 (diff) | |
download | libgit2-69873685650ab1b6e1e523b6a5826fac1f3aaed7.tar.gz |
Merge branch 'pr/3957'
-rw-r--r-- | src/merge.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/merge.c b/src/merge.c index 857d51311..6e00b5adb 100644 --- a/src/merge.c +++ b/src/merge.c @@ -2018,6 +2018,26 @@ int git_merge_trees( git_iterator_options iter_opts = GIT_ITERATOR_OPTIONS_INIT; int error; + assert(out && repo); + + /* if one side is treesame to the ancestor, take the other side */ + if (ancestor_tree && merge_opts && (merge_opts->flags & GIT_MERGE_SKIP_REUC)) { + const git_tree *result = NULL; + const git_oid *ancestor_tree_id = git_tree_id(ancestor_tree); + + if (our_tree && !git_oid_cmp(ancestor_tree_id, git_tree_id(our_tree))) + result = their_tree; + else if (their_tree && !git_oid_cmp(ancestor_tree_id, git_tree_id(their_tree))) + result = our_tree; + + if (result) { + if ((error = git_index_new(out)) == 0) + error = git_index_read_tree(*out, result); + + return error; + } + } + iter_opts.flags = GIT_ITERATOR_DONT_IGNORE_CASE; if ((error = git_iterator_for_tree( |