Allow joining path to tree · gitpython-developers/GitPython@88e2614
@@ -5,6 +5,7 @@
5566__all__ = ["TreeModifier", "Tree"]
778+import os
89import sys
9101011import git.diff as git_diff
@@ -230,7 +231,7 @@ def _iter_convert_to_object(self, iterable: Iterable[TreeCacheTup]) -> Iterator[
230231raise TypeError("Unknown mode %o found in tree data for path '%s'" % (mode, path)) from e
231232# END for each item
232233233-def join(self, file: str) -> IndexObjUnion:
234+def join(self, file: PathLike) -> IndexObjUnion:
234235"""Find the named object in this tree's contents.
235236236237 :return:
@@ -241,6 +242,7 @@ def join(self, file: str) -> IndexObjUnion:
241242 If the given file or tree does not exist in this tree.
242243 """
243244msg = "Blob or Tree named %r not found"
245+file = os.fspath(file)
244246if "/" in file:
245247tree = self
246248item = self
@@ -269,7 +271,7 @@ def join(self, file: str) -> IndexObjUnion:
269271raise KeyError(msg % file)
270272# END handle long paths
271273272-def __truediv__(self, file: str) -> IndexObjUnion:
274+def __truediv__(self, file: PathLike) -> IndexObjUnion:
273275"""The ``/`` operator is another syntax for joining.
274276275277 See :meth:`join` for details.