summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorClemens Buchacher <drizzd@aon.at>2009-01-14 15:54:35 +0100
committerJunio C Hamano <gitster@pobox.com>2009-01-14 19:18:44 -0800
commit0b50922abffb82c473182b03eb5bb47a978cceac (patch)
tree25dac912a5f695b9117162cc59087e68e915bbfc /dir.c
parent1c7c1d179e51f163c014353f33b406f5bae13922 (diff)
downloadgit-0b50922abffb82c473182b03eb5bb47a978cceac.tar.gz
remove pathspec_match, use match_pathspec instead
Both versions have the same functionality. This removes any redundancy. This also adds makes two extensions to match_pathspec: - If pathspec is NULL, return 1. This reflects the behavior of git commands, for which no paths usually means "match all paths". - If seen is NULL, do not use it. Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
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 8b0e0fbaf7..c50ecc8d69 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 (*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;