@@ -6,8 +6,8 @@ use gix_hash::oid;
6
6
7
7
use crate :: fs:: { cache:: State , PathOidMapping } ;
8
8
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 ;
11
11
12
12
/// State related to attributes associated with files in the repository.
13
13
#[ derive( Default , Clone ) ]
@@ -44,6 +44,8 @@ pub struct Ignore {
44
44
impl Ignore {
45
45
/// The `exclude_file_name_for_directories` is an optional override for the filename to use when checking per-directory
46
46
/// 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
47
49
// TODO: more docs
48
50
pub fn new (
49
51
overrides : IgnoreMatchGroup ,
@@ -79,7 +81,7 @@ impl Ignore {
79
81
relative_path : & BStr ,
80
82
is_dir : Option < bool > ,
81
83
case : Case ,
82
- ) -> Option < gix_attributes :: Match < ' _ , ( ) > > {
84
+ ) -> Option < gix_ignore :: search :: Match < ' _ , ( ) > > {
83
85
let groups = self . match_groups ( ) ;
84
86
let mut dir_match = None ;
85
87
if let Some ( ( source, mapping) ) = self
@@ -93,7 +95,7 @@ impl Ignore {
93
95
} )
94
96
. next ( )
95
97
{
96
- let match_ = gix_attributes :: Match {
98
+ let match_ = gix_ignore :: search :: Match {
97
99
pattern : & mapping. pattern ,
98
100
value : & mapping. value ,
99
101
sequence_number : mapping. sequence_number ,
@@ -135,8 +137,14 @@ impl Ignore {
135
137
. enumerate ( )
136
138
. rev ( )
137
139
. 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) )
140
148
} )
141
149
. map ( |( plidx, pidx) | ( gidx, plidx, pidx) )
142
150
} )
@@ -163,17 +171,24 @@ impl Ignore {
163
171
let ignore_file_in_index =
164
172
attribute_files_in_index. binary_search_by ( |t| t. 0 . as_bstr ( ) . cmp ( ignore_path_relative. as_ref ( ) ) ) ;
165
173
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
+ ) ? {
170
181
match ignore_file_in_index {
171
182
Ok ( idx) => {
172
183
let ignore_blob = find ( & attribute_files_in_index[ idx] . 1 , buf)
173
184
. map_err ( |err| std:: io:: Error :: new ( std:: io:: ErrorKind :: Other , err) ) ?;
174
185
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
+ ) ;
177
192
}
178
193
Err ( _) => {
179
194
// Need one stack level per component so push and pop matches.
0 commit comments