We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
1 parent0414bf7 commit3801505Copy full SHA for 3801505
git/index/base.py
@@ -652,14 +652,15 @@ def _to_relative_path(self, path: PathLike) -> PathLike:
652
653
:raise ValueError:
654
"""
655
+path=os.fspath(path)
656
ifnotosp.isabs(path):
657
returnpath
658
ifself.repo.bare:
659
raiseInvalidGitRepositoryError("require non-bare repository")
-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)):
661
raiseValueError("Absolute path %r is not in git repository at %r"% (path,self.repo.working_tree_dir))
662
result=os.path.relpath(path,self.repo.working_tree_dir)
-ifos.fspath(path).endswith(os.sep)andnotresult.endswith(os.sep):
663
+ifpath.endswith(os.sep)andnotresult.endswith(os.sep):
664
result+=os.sep
665
returnresult
666
git/index/util.py
@@ -37,7 +37,7 @@ class TemporaryFileSwap:
37
__slots__= ("file_path","tmp_file_path")
38
39
def__init__(self,file_path:PathLike)->None:
40
-self.file_path=file_path
+self.file_path=os.fspath(file_path)
41
dirname,basename=osp.split(file_path)
42
fd,self.tmp_file_path=tempfile.mkstemp(prefix=basename,dir=dirname)
43
os.close(fd)
git/refs/head.py
@@ -8,6 +8,7 @@
8
9
__all__= ["HEAD","Head"]
10
11
+importos
12
fromgit.configimportGitConfigParser,SectionConstraint
13
fromgit.excimportGitCommandError
14
fromgit.utilimportjoin_path
@@ -48,6 +49,7 @@ class HEAD(SymbolicReference):
48
49
commit:"Commit"
50
51
def__init__(self,repo:"Repo",path:PathLike=_HEAD_NAME)->None:
52
53
ifpath!=self._HEAD_NAME:
54
raiseValueError("HEAD instance must point to %r, got %r"% (self._HEAD_NAME,path))
55
super().__init__(repo,path)
git/refs/log.py
@@ -4,6 +4,7 @@
4
__all__= ["RefLog","RefLogEntry"]
5
6
frommmapimportmmap
7
importos.pathasosp
importre
importtimeas_time
@@ -167,7 +168,7 @@ def __init__(self, filepath: Union[PathLike, None] = None) -> None:
167
168
"""Initialize this instance with an optional filepath, from which we will
169
initialize our data. The path is also used to write changes back using the
170
:meth:`write` method."""
-self._path=filepath
171
+self._path=os.fspath(filepath)
172
iffilepathisnotNone:
173
self._read_from_file()
174
# END handle filepath
git/refs/symbolic.py
@@ -76,7 +76,7 @@ class SymbolicReference:
76
77
def__init__(self,repo:"Repo",path:PathLike,check_path:bool=False)->None:
78
self.repo=repo
79
-self.path=path
+self.path=os.fspath(path)
80
81
def__str__(self)->str:
82
returnos.fspath(self.path)
git/repo/fun.py
@@ -62,6 +62,7 @@ def is_git_dir(d: PathLike) -> bool:
62
clearly indicates that we don't support it. There is the unlikely danger to
63
throw if we see directories which just look like a worktree dir, but are none.
64
65
+d=os.fspath(d)
66
ifosp.isdir(d):
67
if (osp.isdir(osp.join(d,"objects"))or"GIT_OBJECT_DIRECTORY"inos.environ)andosp.isdir(
68
osp.join(d,"refs")
git/util.py
@@ -1011,7 +1011,7 @@ class LockFile:
1011
__slots__= ("_file_path","_owns_lock")
1012
1013
1014
-self._file_path=file_path
+self._file_path=os.fspath(file_path)
1015
self._owns_lock=False
1016
1017
def__del__(self)->None: