def write_tree(stack, paths, use_temp_index): """Possibly update the index, and then write its tree. If any path limiting is in effect, use a temp index. :return: The written tree. :rtype: :class:`Tree<stgit.git.Tree>` """ if use_temp_index: with stack.repository.temp_index() as index: iw = IndexAndWorktree(index, stack.repository.default_worktree) try: index.read_tree(stack.head) if paths: iw.update_index(paths) return index.write_tree() finally: stack.repository.default_iw.update_index(paths) else: iw = stack.repository.default_iw if paths: iw.update_index(paths) return iw.index.write_tree()
def go(index): if paths: iw = IndexAndWorktree(index, stack.repository.default_worktree) iw.update_index(paths) return index.write_tree()