1
+ use crate :: blob:: builtin_driver:: text:: Conflict ;
1
2
use crate :: blob:: platform:: { merge, DriverChoice , ResourceRef } ;
2
3
use crate :: blob:: { BuiltinDriver , Platform , PlatformRef , ResourceKind } ;
3
4
use bstr:: { BStr , BString , ByteSlice } ;
4
5
use gix_filter:: attributes;
6
+ use std:: num:: NonZeroU8 ;
7
+ use std:: str:: FromStr ;
5
8
6
9
/// The error returned by [Platform::prepare_merge_state()](Platform::prepare_merge()).
7
10
#[ derive( Debug , thiserror:: Error ) ]
@@ -45,12 +48,14 @@ impl Platform {
45
48
rela_path : current. rela_path . clone ( ) ,
46
49
} ) ?;
47
50
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 {
50
55
attributes:: StateRef :: Set => DriverChoice :: BuiltIn ( BuiltinDriver :: Text ) ,
51
56
attributes:: StateRef :: Unset => DriverChoice :: BuiltIn ( BuiltinDriver :: Binary ) ,
52
57
attributes:: StateRef :: Value ( _) | attributes:: StateRef :: Unspecified => {
53
- let name = match attr . assignment . state {
58
+ let name = match merge_attr . assignment . state {
54
59
attributes:: StateRef :: Value ( name) => Some ( name. as_bstr ( ) ) ,
55
60
attributes:: StateRef :: Unspecified => {
56
61
self . options . default_driver . as_ref ( ) . map ( |name| name. as_bstr ( ) )
@@ -60,6 +65,17 @@ impl Platform {
60
65
self . find_driver_by_name ( name)
61
66
}
62
67
} ;
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
+ }
63
79
if let Some ( recursive_driver_name) = match driver {
64
80
DriverChoice :: Index ( idx) => self . drivers . get ( idx) ,
65
81
_ => None ,
0 commit comments