diff options
author | Marcus R. Brown <mrbrown@precision-mojo.com> | 2013-01-11 13:43:49 -0700 |
---|---|---|
committer | Marcus R. Brown <mrbrown@precision-mojo.com> | 2013-01-11 13:43:49 -0700 |
commit | 5991698ee2b3046bbc9cfc3bd2abd3a881f514dd (patch) | |
tree | 2fed2b11f8da29be057127181806dbae20c9d55e | |
parent | 0b820e617ab21b372394bf12129c30174f57c5d7 (diff) | |
download | gitpython-5991698ee2b3046bbc9cfc3bd2abd3a881f514dd.tar.gz |
Support repos that use the .git-file mechanism.
-rw-r--r-- | git/repo/base.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/git/repo/base.py b/git/repo/base.py index 20c96b22..df52137e 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -71,6 +71,7 @@ class Repo(object): re_hexsha_shortened = re.compile('^[0-9A-Fa-f]{4,40}$') re_author_committer_start = re.compile(r'^(author|committer)') re_tab_full_line = re.compile(r'^\t(.*)$') + re_git_file_gitdir = re.compile('gitdir: (.*)') # invariants # represents the configuration level of a configuration file @@ -113,6 +114,17 @@ class Repo(object): self.git_dir = gitpath self._working_tree_dir = curpath break + if isfile(gitpath): + line = open(gitpath, 'r').readline().strip() + match = self.re_git_file_gitdir.match(line) + if match: + gitpath = match.group(1) + if not os.path.isabs(gitpath): + gitpath = os.path.normpath(join(curpath, gitpath)) + if is_git_dir(gitpath): + self.git_dir = gitpath + self._working_tree_dir = curpath + break curpath, dummy = os.path.split(curpath) if not dummy: break |