* Scan the given exclude list in reverse to see whether pathname * should be ignored. The first match (i.e. the last on the list), if * any, determines the fate. Returns the exclude_list element which * matched, or NULL for undecided. */
| 1421 | * matched, or NULL for undecided. |
| 1422 | */ |
| 1423 | static struct path_pattern *last_matching_pattern_from_list(const char *pathname, |
| 1424 | int pathlen, |
| 1425 | const char *basename, |
| 1426 | int *dtype, |
| 1427 | struct pattern_list *pl, |
| 1428 | struct index_state *istate) |
| 1429 | { |
| 1430 | struct path_pattern *res = NULL; /* undecided */ |
| 1431 | int i; |
| 1432 | |
| 1433 | if (!pl->nr) |
| 1434 | return NULL; /* undefined */ |
| 1435 | |
| 1436 | for (i = pl->nr - 1; 0 <= i; i--) { |
| 1437 | struct path_pattern *pattern = pl->patterns[i]; |
| 1438 | const char *exclude = pattern->pattern; |
| 1439 | int prefix = pattern->nowildcardlen; |
| 1440 | |
| 1441 | if (pattern->flags & PATTERN_FLAG_MUSTBEDIR) { |
| 1442 | *dtype = resolve_dtype(*dtype, istate, pathname, pathlen); |
| 1443 | if (*dtype != DT_DIR) |
| 1444 | continue; |
| 1445 | } |
| 1446 | |
| 1447 | if (pattern->flags & PATTERN_FLAG_NODIR) { |
| 1448 | if (match_basename(basename, |
| 1449 | pathlen - (basename - pathname), |
| 1450 | exclude, prefix, pattern->patternlen, |
| 1451 | pattern->flags)) { |
| 1452 | res = pattern; |
| 1453 | break; |
| 1454 | } |
| 1455 | continue; |
| 1456 | } |
| 1457 | |
| 1458 | assert(pattern->baselen == 0 || |
| 1459 | pattern->base[pattern->baselen - 1] == '/'); |
| 1460 | if (match_pathname(pathname, pathlen, |
| 1461 | pattern->base, |
| 1462 | pattern->baselen ? pattern->baselen - 1 : 0, |
| 1463 | exclude, prefix, pattern->patternlen)) { |
| 1464 | res = pattern; |
| 1465 | break; |
| 1466 | } |
| 1467 | } |
| 1468 | return res; |
| 1469 | } |
| 1470 | |
| 1471 | /* |
| 1472 | * Scan the list of patterns to determine if the ordered list |
no test coverage detected