@@ -195,6 +195,8 @@ int within_depth(const char *name, int namelen,
195
195
return 1 ;
196
196
}
197
197
198
+ #define DO_MATCH_EXCLUDE 1
199
+
198
200
/*
199
201
* Does 'match' match the given name?
200
202
* A match is found if
@@ -208,7 +210,7 @@ int within_depth(const char *name, int namelen,
208
210
* It returns 0 when there is no match.
209
211
*/
210
212
static int match_pathspec_item (const struct pathspec_item * item , int prefix ,
211
- const char * name , int namelen )
213
+ const char * name , int namelen , unsigned flags )
212
214
{
213
215
/* name/namelen has prefix cut off by caller */
214
216
const char * match = item -> match + prefix ;
@@ -285,9 +287,9 @@ static int match_pathspec_item(const struct pathspec_item *item, int prefix,
285
287
static int do_match_pathspec (const struct pathspec * ps ,
286
288
const char * name , int namelen ,
287
289
int prefix , char * seen ,
288
- int exclude )
290
+ unsigned flags )
289
291
{
290
- int i , retval = 0 ;
292
+ int i , retval = 0 , exclude = flags & DO_MATCH_EXCLUDE ;
291
293
292
294
GUARD_PATHSPEC (ps ,
293
295
PATHSPEC_FROMTOP |
@@ -327,7 +329,8 @@ static int do_match_pathspec(const struct pathspec *ps,
327
329
*/
328
330
if (seen && ps -> items [i ].magic & PATHSPEC_EXCLUDE )
329
331
seen [i ] = MATCHED_FNMATCH ;
330
- how = match_pathspec_item (ps -> items + i , prefix , name , namelen );
332
+ how = match_pathspec_item (ps -> items + i , prefix , name ,
333
+ namelen , flags );
331
334
if (ps -> recursive &&
332
335
(ps -> magic & PATHSPEC_MAXDEPTH ) &&
333
336
ps -> max_depth != -1 &&
@@ -355,10 +358,14 @@ int match_pathspec(const struct pathspec *ps,
355
358
int prefix , char * seen )
356
359
{
357
360
int positive , negative ;
358
- positive = do_match_pathspec (ps , name , namelen , prefix , seen , 0 );
361
+ unsigned flags = 0 ;
362
+ positive = do_match_pathspec (ps , name , namelen ,
363
+ prefix , seen , flags );
359
364
if (!(ps -> magic & PATHSPEC_EXCLUDE ) || !positive )
360
365
return positive ;
361
- negative = do_match_pathspec (ps , name , namelen , prefix , seen , 1 );
366
+ negative = do_match_pathspec (ps , name , namelen ,
367
+ prefix , seen ,
368
+ flags | DO_MATCH_EXCLUDE );
362
369
return negative ? 0 : positive ;
363
370
}
364
371
0 commit comments