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