def _merge_entries(path, trees):
    """Merge the entries of two trees.

    :param path: A path to prepend to all tree entry names.
    :param tree1: The first Tree object to iterate, or None.
    :param tree2: The second Tree object to iterate, or None.
    :return: A list of pairs of TreeEntry objects for each pair of entries in
        the trees. If an entry exists in one tree but not the other, the other
        entry will have all attributes set to None. If neither entry's path is
        None, they are guaranteed to match.
    """
    entries = []
    for tree in trees:
        entries.append(_tree_entries(path, tree))

    inds = []
    lens = []
    for e in entries:
        inds.append(0)
        lens.append(len(e))

    result = []
    while any([ind < l for ind, l in zip(inds, lens)]):
        next_entry = [e[ind] if ind < l else _NULL_ENTRY for e, ind, l in zip(entries, inds, lens)]
        paths = [e.path for e in next_entry if e.path]
        minpath = min(paths)
        merged = [e if e.path == minpath else _NULL_ENTRY for e in next_entry]
        result.append(merged)
        inds = [ind + 1 if e.path == minpath else ind for e, ind in zip(next_entry, inds)]

    return result
Merge the entries of two trees.

    :param path: A path to prepend to all tree entry names.
    :param tree1: The first Tree object to iterate, or None.
    :param tree2: The second Tree object to iterate, or None.
    :return: A list of pairs of TreeEntry objects for each pair of entries in
        the trees. If an entry exists in one tree but not the other, the other
        entry will have all attributes set to None. If neither entry's path is
        None, they are guaranteed to match.
    
lib/git/git-merge.py