X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=dir.c;h=2245749b3fe74f793bd1997d2238883abe61fc07;hb=2464456a6ac9216d59d9e2cf0d86fee072f63cf8;hp=d55a41a5abde946177e1123b075a13967d2f850f;hpb=9a01387b9714452ebcae431705a288e1a7e099c3;p=git.git diff --git a/dir.c b/dir.c index d55a41a5a..2245749b3 100644 --- a/dir.c +++ b/dir.c @@ -108,25 +108,28 @@ static int match_one(const char *match, const char *name, int namelen) * and a mark is left in seen[] array for pathspec element that * actually matched anything. */ -int match_pathspec(const char **pathspec, const char *name, int namelen, int prefix, char *seen) +int match_pathspec(const char **pathspec, const char *name, int namelen, + int prefix, char *seen) { - int retval; - const char *match; + int i, retval = 0; + + if (!pathspec) + return 1; name += prefix; namelen -= prefix; - for (retval = 0; (match = *pathspec++) != NULL; seen++) { + for (i = 0; pathspec[i] != NULL; i++) { int how; - if (retval && *seen == MATCHED_EXACTLY) + const char *match = pathspec[i] + prefix; + if (seen && seen[i] == MATCHED_EXACTLY) continue; - match += prefix; how = match_one(match, name, namelen); if (how) { if (retval < how) retval = how; - if (*seen < how) - *seen = how; + if (seen && seen[i] < how) + seen[i] = how; } } return retval; @@ -134,7 +137,7 @@ int match_pathspec(const char **pathspec, const char *name, int namelen, int pre static int no_wildcard(const char *string) { - return string[strcspn(string, "*?[{")] == '\0'; + return string[strcspn(string, "*?[{\\")] == '\0'; } void add_exclude(const char *string, const char *base,