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

Commit3801505

Browse files
committed
Convert paths in constructors and large function calls
1 parent0414bf7 commit3801505

File tree

7 files changed

+11
-6
lines changed

7 files changed

+11
-6
lines changed

‎git/index/base.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,14 +652,15 @@ def _to_relative_path(self, path: PathLike) -> PathLike:
652652
653653
:raise ValueError:
654654
"""
655+
path=os.fspath(path)
655656
ifnotosp.isabs(path):
656657
returnpath
657658
ifself.repo.bare:
658659
raiseInvalidGitRepositoryError("require non-bare repository")
659-
ifnotosp.normpath(os.fspath(path)).startswith(os.fspath(self.repo.working_tree_dir)):
660+
ifnotosp.normpath(path).startswith(os.fspath(self.repo.working_tree_dir)):
660661
raiseValueError("Absolute path %r is not in git repository at %r"% (path,self.repo.working_tree_dir))
661662
result=os.path.relpath(path,self.repo.working_tree_dir)
662-
ifos.fspath(path).endswith(os.sep)andnotresult.endswith(os.sep):
663+
ifpath.endswith(os.sep)andnotresult.endswith(os.sep):
663664
result+=os.sep
664665
returnresult
665666

‎git/index/util.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class TemporaryFileSwap:
3737
__slots__= ("file_path","tmp_file_path")
3838

3939
def__init__(self,file_path:PathLike)->None:
40-
self.file_path=file_path
40+
self.file_path=os.fspath(file_path)
4141
dirname,basename=osp.split(file_path)
4242
fd,self.tmp_file_path=tempfile.mkstemp(prefix=basename,dir=dirname)
4343
os.close(fd)

‎git/refs/head.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
__all__= ["HEAD","Head"]
1010

11+
importos
1112
fromgit.configimportGitConfigParser,SectionConstraint
1213
fromgit.excimportGitCommandError
1314
fromgit.utilimportjoin_path
@@ -48,6 +49,7 @@ class HEAD(SymbolicReference):
4849
commit:"Commit"
4950

5051
def__init__(self,repo:"Repo",path:PathLike=_HEAD_NAME)->None:
52+
path=os.fspath(path)
5153
ifpath!=self._HEAD_NAME:
5254
raiseValueError("HEAD instance must point to %r, got %r"% (self._HEAD_NAME,path))
5355
super().__init__(repo,path)

‎git/refs/log.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
__all__= ["RefLog","RefLogEntry"]
55

66
frommmapimportmmap
7+
importos
78
importos.pathasosp
89
importre
910
importtimeas_time
@@ -167,7 +168,7 @@ def __init__(self, filepath: Union[PathLike, None] = None) -> None:
167168
"""Initialize this instance with an optional filepath, from which we will
168169
initialize our data. The path is also used to write changes back using the
169170
:meth:`write` method."""
170-
self._path=filepath
171+
self._path=os.fspath(filepath)
171172
iffilepathisnotNone:
172173
self._read_from_file()
173174
# END handle filepath

‎git/refs/symbolic.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class SymbolicReference:
7676

7777
def__init__(self,repo:"Repo",path:PathLike,check_path:bool=False)->None:
7878
self.repo=repo
79-
self.path=path
79+
self.path=os.fspath(path)
8080

8181
def__str__(self)->str:
8282
returnos.fspath(self.path)

‎git/repo/fun.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def is_git_dir(d: PathLike) -> bool:
6262
clearly indicates that we don't support it. There is the unlikely danger to
6363
throw if we see directories which just look like a worktree dir, but are none.
6464
"""
65+
d=os.fspath(d)
6566
ifosp.isdir(d):
6667
if (osp.isdir(osp.join(d,"objects"))or"GIT_OBJECT_DIRECTORY"inos.environ)andosp.isdir(
6768
osp.join(d,"refs")

‎git/util.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ class LockFile:
10111011
__slots__= ("_file_path","_owns_lock")
10121012

10131013
def__init__(self,file_path:PathLike)->None:
1014-
self._file_path=file_path
1014+
self._file_path=os.fspath(file_path)
10151015
self._owns_lock=False
10161016

10171017
def__del__(self)->None:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp