summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-01-26 01:13:11 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-01-26 01:13:11 (GMT)
commitd64d4835b83669d5c9c8ce1989859efa803874db (patch)
tree6748e48171e74bb97dc56efa9e7d133a7674e1a2 /dir.c
parentf18e6bef23809d2823c1a687f375b22c6af0e735 (diff)
parent0b50922abffb82c473182b03eb5bb47a978cceac (diff)
downloadgit-d64d4835b83669d5c9c8ce1989859efa803874db.zip
git-d64d4835b83669d5c9c8ce1989859efa803874db.tar.gz
git-d64d4835b83669d5c9c8ce1989859efa803874db.tar.bz2
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.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/dir.c b/dir.c
index d55a41a..cfd1ea5 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;