Skip to content

Commit 5991698

Browse files
committedJan 11, 2013
Support repos that use the .git-file mechanism.
1 parent 0b820e6 commit 5991698

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
 

‎git/repo/base.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class Repo(object):
7171
re_hexsha_shortened = re.compile('^[0-9A-Fa-f]{4,40}$')
7272
re_author_committer_start = re.compile(r'^(author|committer)')
7373
re_tab_full_line = re.compile(r'^\t(.*)$')
74+
re_git_file_gitdir = re.compile('gitdir: (.*)')
7475

7576
# invariants
7677
# represents the configuration level of a configuration file
@@ -113,6 +114,17 @@ def __init__(self, path=None, odbt = DefaultDBType):
113114
self.git_dir = gitpath
114115
self._working_tree_dir = curpath
115116
break
117+
if isfile(gitpath):
118+
line = open(gitpath, 'r').readline().strip()
119+
match = self.re_git_file_gitdir.match(line)
120+
if match:
121+
gitpath = match.group(1)
122+
if not os.path.isabs(gitpath):
123+
gitpath = os.path.normpath(join(curpath, gitpath))
124+
if is_git_dir(gitpath):
125+
self.git_dir = gitpath
126+
self._working_tree_dir = curpath
127+
break
116128
curpath, dummy = os.path.split(curpath)
117129
if not dummy:
118130
break

0 commit comments

Comments
 (0)