summaryrefslogtreecommitdiff
path: root/lib/git/repo.py
diff options
context:
space:
mode:
authorFlorian Apolloner <florian@apolloner.eu>2008-06-20 22:46:11 +0200
committerFlorian Apolloner <florian@apolloner.eu>2008-06-20 22:46:11 +0200
commit66beac619ba944afeca9d15c56ccc60d5276a799 (patch)
treeb73e11c8fb9c91785fceb022759660d12d373b78 /lib/git/repo.py
parent93e19791659c279f4f7e33a433771beca65bf9ea (diff)
parent3980f11a9411d0b487b73279346cfae938845e7a (diff)
downloadgitpython-66beac619ba944afeca9d15c56ccc60d5276a799.tar.gz
Merge branch 'master' of git://gitorious.org/git-python/david into bisect
Diffstat (limited to 'lib/git/repo.py')
-rw-r--r--lib/git/repo.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/git/repo.py b/lib/git/repo.py
index 5853356e..5a9855ac 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,24 @@ class Repo(object):
Returns
``GitPython.Repo``
"""
- epath = os.path.abspath(path)
+ if not os.path.exists(path):
+ raise NoSuchPathError(path)
+
+ self.git = Git(path)
+ self.path = self.git.get_git_dir()
+ if not self.path:
+ raise InvalidGitRepositoryError(path)
+ epath = self.git.get_work_tree()
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):
@@ -275,7 +280,7 @@ class Repo(object):
if mkdir and not os.path.exists(path):
os.makedirs(path, 0755)
- git = Git(path)
+ git = Git(path, bare_repo=True)
output = git.init(**kwargs)
return Repo(path)
create = init_bare