Skip to content

Commit 4bcebe2

Browse files
committed
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 parent 63adcc4 commit 4bcebe2

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

tests/attr/file.c

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,11 @@ void test_attr_file__assign_variants(void)
181181
git_attr_file__free(file);
182182
}
183183

184-
void test_attr_file__check_attr_examples(void)
184+
static void assert_examples(git_attr_file *file)
185185
{
186-
git_attr_file *file;
187186
git_attr_rule *rule;
188187
git_attr_assignment *assign;
189188

190-
cl_git_pass(git_attr_file__load_standalone(&file, cl_fixture("attr/attr3")));
191-
cl_assert_equal_s(cl_fixture("attr/attr3"), file->entry->path);
192-
cl_assert(file->rules.length == 3);
193-
194189
rule = get_rule(0);
195190
cl_assert_equal_s("*.java", rule->match.pattern);
196191
cl_assert(rule->assigns.length == 3);
@@ -219,6 +214,30 @@ void test_attr_file__check_attr_examples(void)
219214
assign = get_assign(rule, 0);
220215
cl_assert_equal_s("caveat", assign->name);
221216
cl_assert_equal_s("unspecified", assign->value);
217+
}
218+
219+
void test_attr_file__check_attr_examples(void)
220+
{
221+
git_attr_file *file;
222+
223+
cl_git_pass(git_attr_file__load_standalone(&file, cl_fixture("attr/attr3")));
224+
cl_assert_equal_s(cl_fixture("attr/attr3"), file->entry->path);
225+
cl_assert(file->rules.length == 3);
226+
227+
assert_examples(file);
228+
229+
git_attr_file__free(file);
230+
}
231+
232+
void test_attr_file__whitespace(void)
233+
{
234+
git_attr_file *file;
235+
236+
cl_git_pass(git_attr_file__load_standalone(&file, cl_fixture("attr/attr4")));
237+
cl_assert_equal_s(cl_fixture("attr/attr4"), file->entry->path);
238+
cl_assert(file->rules.length == 3);
239+
240+
assert_examples(file);
222241

223242
git_attr_file__free(file);
224243
}

tests/iterator/workdir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static void workdir_iterator_test(
100100

101101
void test_iterator_workdir__0(void)
102102
{
103-
workdir_iterator_test("attr", NULL, NULL, 23, 5, NULL, "ign");
103+
workdir_iterator_test("attr", NULL, NULL, 24, 5, NULL, "ign");
104104
}
105105

106106
static const char *status_paths[] = {

tests/resources/attr/attr4

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This is a comment
2+
# This is also a comment
3+
*.java diff=java -crlf myAttr
4+
5+
NoMyAttr.java !myAttr
6+
7+
README caveat=unspecified

0 commit comments

Comments
 (0)