summaryrefslogtreecommitdiff
path: root/git/repo/base.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2015-01-10 18:22:48 +0100
committerSebastian Thiel <byronimo@gmail.com>2015-01-10 18:22:48 +0100
commit96c6ab4f7572fd5ca8638f3cb6e342d5000955e7 (patch)
tree5f5bf29b1e866892796cffe61d0bc71d00321823 /git/repo/base.py
parentbfce49feb0be6c69f7fffc57ebdd22b6da241278 (diff)
downloadgitpython-96c6ab4f7572fd5ca8638f3cb6e342d5000955e7.tar.gz
Added search_parent_directories keyword argument to Repo type.
Now by default, we will not walk up the directory structure and possibly find git directories that the user didn't intend to find. If required, that kind of behaviour can be turned back on. Fixes #65
Diffstat (limited to 'git/repo/base.py')
-rw-r--r--git/repo/base.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/git/repo/base.py b/git/repo/base.py
index dbca4697..97e49aa2 100644
--- a/git/repo/base.py
+++ b/git/repo/base.py
@@ -46,7 +46,6 @@ from .fun import (
rev_parse,
is_git_dir,
find_git_dir,
- read_gitfile,
touch,
)
from git.compat import (
@@ -96,7 +95,7 @@ class Repo(object):
# represents the configuration level of a configuration file
config_level = ("system", "global", "repository")
- def __init__(self, path=None, odbt=DefaultDBType):
+ def __init__(self, path=None, odbt=DefaultDBType, search_parent_directories=False):
"""Create a new Repo instance
:param path: is the path to either the root git directory or the bare git repo::
@@ -128,15 +127,14 @@ class Repo(object):
self.git_dir = curpath
self._working_tree_dir = os.path.dirname(curpath)
break
+
gitpath = find_git_dir(join(curpath, '.git'))
if gitpath is not None:
self.git_dir = gitpath
self._working_tree_dir = curpath
break
- gitpath = read_gitfile(curpath)
- if gitpath:
- self.git_dir = gitpath
- self._working_tree_dir = curpath
+
+ if not search_parent_directories:
break
curpath, dummy = os.path.split(curpath)
if not dummy: