Skip to content

Commit 2ea528e

Browse files
committed
Fix typing of index.fun.write_tree_from_cache()
1 parent 09053c5 commit 2ea528e

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

‎git/index/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ def write_tree(self) -> Tree:
572572
# note: additional deserialization could be saved if write_tree_from_cache
573573
# would return sorted tree entries
574574
root_tree = Tree(self.repo, binsha, path='')
575-
root_tree._cache = tree_items # type: ignore
575+
root_tree._cache = tree_items # type: ignore # should this be encoded to [bytes, int, str]?
576576
return root_tree
577577

578578
def _process_diff_args(self, # type: ignore[override]

‎git/index/fun.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def read_cache(stream: IO[bytes]) -> Tuple[int, Dict[Tuple[PathLike, int], 'Inde
249249

250250

251251
def write_tree_from_cache(entries: List[IndexEntry], odb, sl: slice, si: int = 0
252-
) -> Tuple[bytes, List[Tuple[str, int, str]]]:
252+
) -> Tuple[bytes, List[Tuple[bytes, int, str]]]:
253253
"""Create a tree from the given sorted list of entries and put the respective
254254
trees into the given object database
255255
@@ -298,12 +298,11 @@ def write_tree_from_cache(entries: List[IndexEntry], odb, sl: slice, si: int = 0
298298

299299
# finally create the tree
300300
sio = BytesIO()
301-
tree_to_stream(tree_items, sio.write) # converts bytes of each item[0] to str
302-
tree_items_stringified = cast(List[Tuple[str, int, str]], tree_items)
301+
tree_to_stream(tree_items, sio.write) # writes to stream as bytes, but doesnt change tree_items
303302
sio.seek(0)
304303

305304
istream = odb.store(IStream(str_tree_type, len(sio.getvalue()), sio))
306-
return (istream.binsha, tree_items_stringified)
305+
return (istream.binsha, tree_items)
307306

308307

309308
def _tree_entry_to_baseindexentry(tree_entry: Tuple[bytes, int, str], stage: int) -> BaseIndexEntry:

0 commit comments

Comments
 (0)