summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKostis Anagnostopoulos <ankostis@gmail.com>2016-10-22 13:27:44 +0200
committerKostis Anagnostopoulos <ankostis@gmail.com>2016-10-22 13:27:44 +0200
commit5fac8d40f535ec8f3d1cf2187fbbe3418d82cf62 (patch)
tree23445fd34bf4b15f125c3ded00f6e6e8079058ff
parenta25365fea0ea3b92ba96cc281facd308311def1e (diff)
downloadgitpython-5fac8d40f535ec8f3d1cf2187fbbe3418d82cf62.tar.gz
fix(repo): Use GIT_DIR only if no repo-path given
FIX #535 according to Byron's comment: https://github.com/gitpython-developers/GitPython/issues/535#issuecomment-255522529
-rw-r--r--git/repo/base.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/git/repo/base.py b/git/repo/base.py
index f3a04cf4..0f85e3d9 100644
--- a/git/repo/base.py
+++ b/git/repo/base.py
@@ -100,8 +100,8 @@ class Repo(object):
repo = Repo("$REPOSITORIES/Development/git-python.git")
- In *Cygwin*, path may be a `'cygdrive/...'` prefixed path.
- - If `None, current-directory is used.
- - The :envvar:`GIT_DIR` if set and not empty takes precendance over this parameter.
+ - If it evaluates to false, :envvar:`GIT_DIR` is used, and if this also evals to false,
+ the current-directory is used.
:param odbt:
Object DataBase type - a type which is constructed by providing
the directory containing the database objects, i.e. .git/objects. It will
@@ -114,7 +114,9 @@ class Repo(object):
:raise InvalidGitRepositoryError:
:raise NoSuchPathError:
:return: git.Repo """
- epath = os.getenv('GIT_DIR') or path or os.getcwd()
+ epath = path or os.getenv('GIT_DIR')
+ if not epath:
+ epath = os.getcwd()
if Git.is_cygwin():
epath = decygpath(epath)
epath = _expand_path(epath or path or os.getcwd())