@@ -202,14 +202,21 @@ def __init__(self, path=None, odbt=GitCmdObjectDB, search_parent_directories=Fal
202
202
# END working dir handling
203
203
204
204
self .working_dir = self ._working_tree_dir or self .common_dir
205
- self .git = self .GitCommandWrapperType (self .working_dir )
206
205
207
206
# special handling, in special times
208
207
args = [osp .join (self .common_dir , 'objects' )]
209
208
if issubclass (odbt , GitCmdObjectDB ):
210
209
args .append (self .git )
211
210
self .odb = odbt (* args )
212
211
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
+
213
220
def __enter__ (self ):
214
221
return self
215
222
@@ -431,7 +438,12 @@ def _get_config_path(self, config_level):
431
438
elif config_level == "global" :
432
439
return osp .normpath (osp .expanduser ("~/.gitconfig" ))
433
440
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 ))
435
447
436
448
raise ValueError ("Invalid configuration level: %r" % config_level )
437
449
0 commit comments