Merge branch 'cb/add-pathspec'

* cb/add-pathspec:
  remove pathspec_match, use match_pathspec instead
  clean up pathspec matching
This commit is contained in:
Junio C Hamano
2009-01-25 17:13:11 -08:00
5 changed files with 17 additions and 51 deletions

19
dir.c
View File

@ -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;