Skip to content

Commit 5fac8d4

Browse files
committed
fix(repo): Use GIT_DIR only if no repo-path given
FIX #535 according to Byron's comment: #535 (comment)
1 parent a25365f commit 5fac8d4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

git/repo/base.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ def __init__(self, path=None, odbt=DefaultDBType, search_parent_directories=Fals
100100
repo = Repo("$REPOSITORIES/Development/git-python.git")
101101
102102
- In *Cygwin*, path may be a `'cygdrive/...'` prefixed path.
103-
- If `None, current-directory is used.
104-
- The :envvar:`GIT_DIR` if set and not empty takes precendance over this parameter.
103+
- If it evaluates to false, :envvar:`GIT_DIR` is used, and if this also evals to false,
104+
the current-directory is used.
105105
:param odbt:
106106
Object DataBase type - a type which is constructed by providing
107107
the directory containing the database objects, i.e. .git/objects. It will
@@ -114,7 +114,9 @@ def __init__(self, path=None, odbt=DefaultDBType, search_parent_directories=Fals
114114
:raise InvalidGitRepositoryError:
115115
:raise NoSuchPathError:
116116
:return: git.Repo """
117-
epath = os.getenv('GIT_DIR') or path or os.getcwd()
117+
epath = path or os.getenv('GIT_DIR')
118+
if not epath:
119+
epath = os.getcwd()
118120
if Git.is_cygwin():
119121
epath = decygpath(epath)
120122
epath = _expand_path(epath or path or os.getcwd())

0 commit comments

Comments
 (0)