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

Commit67291f0

Browse files
committed
Fixed missing parameter and changed name
1 parent54709d9 commit67291f0

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

‎git/repo/base.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@
5151
__all__= ('Repo',)
5252

5353

54-
def_expand_path(p,unsafe=True):
55-
ifunsafe:
56-
returnosp.normpath(osp.abspath(osp.expandvars(osp.expanduser(p))))
57-
else:
58-
returnosp.normpath(osp.abspath(osp.expanduser(p)))
54+
def_expand_path(p,expand_vars=True):
55+
p=osp.expanduser(p)
56+
ifexpand_vars:
57+
p=osp.expandvars(p)
58+
returnosp.normpath(osp.abspath(p))
5959

6060

6161
classRepo(object):
@@ -94,7 +94,7 @@ class Repo(object):
9494
# Subclasses may easily bring in their own custom types by placing a constructor or type here
9595
GitCommandWrapperType=Git
9696

97-
def__init__(self,path=None,odbt=DefaultDBType,search_parent_directories=False,unsafe=True):
97+
def__init__(self,path=None,odbt=DefaultDBType,search_parent_directories=False,expand_vars=True):
9898
"""Create a new Repo instance
9999
100100
:param path:
@@ -120,15 +120,17 @@ def __init__(self, path=None, odbt=DefaultDBType, search_parent_directories=Fals
120120
:raise InvalidGitRepositoryError:
121121
:raise NoSuchPathError:
122122
:return: git.Repo """
123+
123124
epath=pathoros.getenv('GIT_DIR')
124125
ifnotepath:
125126
epath=os.getcwd()
126127
ifGit.is_cygwin():
127128
epath=decygpath(epath)
128-
ifunsafeand ("%"inepathor"$"inepath):
129-
warnings.warn("The use of environment variables in paths is deprecated"
130-
+"\nfor security reasons and may be removed in the future!!")
131-
epath=_expand_path(epathorpathoros.getcwd(),unsafe)
129+
epath=epathorpathoros.getcwd()
130+
ifexpand_varsand ("%"inepathor"$"inepath):
131+
warnings.warn("The use of environment variables in paths is deprecated"+
132+
"\nfor security reasons and may be removed in the future!!")
133+
epath=_expand_path(epath,expand_vars)
132134
ifnotos.path.exists(epath):
133135
raiseNoSuchPathError(epath)
134136

@@ -155,7 +157,7 @@ def __init__(self, path=None, odbt=DefaultDBType, search_parent_directories=Fals
155157
sm_gitpath=find_worktree_git_dir(dotgit)
156158

157159
ifsm_gitpathisnotNone:
158-
self.git_dir=_expand_path(sm_gitpath,unsafe)
160+
self.git_dir=_expand_path(sm_gitpath,expand_vars)
159161
self._working_tree_dir=curpath
160162
break
161163

@@ -851,7 +853,7 @@ def blame(self, rev, file, incremental=False, **kwargs):
851853
returnblames
852854

853855
@classmethod
854-
definit(cls,path=None,mkdir=True,odbt=DefaultDBType,**kwargs):
856+
definit(cls,path=None,mkdir=True,odbt=DefaultDBType,expand_vars=True,**kwargs):
855857
"""Initialize a git repository at the given path if specified
856858
857859
:param path:
@@ -869,7 +871,7 @@ def init(cls, path=None, mkdir=True, odbt=DefaultDBType, **kwargs):
869871
the directory containing the database objects, i.e. .git/objects.
870872
It will be used to access all object data
871873
872-
:paramunsafe:
874+
:paramexpand_vars:
873875
if specified, environment variables will not be escaped. This
874876
can lead to information disclosure, allowing attackers to
875877
access the contents of environment variables
@@ -879,7 +881,7 @@ def init(cls, path=None, mkdir=True, odbt=DefaultDBType, **kwargs):
879881
880882
:return: ``git.Repo`` (the newly created repo)"""
881883
ifpath:
882-
path=_expand_path(path,unsafe)
884+
path=_expand_path(path,expand_vars)
883885
ifmkdirandpathandnotosp.exists(path):
884886
os.makedirs(path,0o755)
885887

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp