<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def export(local_root, commit, target):
 """Export git commit to directory. "Extracts" all files at the commit to the target directory. Set mtime of RST files to last commit date. :raise CalledProcessError: Unhandled git command failure. :param str local_root: Local path to git root directory. :param str commit: Git commit SHA to export. :param str target: Directory to export to. """

    log = logging.getLogger(__name__)
    target = os.path.realpath(target)
    mtimes = list()

    # Define extract function.
    def extract(stdout):
        """Extract tar archive from "git archive" stdout.

        :param file stdout: Handle to git's stdout pipe.
        """
        queued_links = list()
        try:
            with tarfile.open(fileobj=stdout, mode='r|') as tar:
                for info in tar:
                    log.debug('name: %s; mode: %d; size: %s; type: %s', info.name, info.mode, info.size, info.type)
                    path = os.path.realpath(os.path.join(target, info.name))
                    if not path.startswith(target):  # Handle bad paths.
                        log.warning('Ignoring tar object path %s outside of target directory.', info.name)
                    elif info.isdir():  # Handle directories.
                        if not os.path.exists(path):
                            os.makedirs(path, mode=info.mode)
                    elif info.issym() or info.islnk():  # Queue links.
                        queued_links.append(info)
                    else:  # Handle files.
                        tar.extract(member=info, path=target)
                        if os.path.splitext(info.name)[1].lower() == '.rst':
                            mtimes.append(info.name)
                for info in (i for i in queued_links if os.path.exists(os.path.join(target, i.linkname))):
                    tar.extract(member=info, path=target)
        except tarfile.TarError as exc:
            log.debug('Failed to extract output from "git archive" command: %s', str(exc))

    # Run command.
    run_command(local_root, ['git', 'archive', '--format=tar', commit], pipeto=extract)

    # Set mtime.
    for file_path in mtimes:
        last_committed = int(run_command(local_root, ['git', 'log', '-n1', '--format=%at', commit, '--', file_path]))
        os.utime(os.path.join(target, file_path), (last_committed, last_committed))