@@ -15,6 +15,11 @@ 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 : keys:: String = keys:: String :: new_string ( "ignoreSubmodules" , & config:: Tree :: DIFF )
21+ . with_note ( "This setting affects only the submodule status, and thus the repository status in general." ) ;
22+
1823 /// The `diff.renames` key.
1924 pub const RENAMES : Renames = Renames :: new_renames ( "renames" , & config:: Tree :: DIFF ) ;
2025
@@ -45,6 +50,7 @@ impl Section for Diff {
4550 fn keys ( & self ) -> & [ & dyn Key ] {
4651 & [
4752 & Self :: ALGORITHM ,
53+ & Self :: IGNORE_SUBMODULES ,
4854 & Self :: RENAME_LIMIT ,
4955 & Self :: RENAMES ,
5056 & Self :: DRIVER_COMMAND ,
@@ -59,6 +65,9 @@ impl Section for Diff {
5965/// The `diff.algorithm` key.
6066pub type Algorithm = keys:: Any < validate:: Algorithm > ;
6167
68+ /// The `diff.ignoreSubmodules` key.
69+ pub type Ignore = keys:: Any < validate:: Ignore > ;
70+
6271/// The `diff.renames` key.
6372pub type Renames = keys:: Any < validate:: Renames > ;
6473
@@ -71,12 +80,27 @@ mod algorithm {
7180 use crate :: {
7281 bstr:: BStr ,
7382 config,
74- config:: { diff:: algorithm:: Error , tree:: sections:: diff:: Algorithm } ,
83+ config:: {
84+ diff:: algorithm,
85+ key,
86+ tree:: sections:: diff:: { Algorithm , Ignore } ,
87+ } ,
7588 } ;
7689
90+ impl Ignore {
91+ /// See if `value` is an actual ignore
92+ pub fn try_into_ignore (
93+ & self ,
94+ value : Cow < ' _ , BStr > ,
95+ ) -> Result < gix_submodule:: config:: Ignore , key:: GenericErrorWithValue > {
96+ gix_submodule:: config:: Ignore :: try_from ( value. as_ref ( ) )
97+ . or_else ( |( ) | key:: GenericErrorWithValue :: from_value ( self , value. into_owned ( ) ) )
98+ }
99+ }
100+
77101 impl Algorithm {
78102 /// 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 > {
103+ pub fn try_into_algorithm ( & self , name : Cow < ' _ , BStr > ) -> Result < gix_diff:: blob:: Algorithm , algorithm :: Error > {
80104 let algo = if name. eq_ignore_ascii_case ( b"myers" ) || name. eq_ignore_ascii_case ( b"default" ) {
81105 gix_diff:: blob:: Algorithm :: Myers
82106 } else if name. eq_ignore_ascii_case ( b"minimal" ) {
@@ -88,7 +112,7 @@ mod algorithm {
88112 name : name. into_owned ( ) ,
89113 } ) ;
90114 } else {
91- return Err ( Error :: Unknown {
115+ return Err ( algorithm :: Error :: Unknown {
92116 name : name. into_owned ( ) ,
93117 } ) ;
94118 } ;
@@ -171,6 +195,14 @@ pub(super) mod validate {
171195 config:: tree:: { keys, Diff } ,
172196 } ;
173197
198+ pub struct Ignore ;
199+ impl keys:: Validate for Ignore {
200+ fn validate ( & self , value : & BStr ) -> Result < ( ) , Box < dyn std:: error:: Error + Send + Sync + ' static > > {
201+ Diff :: ALGORITHM . try_into_ignore ( value. into ( ) ) ?;
202+ Ok ( ( ) )
203+ }
204+ }
205+
174206 pub struct Algorithm ;
175207 impl keys:: Validate for Algorithm {
176208 fn validate ( & self , value : & BStr ) -> Result < ( ) , Box < dyn std:: error:: Error + Send + Sync + ' static > > {
0 commit comments