summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2013-07-14 08:36:00 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-07-15 17:56:09 (GMT)
commit84b8b5d1fa244bc591291a3cf18bf0fa9976ad17 (patch)
tree67f5a9e9a0c5cb67fcd3694055403fcd4936b2be /dir.c
parent9a0872744315da67db3c81eb9270751e31fcc8f5 (diff)
downloadgit-84b8b5d1fa244bc591291a3cf18bf0fa9976ad17.zip
git-84b8b5d1fa244bc591291a3cf18bf0fa9976ad17.tar.gz
git-84b8b5d1fa244bc591291a3cf18bf0fa9976ad17.tar.bz2
remove match_pathspec() in favor of match_pathspec_depth()
match_pathspec_depth was created to replace match_pathspec (see 61cf282 (pathspec: add match_pathspec_depth() - 2010-12-15). It took more than two years, but the replacement finally happens :-) Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c107
1 files changed, 0 insertions, 107 deletions
diff --git a/dir.c b/dir.c
index 959e694..9423fbb 100644
--- a/dir.c
+++ b/dir.c
@@ -183,113 +183,6 @@ int within_depth(const char *name, int namelen,
*
* It returns 0 when there is no match.
*/
-static int match_one(const char *match, const char *name, int namelen)
-{
- int matchlen;
- int literal = limit_pathspec_to_literal();
-
- /* If the match was just the prefix, we matched */
- if (!*match)
- return MATCHED_RECURSIVELY;
-
- if (ignore_case) {
- for (;;) {
- unsigned char c1 = tolower(*match);
- unsigned char c2 = tolower(*name);
- if (c1 == '\0' || (!literal && is_glob_special(c1)))
- break;
- if (c1 != c2)
- return 0;
- match++;
- name++;
- namelen--;
- }
- } else {
- for (;;) {
- unsigned char c1 = *match;
- unsigned char c2 = *name;
- if (c1 == '\0' || (!literal && is_glob_special(c1)))
- break;
- if (c1 != c2)
- return 0;
- match++;
- name++;
- namelen--;
- }
- }
-
- /*
- * If we don't match the matchstring exactly,
- * we need to match by fnmatch
- */
- matchlen = strlen(match);
- if (strncmp_icase(match, name, matchlen)) {
- if (literal)
- return 0;
- return !fnmatch_icase(match, name, 0) ? MATCHED_FNMATCH : 0;
- }
-
- if (namelen == matchlen)
- return MATCHED_EXACTLY;
- if (match[matchlen-1] == '/' || name[matchlen] == '/')
- return MATCHED_RECURSIVELY;
- return 0;
-}
-
-/*
- * Given a name and a list of pathspecs, returns the nature of the
- * closest (i.e. most specific) match of the name to any of the
- * pathspecs.
- *
- * The caller typically calls this multiple times with the same
- * pathspec and seen[] array but with different name/namelen
- * (e.g. entries from the index) and is interested in seeing if and
- * how each pathspec matches all the names it calls this function
- * with. A mark is left in the seen[] array for each pathspec element
- * indicating the closest type of match that element achieved, so if
- * seen[n] remains zero after multiple invocations, that means the nth
- * pathspec did not match any names, which could indicate that the
- * user mistyped the nth pathspec.
- */
-int match_pathspec(const char **pathspec, const char *name, int namelen,
- int prefix, char *seen)
-{
- int i, retval = 0;
-
- if (!pathspec)
- return 1;
-
- name += prefix;
- namelen -= prefix;
-
- for (i = 0; pathspec[i] != NULL; i++) {
- int how;
- const char *match = pathspec[i] + prefix;
- if (seen && seen[i] == MATCHED_EXACTLY)
- continue;
- how = match_one(match, name, namelen);
- if (how) {
- if (retval < how)
- retval = how;
- if (seen && seen[i] < how)
- seen[i] = how;
- }
- }
- return retval;
-}
-
-/*
- * Does 'match' match the given name?
- * A match is found if
- *
- * (1) the 'match' string is leading directory of 'name', or
- * (2) the 'match' string is a wildcard and matches 'name', or
- * (3) the 'match' string is exactly the same as 'name'.
- *
- * and the return value tells which case it was.
- *
- * It returns 0 when there is no match.
- */
static int match_pathspec_item(const struct pathspec_item *item, int prefix,
const char *name, int namelen)
{