File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -347,7 +347,7 @@ int git_attr_file__parse_buffer(
347347{
348348 const char * scan = data , * context = NULL ;
349349 git_attr_rule * rule = NULL ;
350- int error = 0 ;
350+ int ignorecase , error = 0 ;
351351
352352 /* If subdir file path, convert context for file paths */
353353 if (attrs -> entry && git_fs_path_root (attrs -> entry -> path ) < 0 &&
@@ -379,6 +379,12 @@ int git_attr_file__parse_buffer(
379379 continue ;
380380 }
381381
382+ if ((error = git_repository__configmap_lookup (& ignorecase , repo , GIT_CONFIGMAP_IGNORECASE )) < 0 )
383+ goto out ;
384+
385+ if (ignorecase )
386+ rule -> match .flags |= GIT_ATTR_FNMATCH_ICASE ;
387+
382388 if (rule -> match .flags & GIT_ATTR_FNMATCH_MACRO ) {
383389 /* TODO: warning if macro found in file below repo root */
384390 if (!allow_macros )
@@ -482,7 +488,7 @@ bool git_attr_fnmatch__match(
482488 */
483489 if (match -> containing_dir ) {
484490 if (match -> flags & GIT_ATTR_FNMATCH_ICASE ) {
485- if (git__strncasecmp (path -> path , match -> containing_dir , match -> containing_dir_length ))
491+ if (git__prefixcmp_icase (path -> path , match -> containing_dir ))
486492 return 0 ;
487493 } else {
488494 if (git__prefixcmp (path -> path , match -> containing_dir ))
Original file line number Diff line number Diff line change @@ -53,6 +53,18 @@ void test_filter_query__filters(void)
5353 cl_assert_equal_i (1 , filter_for ("id.binident" , "ident" ));
5454}
5555
56+ void test_filter_query__filters_ignorecase (void )
57+ {
58+ if (!cl_repo_get_bool (g_repo , "core.ignorecase" ))
59+ cl_skip ();
60+
61+ cl_assert_equal_i (1 , filter_for ("TEXT.TXT" , "crlf" ));
62+ cl_assert_equal_i (0 , filter_for ("Binary.bin" , "crlf" ));
63+
64+ cl_assert_equal_i (1 , filter_for ("id.Ident" , "crlf" ));
65+ cl_assert_equal_i (1 , filter_for ("ID.IdEnT" , "ident" ));
66+ }
67+
5668void test_filter_query__autocrlf_true_implies_crlf (void )
5769{
5870 cl_repo_set_bool (g_repo , "core.autocrlf" , true);
You can’t perform that action at this time.
0 commit comments