◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
6 changes: 4 additions & 2 deletions git/objects/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

__all__ = ["TreeModifier", "Tree"]

import sys

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

def join(self, file: str) -> IndexObjUnion:
"""Find the named object in this tree's contents.

:return:
Expand All @@ -241,6 +242,7 @@ def join(self, file: str) -> IndexObjUnion:
If the given file or tree does not exist in this tree.
"""
msg = "Blob or Tree named %r not found"
if "/" in file:
tree = self
item = self
Expand Down Expand Up @@ -269,7 +271,7 @@ def join(self, file: str) -> IndexObjUnion:
raise KeyError(msg % file)
# END handle long paths

def __truediv__(self, file: str) -> IndexObjUnion:
"""The ``/`` operator is another syntax for joining.

See :meth:`join` for details.
58 changes: 58 additions & 0 deletions test/test_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@
from pathlib import Path
import subprocess

from git.objects import Blob, Tree
from git.util import cwd

from test.lib import TestBase, with_rw_directory


class TestTree(TestBase):
Expand Up @@ -161,3 +165,57 @@ def lib_folder(t, _d):
assert root[item.path] == item == root / item.path
# END for each item
assert found_slash
Loading
Toggle all file notes Toggle all file annotations