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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
diff --git a/tests/attr/file.c b/tests/attr/file.c
index 1f4108c..ec67c27 100644
--- a/tests/attr/file.c
+++ b/tests/attr/file.c
@@ -181,16 +181,11 @@ void test_attr_file__assign_variants(void)
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_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);
cl_assert_equal_s("*.java", rule->match.pattern);
cl_assert(rule->assigns.length == 3);
@@ -219,6 +214,30 @@ void test_attr_file__check_attr_examples(void)
assign = get_assign(rule, 0);
cl_assert_equal_s("caveat", assign->name);
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);
}
diff --git a/tests/iterator/workdir.c b/tests/iterator/workdir.c
index 87ac1e5..9d3b543 100644
--- a/tests/iterator/workdir.c
+++ b/tests/iterator/workdir.c
@@ -100,7 +100,7 @@ static void workdir_iterator_test(
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[] = {
diff --git a/tests/resources/attr/attr4 b/tests/resources/attr/attr4
new file mode 100644
index 0000000..fa88df9
--- /dev/null
+++ b/tests/resources/attr/attr4
@@ -0,0 +1,7 @@
+# This is a comment
+ # This is also a comment
+*.java diff=java -crlf myAttr
+
+ NoMyAttr.java !myAttr
+
+ README caveat=unspecified