Merge two trees. Returns: an Index that reflects the result of the merge. Parameters: ancestor The tree which is the common ancestor between 'ours' and 'theirs'. ours The commit to take as "ours" or base. theirs
(
self,
ancestor: str | Oid | Tree,
ours: str | Oid | Tree,
theirs: str | Oid | Tree,
favor: MergeFavor = MergeFavor.NORMAL,
flags: MergeFlag = MergeFlag.FIND_RENAMES,
file_flags: MergeFileFlag = MergeFileFlag.DEFAULT,
)
| 925 | return Index.from_c(self, cindex) |
| 926 | |
| 927 | def merge_trees( |
| 928 | self, |
| 929 | ancestor: str | Oid | Tree, |
| 930 | ours: str | Oid | Tree, |
| 931 | theirs: str | Oid | Tree, |
| 932 | favor: MergeFavor = MergeFavor.NORMAL, |
| 933 | flags: MergeFlag = MergeFlag.FIND_RENAMES, |
| 934 | file_flags: MergeFileFlag = MergeFileFlag.DEFAULT, |
| 935 | ) -> 'Index': |
| 936 | """ |
| 937 | Merge two trees. |
| 938 | |
| 939 | Returns: an Index that reflects the result of the merge. |
| 940 | |
| 941 | Parameters: |
| 942 | |
| 943 | ancestor |
| 944 | The tree which is the common ancestor between 'ours' and 'theirs'. |
| 945 | |
| 946 | ours |
| 947 | The commit to take as "ours" or base. |
| 948 | |
| 949 | theirs |
| 950 | The commit which will be merged into "ours". |
| 951 | |
| 952 | favor |
| 953 | An enums.MergeFavor constant specifying how to deal with file-level conflicts. |
| 954 | For all but NORMAL, the index will not record a conflict. |
| 955 | |
| 956 | flags |
| 957 | A combination of enums.MergeFlag constants. |
| 958 | |
| 959 | file_flags |
| 960 | A combination of enums.MergeFileFlag constants. |
| 961 | """ |
| 962 | ancestor_ptr = ffi.new('git_tree **') |
| 963 | ours_ptr = ffi.new('git_tree **') |
| 964 | theirs_ptr = ffi.new('git_tree **') |
| 965 | cindex = ffi.new('git_index **') |
| 966 | |
| 967 | ancestor = self.__ensure_tree(ancestor) |
| 968 | ours = self.__ensure_tree(ours) |
| 969 | theirs = self.__ensure_tree(theirs) |
| 970 | |
| 971 | opts = self._merge_options(favor, flags, file_flags) |
| 972 | |
| 973 | ffi.buffer(ancestor_ptr)[:] = ancestor._pointer[:] |
| 974 | ffi.buffer(ours_ptr)[:] = ours._pointer[:] |
| 975 | ffi.buffer(theirs_ptr)[:] = theirs._pointer[:] |
| 976 | |
| 977 | err = C.git_merge_trees( |
| 978 | cindex, self._repo, ancestor_ptr[0], ours_ptr[0], theirs_ptr[0], opts |
| 979 | ) |
| 980 | check_error(err) |
| 981 | |
| 982 | return Index.from_c(self, cindex) |
| 983 | |
| 984 | def merge( |