From d0bfd026a8241d544c339944976927b388d61a5e Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 12 Apr 2007 01:07:32 -0700 Subject: Add basic infrastructure to assign attributes to paths This adds the basic infrastructure to assign attributes to paths, in a way similar to what the exclusion mechanism does based on $GIT_DIR/info/exclude and .gitignore files. An attribute is just a simple string that does not contain any whitespace. They can be specified in $GIT_DIR/info/attributes file, and .gitattributes file in each directory. Each line in these files defines a pattern matching rule. Similar to the exclusion mechanism, a later match overrides an earlier match in the same file, and entries from .gitattributes file in the same directory takes precedence over the ones from parent directories. Lines in $GIT_DIR/info/attributes file are used as the lowest precedence default rules. A line is either a comment (an empty line, or a line that begins with a '#'), or a rule, which is a whitespace separated list of tokens. The first token on the line is a shell glob pattern. The rest are names of attributes, each of which can optionally be prefixed with '!'. Such a line means "if a path matches this glob, this attribute is set (or unset -- if the attribute name is prefixed with '!'). For glob matching, the same "if the pattern does not have a slash in it, the basename of the path is matched with fnmatch(3) against the pattern, otherwise, the path is matched with the pattern with FNM_PATHNAME" rule as the exclusion mechanism is used. This does not define what an attribute means. Tying an attribute to various effects it has on git operation for paths that have it will be specified separately. Signed-off-by: Junio C Hamano --- attr.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 attr.h (limited to 'attr.h') diff --git a/attr.h b/attr.h new file mode 100644 index 000000000..1e5ab4069 --- /dev/null +++ b/attr.h @@ -0,0 +1,16 @@ +#ifndef ATTR_H +#define ATTR_H + +/* An attribute is a pointer to this opaque structure */ +struct git_attr; + +struct git_attr *git_attr(const char *, int); + +struct git_attr_check { + struct git_attr *attr; + int isset; +}; + +int git_checkattr(const char *path, int, struct git_attr_check *); + +#endif /* ATTR_H */ -- cgit v1.2.1