@@ -15,6 +15,12 @@ impl Diff {
15
15
. with_note (
16
16
"The limit is actually squared, so 1000 stands for up to 1 million diffs if fuzzy rename tracking is enabled" ,
17
17
) ;
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
+
18
24
/// The `diff.renames` key.
19
25
pub const RENAMES : Renames = Renames :: new_renames ( "renames" , & config:: Tree :: DIFF ) ;
20
26
@@ -45,6 +51,7 @@ impl Section for Diff {
45
51
fn keys ( & self ) -> & [ & dyn Key ] {
46
52
& [
47
53
& Self :: ALGORITHM ,
54
+ & Self :: IGNORE_SUBMODULES ,
48
55
& Self :: RENAME_LIMIT ,
49
56
& Self :: RENAMES ,
50
57
& Self :: DRIVER_COMMAND ,
@@ -59,6 +66,9 @@ impl Section for Diff {
59
66
/// The `diff.algorithm` key.
60
67
pub type Algorithm = keys:: Any < validate:: Algorithm > ;
61
68
69
+ /// The `diff.ignoreSubmodules` key.
70
+ pub type Ignore = keys:: Any < validate:: Ignore > ;
71
+
62
72
/// The `diff.renames` key.
63
73
pub type Renames = keys:: Any < validate:: Renames > ;
64
74
@@ -71,12 +81,27 @@ mod algorithm {
71
81
use crate :: {
72
82
bstr:: BStr ,
73
83
config,
74
- config:: { diff:: algorithm:: Error , tree:: sections:: diff:: Algorithm } ,
84
+ config:: {
85
+ diff:: algorithm,
86
+ key,
87
+ tree:: sections:: diff:: { Algorithm , Ignore } ,
88
+ } ,
75
89
} ;
76
90
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
+
77
102
impl Algorithm {
78
103
/// 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 > {
80
105
let algo = if name. eq_ignore_ascii_case ( b"myers" ) || name. eq_ignore_ascii_case ( b"default" ) {
81
106
gix_diff:: blob:: Algorithm :: Myers
82
107
} else if name. eq_ignore_ascii_case ( b"minimal" ) {
@@ -88,7 +113,7 @@ mod algorithm {
88
113
name : name. into_owned ( ) ,
89
114
} ) ;
90
115
} else {
91
- return Err ( Error :: Unknown {
116
+ return Err ( algorithm :: Error :: Unknown {
92
117
name : name. into_owned ( ) ,
93
118
} ) ;
94
119
} ;
@@ -171,6 +196,15 @@ pub(super) mod validate {
171
196
config:: tree:: { keys, Diff } ,
172
197
} ;
173
198
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
+
174
208
pub struct Algorithm ;
175
209
impl keys:: Validate for Algorithm {
176
210
fn validate ( & self , value : & BStr ) -> Result < ( ) , Box < dyn std:: error:: Error + Send + Sync + ' static > > {
0 commit comments