@@ -23,7 +23,9 @@ void test_filter_crlf__to_worktree(void)
2323{
2424 git_filter_list * fl ;
2525 git_filter * crlf ;
26- git_buf in = { 0 }, out = { 0 };
26+ git_buf out = GIT_BUF_INIT ;
27+ const char * in ;
28+ size_t in_len ;
2729
2830 cl_git_pass (git_filter_list_new (
2931 & fl , g_repo , GIT_FILTER_TO_WORKTREE , 0 ));
@@ -33,10 +35,10 @@ void test_filter_crlf__to_worktree(void)
3335
3436 cl_git_pass (git_filter_list_push (fl , crlf , NULL ));
3537
36- in . ptr = "Some text\nRight here\n" ;
37- in . size = strlen (in . ptr );
38+ in = "Some text\nRight here\n" ;
39+ in_len = strlen (in );
3840
39- cl_git_pass (git_filter_list_apply_to_data (& out , fl , & in ));
41+ cl_git_pass (git_filter_list_apply_to_buffer (& out , fl , in , in_len ));
4042
4143 cl_assert_equal_s ("Some text\r\nRight here\r\n" , out .ptr );
4244
@@ -48,7 +50,9 @@ void test_filter_crlf__to_odb(void)
4850{
4951 git_filter_list * fl ;
5052 git_filter * crlf ;
51- git_buf in = { 0 }, out = { 0 };
53+ git_buf out = GIT_BUF_INIT ;
54+ const char * in ;
55+ size_t in_len ;
5256
5357 cl_git_pass (git_filter_list_new (
5458 & fl , g_repo , GIT_FILTER_TO_ODB , 0 ));
@@ -58,10 +62,10 @@ void test_filter_crlf__to_odb(void)
5862
5963 cl_git_pass (git_filter_list_push (fl , crlf , NULL ));
6064
61- in . ptr = "Some text\r\nRight here\r\n" ;
62- in . size = strlen (in . ptr );
65+ in = "Some text\r\nRight here\r\n" ;
66+ in_len = strlen (in );
6367
64- cl_git_pass (git_filter_list_apply_to_data (& out , fl , & in ));
68+ cl_git_pass (git_filter_list_apply_to_buffer (& out , fl , in , in_len ));
6569
6670 cl_assert_equal_s ("Some text\nRight here\n" , out .ptr );
6771
@@ -73,7 +77,9 @@ void test_filter_crlf__with_safecrlf(void)
7377{
7478 git_filter_list * fl ;
7579 git_filter * crlf ;
76- git_buf in = {0 }, out = GIT_BUF_INIT ;
80+ git_buf out = GIT_BUF_INIT ;
81+ const char * in ;
82+ size_t in_len ;
7783
7884 cl_repo_set_bool (g_repo , "core.safecrlf" , true);
7985
@@ -86,31 +92,31 @@ void test_filter_crlf__with_safecrlf(void)
8692 cl_git_pass (git_filter_list_push (fl , crlf , NULL ));
8793
8894 /* Normalized \r\n succeeds with safecrlf */
89- in . ptr = "Normal\r\nCRLF\r\nline-endings.\r\n" ;
90- in . size = strlen (in . ptr );
95+ in = "Normal\r\nCRLF\r\nline-endings.\r\n" ;
96+ in_len = strlen (in );
9197
92- cl_git_pass (git_filter_list_apply_to_data (& out , fl , & in ));
98+ cl_git_pass (git_filter_list_apply_to_buffer (& out , fl , in , in_len ));
9399 cl_assert_equal_s ("Normal\nCRLF\nline-endings.\n" , out .ptr );
94100
95101 /* Mix of line endings fails with safecrlf */
96- in . ptr = "Mixed\nup\r\nLF\nand\r\nCRLF\nline-endings.\r\n" ;
97- in . size = strlen (in . ptr );
102+ in = "Mixed\nup\r\nLF\nand\r\nCRLF\nline-endings.\r\n" ;
103+ in_len = strlen (in );
98104
99- cl_git_fail (git_filter_list_apply_to_data (& out , fl , & in ));
105+ cl_git_fail (git_filter_list_apply_to_buffer (& out , fl , in , in_len ));
100106 cl_assert_equal_i (git_error_last ()-> klass , GIT_ERROR_FILTER );
101107
102108 /* Normalized \n fails for autocrlf=true when safecrlf=true */
103- in . ptr = "Normal\nLF\nonly\nline-endings.\n" ;
104- in . size = strlen (in . ptr );
109+ in = "Normal\nLF\nonly\nline-endings.\n" ;
110+ in_len = strlen (in );
105111
106- cl_git_fail (git_filter_list_apply_to_data (& out , fl , & in ));
112+ cl_git_fail (git_filter_list_apply_to_buffer (& out , fl , in , in_len ));
107113 cl_assert_equal_i (git_error_last ()-> klass , GIT_ERROR_FILTER );
108114
109115 /* String with \r but without \r\n does not fail with safecrlf */
110- in . ptr = "Normal\nCR only\rand some more\nline-endings.\n" ;
111- in . size = strlen (in . ptr );
116+ in = "Normal\nCR only\rand some more\nline-endings.\n" ;
117+ in_len = strlen (in );
112118
113- cl_git_pass (git_filter_list_apply_to_data (& out , fl , & in ));
119+ cl_git_pass (git_filter_list_apply_to_buffer (& out , fl , in , in_len ));
114120 cl_assert_equal_s ("Normal\nCR only\rand some more\nline-endings.\n" , out .ptr );
115121
116122 git_filter_list_free (fl );
@@ -121,7 +127,9 @@ void test_filter_crlf__with_safecrlf_and_unsafe_allowed(void)
121127{
122128 git_filter_list * fl ;
123129 git_filter * crlf ;
124- git_buf in = {0 }, out = GIT_BUF_INIT ;
130+ git_buf out = GIT_BUF_INIT ;
131+ const char * in ;
132+ size_t in_len ;
125133
126134 cl_repo_set_bool (g_repo , "core.safecrlf" , true);
127135
@@ -134,25 +142,25 @@ void test_filter_crlf__with_safecrlf_and_unsafe_allowed(void)
134142 cl_git_pass (git_filter_list_push (fl , crlf , NULL ));
135143
136144 /* Normalized \r\n succeeds with safecrlf */
137- in . ptr = "Normal\r\nCRLF\r\nline-endings.\r\n" ;
138- in . size = strlen (in . ptr );
145+ in = "Normal\r\nCRLF\r\nline-endings.\r\n" ;
146+ in_len = strlen (in );
139147
140- cl_git_pass (git_filter_list_apply_to_data (& out , fl , & in ));
148+ cl_git_pass (git_filter_list_apply_to_buffer (& out , fl , in , in_len ));
141149 cl_assert_equal_s ("Normal\nCRLF\nline-endings.\n" , out .ptr );
142150
143151 /* Mix of line endings fails with safecrlf, but allowed to pass */
144- in . ptr = "Mixed\nup\r\nLF\nand\r\nCRLF\nline-endings.\r\n" ;
145- in . size = strlen (in . ptr );
152+ in = "Mixed\nup\r\nLF\nand\r\nCRLF\nline-endings.\r\n" ;
153+ in_len = strlen (in );
146154
147- cl_git_pass (git_filter_list_apply_to_data (& out , fl , & in ));
155+ cl_git_pass (git_filter_list_apply_to_buffer (& out , fl , in , in_len ));
148156 /* TODO: check for warning */
149157 cl_assert_equal_s ("Mixed\nup\nLF\nand\nCRLF\nline-endings.\n" , out .ptr );
150158
151159 /* Normalized \n fails with safecrlf, but allowed to pass */
152- in . ptr = "Normal\nLF\nonly\nline-endings.\n" ;
153- in . size = strlen (in . ptr );
160+ in = "Normal\nLF\nonly\nline-endings.\n" ;
161+ in_len = strlen (in );
154162
155- cl_git_pass (git_filter_list_apply_to_data (& out , fl , & in ));
163+ cl_git_pass (git_filter_list_apply_to_buffer (& out , fl , in , in_len ));
156164 /* TODO: check for warning */
157165 cl_assert_equal_s ("Normal\nLF\nonly\nline-endings.\n" , out .ptr );
158166
@@ -164,7 +172,9 @@ void test_filter_crlf__no_safecrlf(void)
164172{
165173 git_filter_list * fl ;
166174 git_filter * crlf ;
167- git_buf in = {0 }, out = GIT_BUF_INIT ;
175+ git_buf out = GIT_BUF_INIT ;
176+ const char * in ;
177+ size_t in_len ;
168178
169179 cl_git_pass (git_filter_list_new (
170180 & fl , g_repo , GIT_FILTER_TO_ODB , 0 ));
@@ -175,24 +185,24 @@ void test_filter_crlf__no_safecrlf(void)
175185 cl_git_pass (git_filter_list_push (fl , crlf , NULL ));
176186
177187 /* Normalized \r\n succeeds with safecrlf */
178- in . ptr = "Normal\r\nCRLF\r\nline-endings.\r\n" ;
179- in . size = strlen (in . ptr );
188+ in = "Normal\r\nCRLF\r\nline-endings.\r\n" ;
189+ in_len = strlen (in );
180190
181- cl_git_pass (git_filter_list_apply_to_data (& out , fl , & in ));
191+ cl_git_pass (git_filter_list_apply_to_buffer (& out , fl , in , in_len ));
182192 cl_assert_equal_s ("Normal\nCRLF\nline-endings.\n" , out .ptr );
183193
184194 /* Mix of line endings fails with safecrlf */
185- in . ptr = "Mixed\nup\r\nLF\nand\r\nCRLF\nline-endings.\r\n" ;
186- in . size = strlen (in . ptr );
195+ in = "Mixed\nup\r\nLF\nand\r\nCRLF\nline-endings.\r\n" ;
196+ in_len = strlen (in );
187197
188- cl_git_pass (git_filter_list_apply_to_data (& out , fl , & in ));
198+ cl_git_pass (git_filter_list_apply_to_buffer (& out , fl , in , in_len ));
189199 cl_assert_equal_s ("Mixed\nup\nLF\nand\nCRLF\nline-endings.\n" , out .ptr );
190200
191201 /* Normalized \n fails with safecrlf */
192- in . ptr = "Normal\nLF\nonly\nline-endings.\n" ;
193- in . size = strlen (in . ptr );
202+ in = "Normal\nLF\nonly\nline-endings.\n" ;
203+ in_len = strlen (in );
194204
195- cl_git_pass (git_filter_list_apply_to_data (& out , fl , & in ));
205+ cl_git_pass (git_filter_list_apply_to_buffer (& out , fl , in , in_len ));
196206 cl_assert_equal_s ("Normal\nLF\nonly\nline-endings.\n" , out .ptr );
197207
198208 git_filter_list_free (fl );
@@ -203,7 +213,9 @@ void test_filter_crlf__safecrlf_warn(void)
203213{
204214 git_filter_list * fl ;
205215 git_filter * crlf ;
206- git_buf in = {0 }, out = GIT_BUF_INIT ;
216+ git_buf out = GIT_BUF_INIT ;
217+ const char * in ;
218+ size_t in_len ;
207219
208220 cl_repo_set_string (g_repo , "core.safecrlf" , "warn" );
209221
@@ -216,26 +228,26 @@ void test_filter_crlf__safecrlf_warn(void)
216228 cl_git_pass (git_filter_list_push (fl , crlf , NULL ));
217229
218230 /* Normalized \r\n succeeds with safecrlf=warn */
219- in . ptr = "Normal\r\nCRLF\r\nline-endings.\r\n" ;
220- in . size = strlen (in . ptr );
231+ in = "Normal\r\nCRLF\r\nline-endings.\r\n" ;
232+ in_len = strlen (in );
221233
222- cl_git_pass (git_filter_list_apply_to_data (& out , fl , & in ));
234+ cl_git_pass (git_filter_list_apply_to_buffer (& out , fl , in , in_len ));
223235 cl_assert_equal_s ("Normal\nCRLF\nline-endings.\n" , out .ptr );
224236
225237 /* Mix of line endings succeeds with safecrlf=warn */
226- in . ptr = "Mixed\nup\r\nLF\nand\r\nCRLF\nline-endings.\r\n" ;
227- in . size = strlen (in . ptr );
238+ in = "Mixed\nup\r\nLF\nand\r\nCRLF\nline-endings.\r\n" ;
239+ in_len = strlen (in );
228240
229- cl_git_pass (git_filter_list_apply_to_data (& out , fl , & in ));
241+ cl_git_pass (git_filter_list_apply_to_buffer (& out , fl , in , in_len ));
230242 /* TODO: check for warning */
231243 cl_assert_equal_s ("Mixed\nup\nLF\nand\nCRLF\nline-endings.\n" , out .ptr );
232244
233245 /* Normalized \n is reversible, so does not fail with safecrlf=warn */
234- in . ptr = "Normal\nLF\nonly\nline-endings.\n" ;
235- in . size = strlen (in . ptr );
246+ in = "Normal\nLF\nonly\nline-endings.\n" ;
247+ in_len = strlen (in );
236248
237- cl_git_pass (git_filter_list_apply_to_data (& out , fl , & in ));
238- cl_assert_equal_s (in . ptr , out .ptr );
249+ cl_git_pass (git_filter_list_apply_to_buffer (& out , fl , in , in_len ));
250+ cl_assert_equal_s (in , out .ptr );
239251
240252 git_filter_list_free (fl );
241253 git_buf_dispose (& out );
0 commit comments