File tree Expand file tree Collapse file tree 6 files changed +45
-1
lines changed Expand file tree Collapse file tree 6 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -219,13 +219,22 @@ impl Cache {
219219 subsection_name : Option < & BStr > ,
220220 key : impl AsRef < str > ,
221221 ) -> 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 ( ) ;
222224 let path = self . resolved . path_filter (
223225 section_name,
224226 subsection_name,
225227 key,
226228 & mut self . filter_config_section . clone ( ) ,
227229 ) ?;
228230
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+
229238 let install_dir = crate :: path:: install_dir ( ) . ok ( ) ;
230239 let home = self . home_dir ( ) ;
231240 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 {
105105 ///
106106 /// When only excludes are desired, this is the most efficient way to obtain them. Otherwise use
107107 /// [`Repository::attributes()`] for accessing both attributes and excludes.
108- // TODO: test
109108 #[ doc( alias = "is_path_ignored" , alias = "git2" ) ]
110109 #[ cfg( feature = "excludes" ) ]
111110 pub fn excludes (
Original file line number Diff line number Diff line change @@ -31,4 +31,9 @@ git init all-untracked
3131 > a
3232 mkdir d
3333 > d/a
34+ )
35+
36+ git init empty-core-excludes
37+ (cd empty-core-excludes
38+ echo $' [core]\n\t excludesFile = ' >> .git/config
3439)
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 11use gix:: Repository ;
22
33mod config;
4+ #[ cfg( feature = "excludes" ) ]
5+ mod excludes;
46#[ cfg( feature = "attributes" ) ]
57mod filter;
68mod object;
@@ -38,6 +40,7 @@ mod dirwalk {
3840 ( "all-untracked" . to_string ( ) , Repository ) ,
3941 ( "bare-repo-with-index.git" . to_string ( ) , Directory ) ,
4042 ( "bare.git" . into ( ) , Directory ) ,
43+ ( "empty-core-excludes" . into ( ) , Repository ) ,
4144 ( "non-bare-repo-without-index" . into ( ) , Repository ) ,
4245 ( "some" . into ( ) , Directory ) ,
4346 ] ;
You can’t perform that action at this time.
0 commit comments