File tree Expand file tree Collapse file tree 2 files changed +24
-12
lines changed Expand file tree Collapse file tree 2 files changed +24
-12
lines changed Original file line number Diff line number Diff line change @@ -467,20 +467,24 @@ def _included_paths(self):
467467 keyword = match .group (1 )
468468 value = match .group (2 ).strip ()
469469
470- if keyword == "gitdir" :
471- value = osp .expanduser (value )
472- if fnmatch .fnmatchcase (self ._repo .git_dir , value ):
473- paths += self .items (section )
474-
475- elif keyword == "gitdir/i" :
470+ if keyword in ["gitdir" , "gitdir/i" ]:
476471 value = osp .expanduser (value )
477472
478- # Ensure that glob is always case insensitive.
479- value = re .sub (
480- r"[a-zA-Z]" ,
481- lambda m : f"[{ m .group ().lower ()} { m .group ().upper ()} ]" ,
482- value
483- )
473+ if not any (value .startswith (s ) for s in ["./" , "/" ]):
474+ value = "**/" + value
475+ if value .endswith ("/" ):
476+ value += "**"
477+
478+ # Ensure that glob is always case insensitive if required.
479+ if keyword .endswith ("/i" ):
480+ value = re .sub (
481+ r"[a-zA-Z]" ,
482+ lambda m : "[{}{}]" .format (
483+ m .group ().lower (),
484+ m .group ().upper ()
485+ ),
486+ value
487+ )
484488
485489 if fnmatch .fnmatchcase (self ._repo .git_dir , value ):
486490 paths += self .items (section )
Original file line number Diff line number Diff line change @@ -299,6 +299,14 @@ def test_conditional_includes_from_git_dir(self, rw_dir):
299299 assert not config ._has_includes ()
300300 assert config ._included_paths () == []
301301
302+ # Ensure that config is included if path in hierarchy.
303+ with open (path1 , "w" ) as stream :
304+ stream .write (template .format ("gitdir" , "target1/" , path2 ))
305+
306+ with GitConfigParser (path1 , repo = repo ) as config :
307+ assert config ._has_includes ()
308+ assert config ._included_paths () == [("path" , path2 )]
309+
302310 @with_rw_directory
303311 def test_conditional_includes_from_branch_name (self , rw_dir ):
304312 # Initiate mocked branch
You can’t perform that action at this time.
0 commit comments