From c5083752d5d02d6c46bc2f18ba53a28d119af5b9 Mon Sep 17 00:00:00 2001 From: Govind Salinas Date: Fri, 6 Jun 2008 22:49:15 -0500 Subject: 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 --- lib/git/repo.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/git/repo.py') 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): -- cgit v1.2.1