@@ -157,7 +157,7 @@ enum ConflictIndexEntryPathHint {
157157}
158158
159159/// A utility to help define which side is what in the [`Conflict`] type.
160- #[ derive( Debug , Clone , Copy ) ]
160+ #[ derive( Debug , Clone , Copy , Eq , PartialEq ) ]
161161enum ConflictMapping {
162162 /// The sides are as described in the field documentation, i.e. `ours` is `ours`.
163163 Original ,
@@ -175,13 +175,19 @@ impl ConflictMapping {
175175 ConflictMapping :: Swapped => ConflictMapping :: Original ,
176176 }
177177 }
178+ fn to_global ( self , global : ConflictMapping ) -> ConflictMapping {
179+ match global {
180+ ConflictMapping :: Original => self ,
181+ ConflictMapping :: Swapped => self . swapped ( ) ,
182+ }
183+ }
178184}
179185
180186impl Conflict {
181187 /// Return `true` if this instance is considered unresolved based on the criterion specified by `how`.
182188 pub fn is_unresolved ( & self , how : TreatAsUnresolved ) -> bool {
183189 use crate :: blob;
184- let content_merge_matches = |info : & ContentMerge | match how. content_merge {
190+ let content_merge_unresolved = |info : & ContentMerge | match how. content_merge {
185191 treat_as_unresolved:: ContentMerge :: Markers => matches ! ( info. resolution, blob:: Resolution :: Conflict ) ,
186192 treat_as_unresolved:: ContentMerge :: ForcedResolution => {
187193 matches ! (
@@ -192,20 +198,28 @@ impl Conflict {
192198 } ;
193199 match how. tree_merge {
194200 treat_as_unresolved:: TreeMerge :: Undecidable => {
195- self . resolution . is_err ( ) || self . content_merge ( ) . map_or ( false , |info| content_merge_matches ( & info) )
201+ self . resolution . is_err ( )
202+ || self
203+ . content_merge ( )
204+ . map_or ( false , |info| content_merge_unresolved ( & info) )
196205 }
197206 treat_as_unresolved:: TreeMerge :: EvasiveRenames | treat_as_unresolved:: TreeMerge :: ForcedResolution => {
198207 match & self . resolution {
199208 Ok ( success) => match success {
200209 Resolution :: SourceLocationAffectedByRename { .. } => false ,
201- Resolution :: Forced ( _) => how. tree_merge == treat_as_unresolved:: TreeMerge :: ForcedResolution ,
210+ Resolution :: Forced ( _) => {
211+ how. tree_merge == treat_as_unresolved:: TreeMerge :: ForcedResolution
212+ || self
213+ . content_merge ( )
214+ . map_or ( false , |merged_blob| content_merge_unresolved ( & merged_blob) )
215+ }
202216 Resolution :: OursModifiedTheirsRenamedAndChangedThenRename {
203217 merged_blob,
204218 final_location,
205219 ..
206- } => final_location. is_some ( ) || merged_blob. as_ref ( ) . map_or ( false , content_merge_matches ) ,
220+ } => final_location. is_some ( ) || merged_blob. as_ref ( ) . map_or ( false , content_merge_unresolved ) ,
207221 Resolution :: OursModifiedTheirsModifiedThenBlobContentMerge { merged_blob } => {
208- content_merge_matches ( merged_blob)
222+ content_merge_unresolved ( merged_blob)
209223 }
210224 } ,
211225 Err ( _failure) => true ,
@@ -386,7 +400,10 @@ pub struct Options {
386400pub enum ResolveWith {
387401 /// On irreconcilable conflict, choose neither *our* nor *their* state, but keep the common *ancestor* state instead.
388402 Ancestor ,
389- /// On irreconcilable conflict, choose *our* side
403+ /// On irreconcilable conflict, choose *our* side.
404+ ///
405+ /// Note that in order to get something equivalent to *theirs*, put *theirs* into the side of *ours*,
406+ /// swapping the sides essentially.
390407 Ours ,
391408}
392409
0 commit comments