@@ -15,6 +15,12 @@ impl Diff {
1515 . with_note (
1616 "The limit is actually squared, so 1000 stands for up to 1 million diffs if fuzzy rename tracking is enabled" ,
1717 ) ;
18+
19+ /// The `diff.ignoreSubmodules` key.
20+ pub const IGNORE_SUBMODULES : Ignore =
21+ Ignore :: new_with_validate ( "ignoreSubmodules" , & config:: Tree :: DIFF , validate:: Ignore )
22+ . with_note ( "This setting affects only the submodule status, and thus the repository status in general." ) ;
23+
1824 /// The `diff.renames` key.
1925 pub const RENAMES : Renames = Renames :: new_renames ( "renames" , & config:: Tree :: DIFF ) ;
2026
@@ -45,6 +51,7 @@ impl Section for Diff {
4551 fn keys ( & self ) -> & [ & dyn Key ] {
4652 & [
4753 & Self :: ALGORITHM ,
54+ & Self :: IGNORE_SUBMODULES ,
4855 & Self :: RENAME_LIMIT ,
4956 & Self :: RENAMES ,
5057 & Self :: DRIVER_COMMAND ,
@@ -59,6 +66,9 @@ impl Section for Diff {
5966/// The `diff.algorithm` key.
6067pub type Algorithm = keys:: Any < validate:: Algorithm > ;
6168
69+ /// The `diff.ignoreSubmodules` key.
70+ pub type Ignore = keys:: Any < validate:: Ignore > ;
71+
6272/// The `diff.renames` key.
6373pub type Renames = keys:: Any < validate:: Renames > ;
6474
@@ -71,12 +81,27 @@ mod algorithm {
7181 use crate :: {
7282 bstr:: BStr ,
7383 config,
74- config:: { diff:: algorithm:: Error , tree:: sections:: diff:: Algorithm } ,
84+ config:: {
85+ diff:: algorithm,
86+ key,
87+ tree:: sections:: diff:: { Algorithm , Ignore } ,
88+ } ,
7589 } ;
7690
91+ impl Ignore {
92+ /// See if `value` is an actual ignore
93+ pub fn try_into_ignore (
94+ & ' static self ,
95+ value : Cow < ' _ , BStr > ,
96+ ) -> Result < gix_submodule:: config:: Ignore , key:: GenericErrorWithValue > {
97+ gix_submodule:: config:: Ignore :: try_from ( value. as_ref ( ) )
98+ . map_err ( |( ) | key:: GenericErrorWithValue :: from_value ( self , value. into_owned ( ) ) )
99+ }
100+ }
101+
77102 impl Algorithm {
78103 /// Derive the diff algorithm identified by `name`, case-insensitively.
79- pub fn try_into_algorithm ( & self , name : Cow < ' _ , BStr > ) -> Result < gix_diff:: blob:: Algorithm , Error > {
104+ pub fn try_into_algorithm ( & self , name : Cow < ' _ , BStr > ) -> Result < gix_diff:: blob:: Algorithm , algorithm :: Error > {
80105 let algo = if name. eq_ignore_ascii_case ( b"myers" ) || name. eq_ignore_ascii_case ( b"default" ) {
81106 gix_diff:: blob:: Algorithm :: Myers
82107 } else if name. eq_ignore_ascii_case ( b"minimal" ) {
@@ -88,7 +113,7 @@ mod algorithm {
88113 name : name. into_owned ( ) ,
89114 } ) ;
90115 } else {
91- return Err ( Error :: Unknown {
116+ return Err ( algorithm :: Error :: Unknown {
92117 name : name. into_owned ( ) ,
93118 } ) ;
94119 } ;
@@ -171,6 +196,15 @@ pub(super) mod validate {
171196 config:: tree:: { keys, Diff } ,
172197 } ;
173198
199+ pub struct Ignore ;
200+ impl keys:: Validate for Ignore {
201+ fn validate ( & self , value : & BStr ) -> Result < ( ) , Box < dyn std:: error:: Error + Send + Sync + ' static > > {
202+ gix_submodule:: config:: Ignore :: try_from ( value)
203+ . map_err ( |( ) | format ! ( "Value '{value}' is not a valid submodule 'ignore' value" ) ) ?;
204+ Ok ( ( ) )
205+ }
206+ }
207+
174208 pub struct Algorithm ;
175209 impl keys:: Validate for Algorithm {
176210 fn validate ( & self , value : & BStr ) -> Result < ( ) , Box < dyn std:: error:: Error + Send + Sync + ' static > > {
0 commit comments