File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -213,6 +213,16 @@ static int parse_ignore_file(
213213 if (ignore_case )
214214 match -> flags |= GIT_ATTR_FNMATCH_ICASE ;
215215
216+ while (match -> length > 0 ) {
217+ if (match -> pattern [match -> length - 1 ] == ' ' ||
218+ match -> pattern [match -> length - 1 ] == '\t' ) {
219+ match -> pattern [match -> length - 1 ] = 0 ;
220+ match -> length -- ;
221+ } else {
222+ break ;
223+ }
224+ }
225+
216226 scan = git__next_line (scan );
217227
218228 /*
Original file line number Diff line number Diff line change @@ -51,6 +51,16 @@ void test_attr_ignore__allow_root(void)
5151 assert_is_ignored (false, "NewFolder/NewFolder/File.txt" );
5252}
5353
54+ void test_attr_ignore__ignore_space (void )
55+ {
56+ cl_git_rewritefile ("attr/.gitignore" , "/\n\n/NewFolder \n/NewFolder/NewFolder" );
57+
58+ assert_is_ignored (false, "File.txt" );
59+ assert_is_ignored (true, "NewFolder" );
60+ assert_is_ignored (true, "NewFolder/NewFolder" );
61+ assert_is_ignored (true, "NewFolder/NewFolder/File.txt" );
62+ }
63+
5464void test_attr_ignore__ignore_root (void )
5565{
5666 cl_git_rewritefile ("attr/.gitignore" , "/\n\n/NewFolder\n/NewFolder/NewFolder" );
You can’t perform that action at this time.
0 commit comments