summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2012-10-15 13:24:39 +0700
committerJunio C Hamano <gitster@pobox.com>2012-10-15 14:57:17 -0700
commit82dce998c2028b6ee96691921b7037a6e182ec89 (patch)
treec521a6c799d79527e70672291afa0aa1e57da817 /dir.c
parent84460eec8dcc82417840bf4be2eb0c13d14b1c94 (diff)
downloadgit-82dce998c2028b6ee96691921b7037a6e182ec89.tar.gz
attr: more matching optimizations from .gitignore
.gitattributes and .gitignore share the same pattern syntax but has separate matching implementation. Over the years, ignore's implementation accumulates more optimizations while attr's stays the same. This patch reuses the core matching functions that are also used by excluded_from_list. excluded_from_list and path_matches can't be merged due to differences in exclude and attr, for example: * "!pattern" syntax is forbidden in .gitattributes. As an attribute can be unset (i.e. set to a special value "false") or made back to unspecified (i.e. not even set to "false"), "!pattern attr" is unclear which one it means. * we support attaching attributes to directories, but git-core internally does not currently make use of attributes on directories. 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.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/dir.c b/dir.c
index c4e64a5bc9..ee8e7115a8 100644
--- a/dir.c
+++ b/dir.c
@@ -308,10 +308,10 @@ static int no_wildcard(const char *string)
return string[simple_length(string)] == '\0';
}
-static void parse_exclude_pattern(const char **pattern,
- int *patternlen,
- int *flags,
- int *nowildcardlen)
+void parse_exclude_pattern(const char **pattern,
+ int *patternlen,
+ int *flags,
+ int *nowildcardlen)
{
const char *p = *pattern;
size_t i, len;
@@ -530,9 +530,9 @@ static void prep_exclude(struct dir_struct *dir, const char *base, int baselen)
dir->basebuf[baselen] = '\0';
}
-static int match_basename(const char *basename, int basenamelen,
- const char *pattern, int prefix, int patternlen,
- int flags)
+int match_basename(const char *basename, int basenamelen,
+ const char *pattern, int prefix, int patternlen,
+ int flags)
{
if (prefix == patternlen) {
if (!strcmp_icase(pattern, basename))
@@ -549,10 +549,10 @@ static int match_basename(const char *basename, int basenamelen,
return 0;
}
-static int match_pathname(const char *pathname, int pathlen,
- const char *base, int baselen,
- const char *pattern, int prefix, int patternlen,
- int flags)
+int match_pathname(const char *pathname, int pathlen,
+ const char *base, int baselen,
+ const char *pattern, int prefix, int patternlen,
+ int flags)
{
const char *name;
int namelen;