File tree 2 files changed +32
-7
lines changed 2 files changed +32
-7
lines changed Original file line number Diff line number Diff line change @@ -97,8 +97,7 @@ static int diff_driver_add_patterns(
97
97
for (scan = regex_str ; scan ; scan = end ) {
98
98
/* get pattern to fill in */
99
99
if ((pat = git_array_alloc (drv -> fn_patterns )) == NULL ) {
100
- error = -1 ;
101
- break ;
100
+ return -1 ;
102
101
}
103
102
104
103
pat -> flags = regex_flags ;
@@ -117,18 +116,18 @@ static int diff_driver_add_patterns(
117
116
break ;
118
117
119
118
if ((error = regcomp (& pat -> re , buf .ptr , regex_flags )) != 0 ) {
120
- /* if regex fails to compile, warn? fail? */
121
- error = giterr_set_regex (& pat -> re , error );
122
- regfree (& pat -> re );
123
- break ;
119
+ /*
120
+ * TODO: issue a warning
121
+ */
124
122
}
125
123
}
126
124
127
125
if (error && pat != NULL )
128
126
(void )git_array_pop (drv -> fn_patterns ); /* release last item */
129
127
git_buf_free (& buf );
130
128
131
- return error ;
129
+ /* We want to ignore bad patterns, so return success regardless */
130
+ return 0 ;
132
131
}
133
132
134
133
static int diff_driver_xfuncname (const git_config_entry * entry , void * payload )
Original file line number Diff line number Diff line change @@ -250,3 +250,29 @@ void test_diff_drivers__builtins(void)
250
250
git_buf_free (& expected );
251
251
git_vector_free (& files );
252
252
}
253
+
254
+ void test_diff_drivers__invalid_pattern (void )
255
+ {
256
+ git_config * cfg ;
257
+ git_index * idx ;
258
+ git_diff * diff ;
259
+ git_patch * patch ;
260
+ git_diff_options opts = GIT_DIFF_OPTIONS_INIT ;
261
+
262
+ g_repo = cl_git_sandbox_init ("userdiff" );
263
+ cl_git_mkfile ("userdiff/.gitattributes" , "*.storyboard diff=storyboard\n" );
264
+
265
+ cl_git_pass (git_repository_config__weakptr (& cfg , g_repo ));
266
+ cl_git_pass (git_config_set_string (cfg , "diff.storyboard.xfuncname" , "<!--(.*?)-->" ));
267
+
268
+ cl_git_mkfile ("userdiff/dummy.storyboard" , "" );
269
+ cl_git_pass (git_repository_index__weakptr (& idx , g_repo ));
270
+ cl_git_pass (git_index_add_bypath (idx , "dummy.storyboard" ));
271
+ cl_git_mkfile ("userdiff/dummy.storyboard" , "some content\n" );
272
+
273
+ cl_git_pass (git_diff_index_to_workdir (& diff , g_repo , NULL , & opts ));
274
+ cl_git_pass (git_patch_from_diff (& patch , diff , 0 ));
275
+
276
+ git_patch_free (patch );
277
+ git_diff_free (diff );
278
+ }
You can’t perform that action at this time.
0 commit comments