diff options
author | Junio C Hamano <gitster@pobox.com> | 2009-01-25 17:13:11 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-01-25 17:13:11 -0800 |
commit | d64d4835b83669d5c9c8ce1989859efa803874db (patch) | |
tree | 6748e48171e74bb97dc56efa9e7d133a7674e1a2 /dir.c | |
parent | f18e6bef23809d2823c1a687f375b22c6af0e735 (diff) | |
parent | 0b50922abffb82c473182b03eb5bb47a978cceac (diff) | |
download | git-d64d4835b83669d5c9c8ce1989859efa803874db.tar.gz |
Merge branch 'cb/add-pathspec'
* cb/add-pathspec:
remove pathspec_match, use match_pathspec instead
clean up pathspec matching
Diffstat (limited to 'dir.c')
-rw-r--r-- | dir.c | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -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; |