File tree Expand file tree Collapse file tree 2 files changed +25
-12
lines changed
Expand file tree Collapse file tree 2 files changed +25
-12
lines changed Original file line number Diff line number Diff line change @@ -429,18 +429,6 @@ bool git_attr_fnmatch__match(
429429 return (p_fnmatch (match -> pattern , relpath , flags ) != FNM_NOMATCH );
430430 }
431431
432- /* if path is a directory prefix of a negated pattern, then match */
433- if ((match -> flags & GIT_ATTR_FNMATCH_NEGATIVE ) && path -> is_dir ) {
434- size_t pathlen = strlen (relpath );
435- bool prefixed = (pathlen <= match -> length ) &&
436- ((match -> flags & GIT_ATTR_FNMATCH_ICASE ) ?
437- !strncasecmp (match -> pattern , relpath , pathlen ) :
438- !strncmp (match -> pattern , relpath , pathlen ));
439-
440- if (prefixed && git_path_at_end_of_segment (& match -> pattern [pathlen ]))
441- return true;
442- }
443-
444432 return (p_fnmatch (match -> pattern , filename , flags ) != FNM_NOMATCH );
445433}
446434
Original file line number Diff line number Diff line change @@ -372,3 +372,28 @@ void test_attr_ignore__case_sensitive_unignore_does_nothing(void)
372372
373373 assert_is_ignored (true, "case/file" );
374374}
375+
376+ void test_attr_ignore__ignored_subdirfiles_with_subdir_rule (void )
377+ {
378+ cl_git_rewritefile (
379+ "attr/.gitignore" ,
380+ "dir/*\n"
381+ "!dir/sub1/sub2/**\n" );
382+
383+ assert_is_ignored (true, "dir/a.test" );
384+ assert_is_ignored (true, "dir/sub1/a.test" );
385+ assert_is_ignored (true, "dir/sub1/sub2" );
386+ }
387+
388+ void test_attr_ignore__ignored_subdirfiles_with_negations (void )
389+ {
390+ cl_git_rewritefile (
391+ "attr/.gitignore" ,
392+ "dir/*\n"
393+ "!dir/a.test\n" );
394+
395+ assert_is_ignored (false, "dir/a.test" );
396+ assert_is_ignored (true, "dir/b.test" );
397+ assert_is_ignored (true, "dir/sub1/c.test" );
398+ }
399+
You can’t perform that action at this time.
0 commit comments