summaryrefslogtreecommitdiff
path: root/lib/git/repo.py
diff options
context:
space:
mode:
authorGovind Salinas <blix@sophiasuchtig.com>2008-06-06 22:49:15 -0500
committerDavid Aguilar <davvid@gmail.com>2008-06-12 01:26:07 -0700
commitc5083752d5d02d6c46bc2f18ba53a28d119af5b9 (patch)
tree6d55b650713f27e2b1e83ccb2b557cc5e0cca017 /lib/git/repo.py
parent8a0eee3989abd3a5d6d47d0298bd056a954d379b (diff)
downloadgitpython-c5083752d5d02d6c46bc2f18ba53a28d119af5b9.tar.gz
Determine git_dir and git_work_tree in python.
Calling git to find the git_dir and work_tree is very costly. This patch uses the same mechanisim to find the git_dir as native git does without shelling out. Signed-off-by: Govind Salinas <blix@sophiasuchtig.com>
Diffstat (limited to 'lib/git/repo.py')
-rw-r--r--lib/git/repo.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/git/repo.py b/lib/git/repo.py
index 5853356e..72291dc9 100644
--- a/lib/git/repo.py
+++ b/lib/git/repo.py
@@ -12,7 +12,7 @@ from tree import Tree
class Repo(object):
DAEMON_EXPORT_FILE = 'git-daemon-export-ok'
- def __init__(self, path):
+ def __init__(self, path=None):
"""
Create a new Repo instance
@@ -27,19 +27,19 @@ class Repo(object):
Returns
``GitPython.Repo``
"""
- epath = os.path.abspath(path)
+ self.git = Git(path)
+ epath = self.git.get_work_tree()
+ self.path = self.git.get_git_dir()
if os.path.exists(os.path.join(epath, '.git')):
- self.path = os.path.join(epath, '.git')
self.bare = False
- elif os.path.exists(epath) and re.search('\.git$', epath):
- self.path = epath
+ elif os.path.exists(epath) and epath.endswith('.git'):
self.bare = True
elif os.path.exists(epath):
raise InvalidGitRepositoryError(epath)
else:
raise NoSuchPathError(epath)
- self.git = Git(self.path)
+
@property
def description(self):