Skip to content

Commit e7fc860

Browse files
committed
filter: test that system attributes can be ignored
Test that we can optionally ignore system attributes when filtering a blob.
1 parent 45ddb58 commit e7fc860

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/filter/systemattrs.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,30 @@ void test_filter_systemattrs__reads_system_attributes(void)
5252
git_buf_dispose(&buf);
5353
git_blob_free(blob);
5454
}
55+
56+
void test_filter_systemattrs__disables_system_attributes(void)
57+
{
58+
git_blob *blob;
59+
git_buf buf = { 0 };
60+
git_blob_filter_options opts = GIT_BLOB_FILTER_OPTIONS_INIT;
61+
62+
opts.flags |= GIT_BLOB_FILTER_NO_SYSTEM_ATTRIBUTES;
63+
64+
cl_git_pass(git_revparse_single(
65+
(git_object **)&blob, g_repo, "799770d")); /* all-lf */
66+
67+
cl_assert_equal_s(ALL_LF_TEXT_RAW, git_blob_rawcontent(blob));
68+
69+
cl_git_pass(git_blob_filter(&buf, blob, "file.bin", &opts));
70+
cl_assert_equal_s(ALL_LF_TEXT_RAW, buf.ptr);
71+
72+
/* No attributes mean these are all treated literally */
73+
cl_git_pass(git_blob_filter(&buf, blob, "file.crlf", &opts));
74+
cl_assert_equal_s(ALL_LF_TEXT_RAW, buf.ptr);
75+
76+
cl_git_pass(git_blob_filter(&buf, blob, "file.lf", &opts));
77+
cl_assert_equal_s(ALL_LF_TEXT_RAW, buf.ptr);
78+
79+
git_buf_dispose(&buf);
80+
git_blob_free(blob);
81+
}

0 commit comments

Comments
 (0)