* Perform matching on the leading non-wildcard part of * pathspec. item->nowildcard_len must be greater than zero. Return * non-zero if base is matched. */
| 970 | * non-zero if base is matched. |
| 971 | */ |
| 972 | static int match_wildcard_base(const struct pathspec_item *item, |
| 973 | const char *base, int baselen, |
| 974 | int *matched) |
| 975 | { |
| 976 | const char *match = item->match; |
| 977 | /* the wildcard part is not considered in this function */ |
| 978 | int matchlen = item->nowildcard_len; |
| 979 | |
| 980 | if (baselen) { |
| 981 | int dirlen; |
| 982 | /* |
| 983 | * Return early if base is longer than the |
| 984 | * non-wildcard part but it does not match. |
| 985 | */ |
| 986 | if (baselen >= matchlen) { |
| 987 | *matched = matchlen; |
| 988 | return !basecmp(item, base, match, matchlen); |
| 989 | } |
| 990 | |
| 991 | dirlen = matchlen; |
| 992 | while (dirlen && match[dirlen - 1] != '/') |
| 993 | dirlen--; |
| 994 | |
| 995 | /* |
| 996 | * Return early if base is shorter than the |
| 997 | * non-wildcard part but it does not match. Note that |
| 998 | * base ends with '/' so we are sure it really matches |
| 999 | * directory |
| 1000 | */ |
| 1001 | if (basecmp(item, base, match, baselen)) |
| 1002 | return 0; |
| 1003 | *matched = baselen; |
| 1004 | } else |
| 1005 | *matched = 0; |
| 1006 | /* |
| 1007 | * we could have checked entry against the non-wildcard part |
| 1008 | * that is not in base and does similar never_interesting |
| 1009 | * optimization as in match_entry. For now just be happy with |
| 1010 | * base comparison. |
| 1011 | */ |
| 1012 | return entry_interesting; |
| 1013 | } |
| 1014 | |
| 1015 | /* |
| 1016 | * Is a tree entry interesting given the pathspec we have? |