def tree_entries_from_data(data: bytes) -> List[EntryTup]:
    """Read the binary representation of a tree and returns tuples of
    :class:`~git.objects.tree.Tree` items.

    :param data:
        Data block with tree data (as bytes).

    :return:
        list(tuple(binsha, mode, tree_relative_path), ...)
    """
    ord_zero = ord("0")
    space_ord = ord(" ")
    len_data = len(data)
    i = 0
    out = []
    while i < len_data:
        mode = 0

        # Read Mode
        # Some git versions truncate the leading 0, some don't.
        # The type will be extracted from the mode later.
        while data[i] != space_ord:
            # Move existing mode integer up one level being 3 bits and add the actual
            # ordinal value of the character.
            mode = (mode << 3) + (data[i] - ord_zero)
            i += 1
        # END while reading mode

        # Byte is space now, skip it.
        i += 1

        # Parse name, it is NULL separated.

        ns = i
        while data[i] != 0:
            i += 1
        # END while not reached NULL

        # Default encoding for strings in git is UTF-8.
        # Only use the respective unicode object if the byte stream was encoded.
        name_bytes = data[ns:i]
        name = safe_decode(name_bytes)

        # Byte is NULL, get next 20.
        i += 1
        sha = data[i : i + 20]
        i = i + 20
        out.append((sha, mode, name))
    # END for each byte in data stream
    return out
Read the binary representation of a tree and returns tuples of
    :class:`~git.objects.tree.Tree` items.

    :param data:
        Data block with tree data (as bytes).

    :return:
        list(tuple(binsha, mode, tree_relative_path), ...)
    
git/objects/fun.py