1+ use crate :: blob:: builtin_driver:: text:: Conflict ;
12use crate :: blob:: platform:: { merge, DriverChoice , ResourceRef } ;
23use crate :: blob:: { BuiltinDriver , Platform , PlatformRef , ResourceKind } ;
34use bstr:: { BStr , BString , ByteSlice } ;
45use gix_filter:: attributes;
6+ use std:: num:: NonZeroU8 ;
7+ use std:: str:: FromStr ;
58
69/// The error returned by [Platform::prepare_merge_state()](Platform::prepare_merge()).
710#[ derive( Debug , thiserror:: Error ) ]
@@ -45,12 +48,14 @@ impl Platform {
4548 rela_path : current. rela_path . clone ( ) ,
4649 } ) ?;
4750 entry. matching_attributes ( & mut self . attrs ) ;
48- let attr = self . attrs . iter_selected ( ) . next ( ) . expect ( "pre-initialized with 'diff'" ) ;
49- let mut driver = match attr. assignment . state {
51+ let mut attrs = self . attrs . iter_selected ( ) ;
52+ let merge_attr = attrs. next ( ) . expect ( "pre-initialized with 'merge'" ) ;
53+ let marker_size_attr = attrs. next ( ) . expect ( "pre-initialized with 'conflict-marker-size'" ) ;
54+ let mut driver = match merge_attr. assignment . state {
5055 attributes:: StateRef :: Set => DriverChoice :: BuiltIn ( BuiltinDriver :: Text ) ,
5156 attributes:: StateRef :: Unset => DriverChoice :: BuiltIn ( BuiltinDriver :: Binary ) ,
5257 attributes:: StateRef :: Value ( _) | attributes:: StateRef :: Unspecified => {
53- let name = match attr . assignment . state {
58+ let name = match merge_attr . assignment . state {
5459 attributes:: StateRef :: Value ( name) => Some ( name. as_bstr ( ) ) ,
5560 attributes:: StateRef :: Unspecified => {
5661 self . options . default_driver . as_ref ( ) . map ( |name| name. as_bstr ( ) )
@@ -60,6 +65,17 @@ impl Platform {
6065 self . find_driver_by_name ( name)
6166 }
6267 } ;
68+ if let attributes:: StateRef :: Value ( value) = marker_size_attr. assignment . state {
69+ if let Some ( value) = u8:: from_str ( value. as_bstr ( ) . to_str_lossy ( ) . as_ref ( ) )
70+ . ok ( )
71+ . and_then ( NonZeroU8 :: new)
72+ {
73+ match & mut options. text . conflict {
74+ Conflict :: Keep { marker_size, .. } => * marker_size = value,
75+ Conflict :: ResolveWithOurs | Conflict :: ResolveWithTheirs | Conflict :: ResolveWithUnion => { }
76+ }
77+ }
78+ }
6379 if let Some ( recursive_driver_name) = match driver {
6480 DriverChoice :: Index ( idx) => self . drivers . get ( idx) ,
6581 _ => None ,
0 commit comments