@@ -6,8 +6,8 @@ use gix_hash::oid;
66
77use crate :: fs:: { cache:: State , PathOidMapping } ;
88
9- type AttributeMatchGroup = gix_attributes:: MatchGroup < gix_attributes :: Attributes > ;
10- type IgnoreMatchGroup = gix_attributes :: MatchGroup < gix_attributes :: Ignore > ;
9+ type AttributeMatchGroup = gix_attributes:: Search ;
10+ type IgnoreMatchGroup = gix_ignore :: Search ;
1111
1212/// State related to attributes associated with files in the repository.
1313#[ derive( Default , Clone ) ]
@@ -44,6 +44,8 @@ pub struct Ignore {
4444impl Ignore {
4545 /// The `exclude_file_name_for_directories` is an optional override for the filename to use when checking per-directory
4646 /// ignore files within the repository, defaults to`.gitignore`.
47+ ///
48+ // This is what it should be able represent: https://github.com/git/git/blob/140b9478dad5d19543c1cb4fd293ccec228f1240/dir.c#L3354
4749 // TODO: more docs
4850 pub fn new (
4951 overrides : IgnoreMatchGroup ,
@@ -79,7 +81,7 @@ impl Ignore {
7981 relative_path : & BStr ,
8082 is_dir : Option < bool > ,
8183 case : Case ,
82- ) -> Option < gix_attributes :: Match < ' _ , ( ) > > {
84+ ) -> Option < gix_ignore :: search :: Match < ' _ , ( ) > > {
8385 let groups = self . match_groups ( ) ;
8486 let mut dir_match = None ;
8587 if let Some ( ( source, mapping) ) = self
@@ -93,7 +95,7 @@ impl Ignore {
9395 } )
9496 . next ( )
9597 {
96- let match_ = gix_attributes :: Match {
98+ let match_ = gix_ignore :: search :: Match {
9799 pattern : & mapping. pattern ,
98100 value : & mapping. value ,
99101 sequence_number : mapping. sequence_number ,
@@ -135,8 +137,14 @@ impl Ignore {
135137 . enumerate ( )
136138 . rev ( )
137139 . find_map ( |( plidx, pl) | {
138- pl. pattern_idx_matching_relative_path ( relative_path, basename_pos, is_dir, case)
139- . map ( |idx| ( plidx, idx) )
140+ gix_ignore:: search:: pattern_idx_matching_relative_path (
141+ pl,
142+ relative_path,
143+ basename_pos,
144+ is_dir,
145+ case,
146+ )
147+ . map ( |idx| ( plidx, idx) )
140148 } )
141149 . map ( |( plidx, pidx) | ( gidx, plidx, pidx) )
142150 } )
@@ -163,17 +171,24 @@ impl Ignore {
163171 let ignore_file_in_index =
164172 attribute_files_in_index. binary_search_by ( |t| t. 0 . as_bstr ( ) . cmp ( ignore_path_relative. as_ref ( ) ) ) ;
165173 let follow_symlinks = ignore_file_in_index. is_err ( ) ;
166- if !self
167- . stack
168- . add_patterns_file ( dir. join ( ".gitignore" ) , follow_symlinks, Some ( root) , buf) ?
169- {
174+ if !gix_glob:: search:: add_patterns_file (
175+ & mut self . stack . patterns ,
176+ dir. join ( ".gitignore" ) ,
177+ follow_symlinks,
178+ Some ( root) ,
179+ buf,
180+ ) ? {
170181 match ignore_file_in_index {
171182 Ok ( idx) => {
172183 let ignore_blob = find ( & attribute_files_in_index[ idx] . 1 , buf)
173184 . map_err ( |err| std:: io:: Error :: new ( std:: io:: ErrorKind :: Other , err) ) ?;
174185 let ignore_path = gix_path:: from_bstring ( ignore_path_relative. into_owned ( ) ) ;
175- self . stack
176- . add_patterns_buffer ( ignore_blob. data , ignore_path, Some ( root) ) ;
186+ gix_glob:: search:: add_patterns_buffer (
187+ & mut self . stack . patterns ,
188+ ignore_blob. data ,
189+ ignore_path,
190+ Some ( root) ,
191+ ) ;
177192 }
178193 Err ( _) => {
179194 // Need one stack level per component so push and pop matches.
0 commit comments