Skip to content

Commit 88e2614

Browse files
committed
Allow joining path to tree
1 parent 9fa28ae commit 88e2614

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

git/objects/tree.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
__all__ = ["TreeModifier", "Tree"]
77

8+
import os
89
import sys
910

1011
import git.diff as git_diff
@@ -230,7 +231,7 @@ def _iter_convert_to_object(self, iterable: Iterable[TreeCacheTup]) -> Iterator[
230231
raise TypeError("Unknown mode %o found in tree data for path '%s'" % (mode, path)) from e
231232
# END for each item
232233

233-
def join(self, file: str) -> IndexObjUnion:
234+
def join(self, file: PathLike) -> IndexObjUnion:
234235
"""Find the named object in this tree's contents.
235236
236237
: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
"""
243244
msg = "Blob or Tree named %r not found"
245+
file = os.fspath(file)
244246
if "/" in file:
245247
tree = self
246248
item = self
@@ -269,7 +271,7 @@ def join(self, file: str) -> IndexObjUnion:
269271
raise KeyError(msg % file)
270272
# END handle long paths
271273

272-
def __truediv__(self, file: str) -> IndexObjUnion:
274+
def __truediv__(self, file: PathLike) -> IndexObjUnion:
273275
"""The ``/`` operator is another syntax for joining.
274276
275277
See :meth:`join` for details.

0 commit comments

Comments
 (0)