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 <junkio@cox.net>
2007-04-12 12:07:32 +04:00
|
|
|
#include "builtin.h"
|
2007-08-14 17:18:38 +04:00
|
|
|
#include "cache.h"
|
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 <junkio@cox.net>
2007-04-12 12:07:32 +04:00
|
|
|
#include "attr.h"
|
|
|
|
#include "quote.h"
|
2008-10-07 04:16:52 +04:00
|
|
|
#include "parse-options.h"
|
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 <junkio@cox.net>
2007-04-12 12:07:32 +04:00
|
|
|
|
2011-08-04 08:36:30 +04:00
|
|
|
static int all_attrs;
|
2011-09-23 01:44:20 +04:00
|
|
|
static int cached_attrs;
|
2008-10-07 04:16:52 +04:00
|
|
|
static int stdin_paths;
|
|
|
|
static const char * const check_attr_usage[] = {
|
2012-08-20 16:31:57 +04:00
|
|
|
N_("git check-attr [-a | --all | attr...] [--] pathname..."),
|
2012-09-18 02:59:34 +04:00
|
|
|
N_("git check-attr --stdin [-z] [-a | --all | attr...] < <list-of-paths>"),
|
2008-10-07 04:16:52 +04:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2013-07-12 09:56:24 +04:00
|
|
|
static int nul_term_line;
|
2008-10-07 04:16:52 +04:00
|
|
|
|
|
|
|
static const struct option check_attr_options[] = {
|
2013-08-03 15:51:19 +04:00
|
|
|
OPT_BOOL('a', "all", &all_attrs, N_("report all attributes set on file")),
|
|
|
|
OPT_BOOL(0, "cached", &cached_attrs, N_("use .gitattributes only from the index")),
|
|
|
|
OPT_BOOL(0 , "stdin", &stdin_paths, N_("read file names from stdin")),
|
2013-09-04 23:39:02 +04:00
|
|
|
OPT_BOOL('z', NULL, &nul_term_line,
|
|
|
|
N_("terminate input and output records by a NUL character")),
|
2008-10-07 04:16:52 +04:00
|
|
|
OPT_END()
|
|
|
|
};
|
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 <junkio@cox.net>
2007-04-12 12:07:32 +04:00
|
|
|
|
2011-08-04 08:36:24 +04:00
|
|
|
static void output_attr(int cnt, struct git_attr_check *check,
|
2011-08-04 08:36:18 +04:00
|
|
|
const char *file)
|
2008-10-07 04:14:18 +04:00
|
|
|
{
|
|
|
|
int j;
|
|
|
|
for (j = 0; j < cnt; j++) {
|
|
|
|
const char *value = check[j].value;
|
|
|
|
|
|
|
|
if (ATTR_TRUE(value))
|
|
|
|
value = "set";
|
|
|
|
else if (ATTR_FALSE(value))
|
|
|
|
value = "unset";
|
|
|
|
else if (ATTR_UNSET(value))
|
|
|
|
value = "unspecified";
|
|
|
|
|
2013-07-12 10:02:40 +04:00
|
|
|
if (nul_term_line) {
|
|
|
|
printf("%s%c" /* path */
|
|
|
|
"%s%c" /* attrname */
|
|
|
|
"%s%c" /* attrvalue */,
|
|
|
|
file, 0, git_attr_name(check[j].attr), 0, value, 0);
|
|
|
|
} else {
|
|
|
|
quote_c_style(file, NULL, stdout, 0);
|
|
|
|
printf(": %s: %s\n", git_attr_name(check[j].attr), value);
|
|
|
|
}
|
|
|
|
|
2008-10-07 04:14:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-04 08:47:46 +04:00
|
|
|
static void check_attr(const char *prefix, int cnt,
|
|
|
|
struct git_attr_check *check, const char *file)
|
2011-08-04 08:36:24 +04:00
|
|
|
{
|
2011-08-04 08:47:46 +04:00
|
|
|
char *full_path =
|
|
|
|
prefix_path(prefix, prefix ? strlen(prefix) : 0, file);
|
2011-08-04 08:36:30 +04:00
|
|
|
if (check != NULL) {
|
2011-08-04 08:47:46 +04:00
|
|
|
if (git_check_attr(full_path, cnt, check))
|
2011-08-04 08:36:33 +04:00
|
|
|
die("git_check_attr died");
|
2011-08-04 08:36:30 +04:00
|
|
|
output_attr(cnt, check, file);
|
|
|
|
} else {
|
2011-08-04 08:47:46 +04:00
|
|
|
if (git_all_attrs(full_path, &cnt, &check))
|
2011-08-04 08:36:30 +04:00
|
|
|
die("git_all_attrs died");
|
|
|
|
output_attr(cnt, check, file);
|
|
|
|
free(check);
|
|
|
|
}
|
2011-08-04 08:47:46 +04:00
|
|
|
free(full_path);
|
2011-08-04 08:36:24 +04:00
|
|
|
}
|
|
|
|
|
2011-08-04 08:47:46 +04:00
|
|
|
static void check_attr_stdin_paths(const char *prefix, int cnt,
|
|
|
|
struct git_attr_check *check)
|
2008-10-07 04:16:52 +04:00
|
|
|
{
|
|
|
|
struct strbuf buf, nbuf;
|
2013-07-12 09:56:24 +04:00
|
|
|
int line_termination = nul_term_line ? 0 : '\n';
|
2008-10-07 04:16:52 +04:00
|
|
|
|
|
|
|
strbuf_init(&buf, 0);
|
|
|
|
strbuf_init(&nbuf, 0);
|
|
|
|
while (strbuf_getline(&buf, stdin, line_termination) != EOF) {
|
|
|
|
if (line_termination && buf.buf[0] == '"') {
|
|
|
|
strbuf_reset(&nbuf);
|
|
|
|
if (unquote_c_style(&nbuf, buf.buf, NULL))
|
|
|
|
die("line is badly quoted");
|
|
|
|
strbuf_swap(&buf, &nbuf);
|
|
|
|
}
|
2011-08-04 08:47:46 +04:00
|
|
|
check_attr(prefix, cnt, check, buf.buf);
|
2008-10-07 04:16:52 +04:00
|
|
|
maybe_flush_or_die(stdout, "attribute to stdout");
|
|
|
|
}
|
|
|
|
strbuf_release(&buf);
|
|
|
|
strbuf_release(&nbuf);
|
|
|
|
}
|
|
|
|
|
2011-08-04 08:36:26 +04:00
|
|
|
static NORETURN void error_with_usage(const char *msg)
|
|
|
|
{
|
|
|
|
error("%s", msg);
|
|
|
|
usage_with_options(check_attr_usage, check_attr_options);
|
|
|
|
}
|
|
|
|
|
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 <junkio@cox.net>
2007-04-12 12:07:32 +04:00
|
|
|
int cmd_check_attr(int argc, const char **argv, const char *prefix)
|
|
|
|
{
|
|
|
|
struct git_attr_check *check;
|
2011-08-04 08:36:25 +04:00
|
|
|
int cnt, i, doubledash, filei;
|
2008-10-07 04:16:52 +04:00
|
|
|
|
2014-02-06 22:19:33 +04:00
|
|
|
if (!is_bare_repository())
|
|
|
|
setup_work_tree();
|
|
|
|
|
2011-10-06 22:22:24 +04:00
|
|
|
git_config(git_default_config, NULL);
|
|
|
|
|
2009-05-23 22:53:12 +04:00
|
|
|
argc = parse_options(argc, argv, prefix, check_attr_options,
|
|
|
|
check_attr_usage, PARSE_OPT_KEEP_DASHDASH);
|
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 <junkio@cox.net>
2007-04-12 12:07:32 +04:00
|
|
|
|
2007-08-14 17:18:38 +04:00
|
|
|
if (read_cache() < 0) {
|
|
|
|
die("invalid cache");
|
|
|
|
}
|
|
|
|
|
2011-09-23 01:44:20 +04:00
|
|
|
if (cached_attrs)
|
|
|
|
git_attr_set_direction(GIT_ATTR_INDEX, NULL);
|
|
|
|
|
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 <junkio@cox.net>
2007-04-12 12:07:32 +04:00
|
|
|
doubledash = -1;
|
2008-10-07 04:16:52 +04:00
|
|
|
for (i = 0; doubledash < 0 && i < argc; i++) {
|
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 <junkio@cox.net>
2007-04-12 12:07:32 +04:00
|
|
|
if (!strcmp(argv[i], "--"))
|
|
|
|
doubledash = i;
|
|
|
|
}
|
|
|
|
|
2011-08-04 08:36:30 +04:00
|
|
|
/* Process --all and/or attribute arguments: */
|
|
|
|
if (all_attrs) {
|
|
|
|
if (doubledash >= 1)
|
|
|
|
error_with_usage("Attributes and --all both specified");
|
|
|
|
|
|
|
|
cnt = 0;
|
|
|
|
filei = doubledash + 1;
|
|
|
|
} else if (doubledash == 0) {
|
2011-08-04 08:36:28 +04:00
|
|
|
error_with_usage("No attribute specified");
|
|
|
|
} else if (doubledash < 0) {
|
|
|
|
if (!argc)
|
|
|
|
error_with_usage("No attribute specified");
|
|
|
|
|
2011-08-04 08:36:32 +04:00
|
|
|
if (stdin_paths) {
|
|
|
|
/* Treat all arguments as attribute names. */
|
|
|
|
cnt = argc;
|
|
|
|
filei = argc;
|
|
|
|
} else {
|
|
|
|
/* Treat exactly one argument as an attribute name. */
|
|
|
|
cnt = 1;
|
|
|
|
filei = 1;
|
|
|
|
}
|
2011-08-04 08:36:25 +04:00
|
|
|
} else {
|
2008-10-07 04:16:52 +04:00
|
|
|
cnt = doubledash;
|
2011-08-04 08:36:25 +04:00
|
|
|
filei = doubledash + 1;
|
|
|
|
}
|
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 <junkio@cox.net>
2007-04-12 12:07:32 +04:00
|
|
|
|
2011-08-04 08:36:28 +04:00
|
|
|
/* Check file argument(s): */
|
2011-08-04 08:36:29 +04:00
|
|
|
if (stdin_paths) {
|
|
|
|
if (filei < argc)
|
|
|
|
error_with_usage("Can't specify files with --stdin");
|
|
|
|
} else {
|
|
|
|
if (filei >= argc)
|
|
|
|
error_with_usage("No file specified");
|
|
|
|
}
|
2008-10-07 04:16:52 +04:00
|
|
|
|
2011-08-04 08:36:30 +04:00
|
|
|
if (all_attrs) {
|
|
|
|
check = NULL;
|
|
|
|
} else {
|
|
|
|
check = xcalloc(cnt, sizeof(*check));
|
|
|
|
for (i = 0; i < cnt; i++) {
|
|
|
|
const char *name;
|
|
|
|
struct git_attr *a;
|
|
|
|
name = argv[i];
|
|
|
|
a = git_attr(name);
|
|
|
|
if (!a)
|
|
|
|
return error("%s: not a valid attribute name",
|
|
|
|
name);
|
|
|
|
check[i].attr = a;
|
|
|
|
}
|
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 <junkio@cox.net>
2007-04-12 12:07:32 +04:00
|
|
|
}
|
|
|
|
|
2008-10-07 04:16:52 +04:00
|
|
|
if (stdin_paths)
|
2011-08-04 08:47:46 +04:00
|
|
|
check_attr_stdin_paths(prefix, cnt, check);
|
2008-10-07 04:16:52 +04:00
|
|
|
else {
|
2011-08-04 08:36:25 +04:00
|
|
|
for (i = filei; i < argc; i++)
|
2011-08-04 08:47:46 +04:00
|
|
|
check_attr(prefix, cnt, check, argv[i]);
|
2008-10-07 04:16:52 +04:00
|
|
|
maybe_flush_or_die(stdout, "attribute to stdout");
|
|
|
|
}
|
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 <junkio@cox.net>
2007-04-12 12:07:32 +04:00
|
|
|
return 0;
|
|
|
|
}
|