commit - 786867b56210cec6de187f096f362fccb529104a
commit + e9f9d24c4d03f5f9a4c59601be2c992a2ef01be8
blob - f7234f58ebfe16f68c31999ba5dc0db53519c4d4
blob + 01459a62e2002b01c25d7a8df72a66cab3173398
--- dulwich/object_store.py
+++ dulwich/object_store.py
def iter_tree_contents(
- store: ObjectContainer, tree_id: bytes, *, include_trees: bool = False):
+ store: ObjectContainer, tree_id: Optional[ObjectID], *, include_trees: bool = False):
"""Iterate the contents of a tree and all subtrees.
Iteration is depth-first pre-order, as in e.g. os.walk.
Returns: Iterator over TreeEntry namedtuples for all the objects in a
tree.
"""
+ if tree_id is None:
+ return
# This could be fairly easily generalized to >2 trees if we find a use
# case.
todo = [TreeEntry(b"", stat.S_IFDIR, tree_id)]
blob - 2bd6fe7dfdcb661ef9303afa55b16a5eaf8ae99c
blob + c03a11956bdd8f3a1c4abc67ae7c3fecdc52bd81
--- dulwich/tests/test_object_store.py
+++ dulwich/tests/test_object_store.py
[TreeEntry(p, m, h) for (p, h, m) in blobs],
list(iter_tree_contents(self.store, tree_id)),
)
+ self.assertEqual([], list(iter_tree_contents(self.store, None)))
def test_iter_tree_contents_include_trees(self):
blob_a = make_object(Blob, data=b"a")