@@ -25,7 +25,7 @@ fn binary() {
2525
2626mod text {
2727 use bstr:: ByteSlice ;
28- use gix_merge:: blob:: builtin_driver:: text:: Conflict ;
28+ use gix_merge:: blob:: builtin_driver:: text:: { Conflict , ConflictStyle } ;
2929 use gix_merge:: blob:: { builtin_driver, Resolution } ;
3030 use pretty_assertions:: assert_str_eq;
3131
@@ -160,10 +160,17 @@ mod text {
160160 if is_case_diverging ( & case, diverging) {
161161 num_diverging += 1 ;
162162 } else {
163- let expected_resolution = if case. expected . contains_str ( "<<<<<<<" ) {
164- Resolution :: Conflict
163+ if case. expected . contains_str ( "<<<<<<<" ) {
164+ assert_eq ! ( actual , Resolution :: Conflict , "{}: resolution mismatch" , case . name , ) ;
165165 } else {
166- Resolution :: Complete
166+ assert ! (
167+ matches!(
168+ actual,
169+ Resolution :: Complete | Resolution :: CompleteWithAutoResolvedConflict
170+ ) ,
171+ "{}: resolution mismatch" ,
172+ case. name
173+ ) ;
167174 } ;
168175 assert_str_eq ! (
169176 out. as_bstr( ) . to_str_lossy( ) ,
@@ -173,7 +180,6 @@ mod text {
173180 out. as_bstr( )
174181 ) ;
175182 assert_eq ! ( out. as_bstr( ) , case. expected) ;
176- assert_eq ! ( actual, expected_resolution, "{}: resolution mismatch" , case. name, ) ;
177183 }
178184 }
179185
@@ -191,6 +197,100 @@ mod text {
191197 Ok ( ( ) )
192198 }
193199
200+ #[ test]
201+ fn both_sides_same_changes_are_conflict_free ( ) {
202+ for conflict in [
203+ builtin_driver:: text:: Conflict :: Keep {
204+ style : ConflictStyle :: Merge ,
205+ marker_size : 7 . try_into ( ) . unwrap ( ) ,
206+ } ,
207+ builtin_driver:: text:: Conflict :: Keep {
208+ style : ConflictStyle :: Diff3 ,
209+ marker_size : 7 . try_into ( ) . unwrap ( ) ,
210+ } ,
211+ builtin_driver:: text:: Conflict :: Keep {
212+ style : ConflictStyle :: ZealousDiff3 ,
213+ marker_size : 7 . try_into ( ) . unwrap ( ) ,
214+ } ,
215+ builtin_driver:: text:: Conflict :: ResolveWithOurs ,
216+ builtin_driver:: text:: Conflict :: ResolveWithTheirs ,
217+ builtin_driver:: text:: Conflict :: ResolveWithUnion ,
218+ ] {
219+ let options = builtin_driver:: text:: Options {
220+ conflict,
221+ ..Default :: default ( )
222+ } ;
223+ let mut input = imara_diff:: intern:: InternedInput :: default ( ) ;
224+ let mut out = Vec :: new ( ) ;
225+ let actual = builtin_driver:: text (
226+ & mut out,
227+ & mut input,
228+ Default :: default ( ) ,
229+ b"1\n 3\n other" ,
230+ b"1\n 2\n 3" ,
231+ b"1\n 3\n other" ,
232+ options,
233+ ) ;
234+ assert_eq ! ( actual, Resolution :: Complete , "{conflict:?}" ) ;
235+ }
236+ }
237+
238+ #[ test]
239+ fn both_differ_partially_resolution_is_conflicting ( ) {
240+ for ( conflict, expected) in [
241+ (
242+ builtin_driver:: text:: Conflict :: Keep {
243+ style : ConflictStyle :: Merge ,
244+ marker_size : 7 . try_into ( ) . unwrap ( ) ,
245+ } ,
246+ Resolution :: Conflict ,
247+ ) ,
248+ (
249+ builtin_driver:: text:: Conflict :: Keep {
250+ style : ConflictStyle :: Diff3 ,
251+ marker_size : 7 . try_into ( ) . unwrap ( ) ,
252+ } ,
253+ Resolution :: Conflict ,
254+ ) ,
255+ (
256+ builtin_driver:: text:: Conflict :: Keep {
257+ style : ConflictStyle :: ZealousDiff3 ,
258+ marker_size : 7 . try_into ( ) . unwrap ( ) ,
259+ } ,
260+ Resolution :: Conflict ,
261+ ) ,
262+ (
263+ builtin_driver:: text:: Conflict :: ResolveWithOurs ,
264+ Resolution :: CompleteWithAutoResolvedConflict ,
265+ ) ,
266+ (
267+ builtin_driver:: text:: Conflict :: ResolveWithTheirs ,
268+ Resolution :: CompleteWithAutoResolvedConflict ,
269+ ) ,
270+ (
271+ builtin_driver:: text:: Conflict :: ResolveWithUnion ,
272+ Resolution :: CompleteWithAutoResolvedConflict ,
273+ ) ,
274+ ] {
275+ let options = builtin_driver:: text:: Options {
276+ conflict,
277+ ..Default :: default ( )
278+ } ;
279+ let mut input = imara_diff:: intern:: InternedInput :: default ( ) ;
280+ let mut out = Vec :: new ( ) ;
281+ let actual = builtin_driver:: text (
282+ & mut out,
283+ & mut input,
284+ Default :: default ( ) ,
285+ b"1\n 3\n ours" ,
286+ b"1\n 2\n 3" ,
287+ b"1\n 3\n theirs" ,
288+ options,
289+ ) ;
290+ assert_eq ! ( actual, expected, "{conflict:?}" ) ;
291+ }
292+ }
293+
194294 mod baseline {
195295 use bstr:: BString ;
196296 use gix_merge:: blob:: builtin_driver:: text:: { Conflict , ConflictStyle } ;
0 commit comments