File tree 6 files changed +45
-1
lines changed
6 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -219,13 +219,22 @@ impl Cache {
219
219
subsection_name : Option < & BStr > ,
220
220
key : impl AsRef < str > ,
221
221
) -> Option < Result < Cow < ' _ , std:: path:: Path > , gix_config:: path:: interpolate:: Error > > {
222
+ let section_name = section_name. as_ref ( ) ;
223
+ let key = key. as_ref ( ) ;
222
224
let path = self . resolved . path_filter (
223
225
section_name,
224
226
subsection_name,
225
227
key,
226
228
& mut self . filter_config_section . clone ( ) ,
227
229
) ?;
228
230
231
+ if self . lenient_config && path. is_empty ( ) {
232
+ gix_trace:: info!(
233
+ "Ignored empty path at {section_name}.{subsection_name:?}.{key} due to lenient configuration"
234
+ ) ;
235
+ return None ;
236
+ }
237
+
229
238
let install_dir = crate :: path:: install_dir ( ) . ok ( ) ;
230
239
let home = self . home_dir ( ) ;
231
240
let ctx = config:: cache:: interpolate_context ( install_dir. as_deref ( ) , home. as_deref ( ) ) ;
Original file line number Diff line number Diff line change @@ -105,7 +105,6 @@ impl Repository {
105
105
///
106
106
/// When only excludes are desired, this is the most efficient way to obtain them. Otherwise use
107
107
/// [`Repository::attributes()`] for accessing both attributes and excludes.
108
- // TODO: test
109
108
#[ doc( alias = "is_path_ignored" , alias = "git2" ) ]
110
109
#[ cfg( feature = "excludes" ) ]
111
110
pub fn excludes (
Original file line number Diff line number Diff line change @@ -31,4 +31,9 @@ git init all-untracked
31
31
> a
32
32
mkdir d
33
33
> d/a
34
+ )
35
+
36
+ git init empty-core-excludes
37
+ (cd empty-core-excludes
38
+ echo $' [core]\n\t excludesFile = ' >> .git/config
34
39
)
Original file line number Diff line number Diff line change
1
+ use crate :: util:: named_subrepo_opts;
2
+ use gix_worktree:: stack:: state:: ignore:: Source ;
3
+
4
+ #[ test]
5
+ fn empty_core_excludes ( ) -> crate :: Result {
6
+ let repo = named_subrepo_opts (
7
+ "make_basic_repo.sh" ,
8
+ "empty-core-excludes" ,
9
+ gix:: open:: Options :: default ( ) . strict_config ( true ) ,
10
+ ) ?;
11
+ let index = repo. index_or_empty ( ) ?;
12
+ match repo. excludes ( & index, None , Source :: WorktreeThenIdMappingIfNotSkipped ) {
13
+ Ok ( _) => {
14
+ unreachable ! ( "Should fail due to empty excludes path" )
15
+ }
16
+ Err ( err) => {
17
+ assert_eq ! (
18
+ err. to_string( ) ,
19
+ "The value for `core.excludesFile` could not be read from configuration"
20
+ ) ;
21
+ }
22
+ } ;
23
+
24
+ let repo = gix:: open_opts ( repo. git_dir ( ) , repo. open_options ( ) . clone ( ) . strict_config ( false ) ) ?;
25
+ repo. excludes ( & index, None , Source :: WorktreeThenIdMappingIfNotSkipped )
26
+ . expect ( "empty paths are now just skipped" ) ;
27
+ Ok ( ( ) )
28
+ }
Original file line number Diff line number Diff line change 1
1
use gix:: Repository ;
2
2
3
3
mod config;
4
+ #[ cfg( feature = "excludes" ) ]
5
+ mod excludes;
4
6
#[ cfg( feature = "attributes" ) ]
5
7
mod filter;
6
8
mod object;
@@ -38,6 +40,7 @@ mod dirwalk {
38
40
( "all-untracked" . to_string ( ) , Repository ) ,
39
41
( "bare-repo-with-index.git" . to_string ( ) , Directory ) ,
40
42
( "bare.git" . into ( ) , Directory ) ,
43
+ ( "empty-core-excludes" . into ( ) , Repository ) ,
41
44
( "non-bare-repo-without-index" . into ( ) , Repository ) ,
42
45
( "some" . into ( ) , Directory ) ,
43
46
] ;
You can’t perform that action at this time.
0 commit comments