Commit 4bcebe2c by Edward Thomson

attr: ensure regular attr files can have whitespace

Unlike ignore files, gitattribute files can have flexible whitespace at
the beginning of the line.  Ensure that by adding new ignore rules that
we have not impeded correct parsing of attribute files.
parent 63adcc4e
...@@ -181,16 +181,11 @@ void test_attr_file__assign_variants(void) ...@@ -181,16 +181,11 @@ void test_attr_file__assign_variants(void)
git_attr_file__free(file); git_attr_file__free(file);
} }
void test_attr_file__check_attr_examples(void) static void assert_examples(git_attr_file *file)
{ {
git_attr_file *file;
git_attr_rule *rule; git_attr_rule *rule;
git_attr_assignment *assign; git_attr_assignment *assign;
cl_git_pass(git_attr_file__load_standalone(&file, cl_fixture("attr/attr3")));
cl_assert_equal_s(cl_fixture("attr/attr3"), file->entry->path);
cl_assert(file->rules.length == 3);
rule = get_rule(0); rule = get_rule(0);
cl_assert_equal_s("*.java", rule->match.pattern); cl_assert_equal_s("*.java", rule->match.pattern);
cl_assert(rule->assigns.length == 3); cl_assert(rule->assigns.length == 3);
...@@ -219,6 +214,30 @@ void test_attr_file__check_attr_examples(void) ...@@ -219,6 +214,30 @@ void test_attr_file__check_attr_examples(void)
assign = get_assign(rule, 0); assign = get_assign(rule, 0);
cl_assert_equal_s("caveat", assign->name); cl_assert_equal_s("caveat", assign->name);
cl_assert_equal_s("unspecified", assign->value); cl_assert_equal_s("unspecified", assign->value);
}
void test_attr_file__check_attr_examples(void)
{
git_attr_file *file;
cl_git_pass(git_attr_file__load_standalone(&file, cl_fixture("attr/attr3")));
cl_assert_equal_s(cl_fixture("attr/attr3"), file->entry->path);
cl_assert(file->rules.length == 3);
assert_examples(file);
git_attr_file__free(file);
}
void test_attr_file__whitespace(void)
{
git_attr_file *file;
cl_git_pass(git_attr_file__load_standalone(&file, cl_fixture("attr/attr4")));
cl_assert_equal_s(cl_fixture("attr/attr4"), file->entry->path);
cl_assert(file->rules.length == 3);
assert_examples(file);
git_attr_file__free(file); git_attr_file__free(file);
} }
...@@ -100,7 +100,7 @@ static void workdir_iterator_test( ...@@ -100,7 +100,7 @@ static void workdir_iterator_test(
void test_iterator_workdir__0(void) void test_iterator_workdir__0(void)
{ {
workdir_iterator_test("attr", NULL, NULL, 23, 5, NULL, "ign"); workdir_iterator_test("attr", NULL, NULL, 24, 5, NULL, "ign");
} }
static const char *status_paths[] = { static const char *status_paths[] = {
......
# This is a comment
# This is also a comment
*.java diff=java -crlf myAttr
NoMyAttr.java !myAttr
README caveat=unspecified
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment