Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb29388a

Browse files
committed
FIX#535: expand also GIT_DIR var on Repo-construct
+ Ignore "empty" GIT_DIR vars.+ Improve documentation on the constructor `path` parameter.
1 parentaab7dc2 commitb29388a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

‎git/repo/base.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ def __init__(self, path=None, odbt=DefaultDBType, search_parent_directories=Fals
124124
repo = Repo("~/Development/git-python.git")
125125
repo = Repo("$REPOSITORIES/Development/git-python.git")
126126
127+
if `None, current-directory is used.
128+
The :envvar:`GIT_DIR` if set and not empty takes precendance over this parameter.
127129
:param odbt:
128130
Object DataBase type - a type which is constructed by providing
129131
the directory containing the database objects, i.e. .git/objects. It will
@@ -136,17 +138,19 @@ def __init__(self, path=None, odbt=DefaultDBType, search_parent_directories=Fals
136138
:raise InvalidGitRepositoryError:
137139
:raise NoSuchPathError:
138140
:return: git.Repo """
139-
epath=_expand_path(pathoros.getcwd())
140141
self.git=None# should be set for __del__ not to fail in case we raise
142+
epath=os.getenv('GIT_DIR')
143+
epath=_expand_path(epathorpathoros.getcwd())
141144
ifnotos.path.exists(epath):
142145
raiseNoSuchPathError(epath)
143146

144147
self.working_dir=None
145148
self._working_tree_dir=None
146149
self.git_dir=None
147-
curpath=os.getenv('GIT_DIR',epath)
148150

149-
# walk up the path to find the .git dir
151+
## Walk up the path to find the `.git` dir.
152+
#
153+
curpath=epath
150154
whilecurpath:
151155
# ABOUT os.path.NORMPATH
152156
# It's important to normalize the paths, as submodules will otherwise initialize their

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp