@@ -202,14 +202,21 @@ def __init__(self, path=None, odbt=GitCmdObjectDB, search_parent_directories=Fal
202202 # END working dir handling
203203
204204 self .working_dir = self ._working_tree_dir or self .common_dir
205- self .git = self .GitCommandWrapperType (self .working_dir )
206205
207206 # special handling, in special times
208207 args = [osp .join (self .common_dir , 'objects' )]
209208 if issubclass (odbt , GitCmdObjectDB ):
210209 args .append (self .git )
211210 self .odb = odbt (* args )
212211
212+ class GitCommand (object ):
213+ def __get__ (self , instance , owner ):
214+ if instance is not None :
215+ return instance .GitCommandWrapperType (instance ._working_tree_dir or instance .common_dir )
216+ raise AttributeError ('git' )
217+
218+ git = GitCommand ()
219+
213220 def __enter__ (self ):
214221 return self
215222
@@ -431,7 +438,12 @@ def _get_config_path(self, config_level):
431438 elif config_level == "global" :
432439 return osp .normpath (osp .expanduser ("~/.gitconfig" ))
433440 elif config_level == "repository" :
434- return osp .normpath (osp .join (self ._common_dir or self .git_dir , "config" ))
441+ try :
442+ config_path = self .git .rev_parse ("config" , git_path = True )
443+ except GitCommandError :
444+ return osp .normpath (osp .join (self ._common_dir or self .git_dir , "config" ))
445+ else :
446+ return osp .normpath (osp .join (self .git ._working_dir , config_path ))
435447
436448 raise ValueError ("Invalid configuration level: %r" % config_level )
437449
0 commit comments