|
| 1 | +#[cfg(feature = "blob-merge")] |
| 2 | +pub use gix_merge as plumbing; |
| 3 | + |
| 4 | +/// |
| 5 | +pub mod tree { |
| 6 | + use gix_merge::tree::UnresolvedConflict; |
| 7 | + |
| 8 | + /// The outcome produced by [`Repository::merge_trees()`](crate::Repository::merge_trees()). |
| 9 | + #[derive(Clone)] |
| 10 | + pub struct Outcome<'repo> { |
| 11 | + /// The ready-made (but unwritten) *base* tree, including all non-conflicting changes, and the changes that had |
| 12 | + /// conflicts which could be resolved automatically. |
| 13 | + /// |
| 14 | + /// This means, if all of their changes were conflicting, this will be equivalent to the *base* tree. |
| 15 | + pub tree: crate::object::tree::Editor<'repo>, |
| 16 | + /// The set of conflicts we encountered. Can be empty to indicate there was no conflict. |
| 17 | + /// Note that conflicts might have been auto-resolved, but they are listed here for completeness. |
| 18 | + /// Use [`has_unresolved_conflicts()`](Outcome::has_unresolved_conflicts()) to see if any action is needed |
| 19 | + /// before using [`tree`](Outcome::tree). |
| 20 | + pub conflicts: Vec<gix_merge::tree::Conflict>, |
| 21 | + /// `true` if `conflicts` contains only a single *unresolved* conflict in the last slot, but possibly more resolved ones. |
| 22 | + /// This also makes this outcome a very partial merge that cannot be completed. |
| 23 | + /// Only set if [`fail_on_conflict`](Options::fail_on_conflict) is `true`. |
| 24 | + pub failed_on_first_unresolved_conflict: bool, |
| 25 | + } |
| 26 | + |
| 27 | + impl Outcome<'_> { |
| 28 | + /// Return `true` if there is any conflict that would still need to be resolved as they would yield undesirable trees. |
| 29 | + /// This is based on `how` to determine what should be considered unresolved. |
| 30 | + pub fn has_unresolved_conflicts(&self, how: UnresolvedConflict) -> bool { |
| 31 | + self.conflicts.iter().any(|c| c.is_unresolved(how)) |
| 32 | + } |
| 33 | + } |
| 34 | +} |
0 commit comments