@@ -79,22 +79,30 @@ def __init__(self, path=None):
7979
8080 self .path = None
8181 curpath = epath
82+
83+ # walk up the path to find the .git dir
8284 while curpath :
8385 if is_git_dir (curpath ):
84- self .bare = True
8586 self .path = curpath
8687 self .wd = curpath
8788 break
8889 gitpath = os .path .join (curpath , '.git' )
8990 if is_git_dir (gitpath ):
90- self .bare = False
9191 self .path = gitpath
9292 self .wd = curpath
9393 break
9494 curpath , dummy = os .path .split (curpath )
9595 if not dummy :
9696 break
97-
97+ # END while curpath
98+
99+ self ._bare = False
100+ try :
101+ self ._bare = self .config_reader ("repository" ).getboolean ('core' ,'bare' )
102+ except Exception :
103+ # lets not assume the option exists, although it should
104+ pass
105+
98106 if self .path is None :
99107 raise InvalidGitRepositoryError (epath )
100108
@@ -113,6 +121,15 @@ def _set_description(self, descr):
113121 doc = "the project's description" )
114122 del _get_description
115123 del _set_description
124+
125+
126+ @property
127+ def bare (self ):
128+ """
129+ Returns
130+ True if the repository is bare
131+ """
132+ return self ._bare
116133
117134 @property
118135 def heads (self ):
@@ -194,8 +211,7 @@ def _get_config_path(self, config_level ):
194211
195212 raise ValueError ( "Invalid configuration level: %r" % config_level )
196213
197- @property
198- def config_reader (self ):
214+ def config_reader (self , config_level = None ):
199215 """
200216 Returns
201217 GitConfigParser allowing to read the full git configuration, but not to write it
@@ -205,8 +221,18 @@ def config_reader(self):
205221
206222 NOTE: On windows, system configuration cannot currently be read as the path is
207223 unknown, instead the global path will be used.
208- """
209- files = [ self ._get_config_path (f ) for f in self .config_level ]
224+
225+ ``config_level``
226+ For possible values, see config_writer method
227+ If None, all applicable levels will be used. Specify a level in case
228+ you know which exact file you whish to read to prevent reading multiple files for
229+ instance
230+ """
231+ files = None
232+ if config_level is None :
233+ files = [ self ._get_config_path (f ) for f in self .config_level ]
234+ else :
235+ files = [ self ._get_config_path (config_level ) ]
210236 return GitConfigParser (files , read_only = True )
211237
212238 def config_writer (self , config_level = "repository" ):
@@ -393,7 +419,7 @@ def is_dirty(self, index=True, working_tree=True, untracked_files=False):
393419 like a git-status without untracked files, hence it is dirty if the
394420 index or the working copy have changes.
395421 """
396- if self .bare :
422+ if self ._bare :
397423 # Bare repositories with no associated working directory are
398424 # always consired to be clean.
399425 return False
0 commit comments