@@ -66,7 +66,7 @@ pub(super) fn recursive(
66
66
if can_recurse ( current_bstr. as_bstr ( ) , info, opts. for_deletion , delegate) {
67
67
let ( action, subdir_prevent_collapse) =
68
68
recursive ( false , current, current_bstr, info, ctx, opts, delegate, out, state) ?;
69
- prevent_collapse = subdir_prevent_collapse;
69
+ prevent_collapse | = subdir_prevent_collapse;
70
70
if action != Action :: Continue {
71
71
break ;
72
72
}
@@ -158,6 +158,7 @@ impl Mark {
158
158
} else {
159
159
dir_info. disk_kind
160
160
} ,
161
+ pathspec_match : filter_dir_pathspec ( dir_info. pathspec_match ) ,
161
162
..dir_info
162
163
} ;
163
164
if opts. should_hold ( empty_info. status ) {
@@ -174,18 +175,10 @@ impl Mark {
174
175
}
175
176
} else if * prevent_collapse {
176
177
self . emit_all_held ( state, opts, out, delegate)
177
- } else if let Some ( action) = self . try_collapse (
178
- dir_rela_path,
179
- dir_info,
180
- state,
181
- prevent_collapse,
182
- out,
183
- opts,
184
- ctx,
185
- delegate,
186
- ) {
178
+ } else if let Some ( action) = self . try_collapse ( dir_rela_path, dir_info, state, out, opts, ctx, delegate) {
187
179
action
188
180
} else {
181
+ * prevent_collapse = true ;
189
182
self . emit_all_held ( state, opts, out, delegate)
190
183
}
191
184
}
@@ -213,7 +206,6 @@ impl Mark {
213
206
dir_rela_path : & BStr ,
214
207
dir_info : classify:: Outcome ,
215
208
state : & mut State ,
216
- prevent_collapse : & mut bool ,
217
209
out : & mut walk:: Outcome ,
218
210
opts : Options ,
219
211
ctx : & mut Context < ' _ > ,
@@ -229,7 +221,6 @@ impl Mark {
229
221
{
230
222
entries += 1 ;
231
223
if kind == Some ( entry:: Kind :: Repository ) {
232
- * prevent_collapse = true ;
233
224
return None ;
234
225
}
235
226
if pathspec_match. map_or ( false , |m| {
@@ -287,12 +278,10 @@ impl Mark {
287
278
. filter_map ( |e| e. pathspec_match )
288
279
. max ( )
289
280
. or_else ( || {
290
- // Only take directory matches for value if they are above the 'guessed' ones.
281
+ // Only take directory matches as value if they are above the 'guessed' ones.
291
282
// Otherwise we end up with seemingly matched entries in the parent directory which
292
283
// affects proper folding.
293
- dir_info
294
- . pathspec_match
295
- . filter ( |m| matches ! ( m, PathspecMatch :: WildcardMatch | PathspecMatch :: Verbatim ) )
284
+ filter_dir_pathspec ( dir_info. pathspec_match )
296
285
} ) ;
297
286
let mut removed_without_emitting = 0 ;
298
287
let mut action = Action :: Continue ;
@@ -317,6 +306,15 @@ impl Mark {
317
306
}
318
307
}
319
308
309
+ fn filter_dir_pathspec ( current : Option < PathspecMatch > ) -> Option < PathspecMatch > {
310
+ current. filter ( |m| {
311
+ matches ! (
312
+ m,
313
+ PathspecMatch :: Always | PathspecMatch :: WildcardMatch | PathspecMatch :: Verbatim
314
+ )
315
+ } )
316
+ }
317
+
320
318
impl Options {
321
319
fn should_hold ( & self , status : entry:: Status ) -> bool {
322
320
if status. is_pruned ( ) {
0 commit comments