Find the first file to match the path and ref, read the file out of git
        and send the path to the newly cached file

def find_file(self, path, tgt_env='base', **kwargs):  # pylint: disable=W0613
        '''
        Find the first file to match the path and ref, read the file out of git
        and send the path to the newly cached file
        '''
        fnd = {'path': '',
               'rel': ''}
        if os.path.isabs(path) or \
                (not salt.utils.stringutils.is_hex(tgt_env) and tgt_env not in self.envs()):
            return fnd

        dest = salt.utils.path.join(self.cache_root, 'refs', tgt_env, path)
        hashes_glob = salt.utils.path.join(self.hash_cachedir,
                                           tgt_env,
                                           '{0}.hash.*'.format(path))
        blobshadest = salt.utils.path.join(self.hash_cachedir,
                                           tgt_env,
                                           '{0}.hash.blob_sha1'.format(path))
        lk_fn = salt.utils.path.join(self.hash_cachedir,
                                     tgt_env,
                                     '{0}.lk'.format(path))
        destdir = os.path.dirname(dest)
        hashdir = os.path.dirname(blobshadest)
        if not os.path.isdir(destdir):
            try:
                os.makedirs(destdir)
            except OSError:
                # Path exists and is a file, remove it and retry
                os.remove(destdir)
                os.makedirs(destdir)
        if not os.path.isdir(hashdir):
            try:
                os.makedirs(hashdir)
            except OSError:
                # Path exists and is a file, remove it and retry
                os.remove(hashdir)
                os.makedirs(hashdir)

        for repo in self.remotes:
            if repo.mountpoint(tgt_env) \
                    and not path.startswith(repo.mountpoint(tgt_env) + os.sep):
                continue
            repo_path = path[len(repo.mountpoint(tgt_env)):].lstrip(os.sep)
            if repo.root(tgt_env):
                repo_path = salt.utils.path.join(repo.root(tgt_env), repo_path)

            blob, blob_hexsha, blob_mode = repo.find_file(repo_path, tgt_env)
            if blob is None:
                continue

            def _add_file_stat(fnd, mode):
                '''
                Add a the mode to the return dict. In other fileserver backends
                we stat the file to get its mode, and add the stat result
                (passed through list() for better serialization) to the 'stat'
                key in the return dict. However, since we aren't using the
                stat result for anything but the mode at this time, we can
                avoid unnecessary work by just manually creating the list and
                not running an os.stat() on all files in the repo.
                '''
                if mode is not None:
                    fnd['stat'] = [mode]
                return fnd

            salt.fileserver.wait_lock(lk_fn, dest)
            try:
                with salt.utils.files.fopen(blobshadest, 'r') as fp_:
                    sha = salt.utils.stringutils.to_unicode(fp_.read())
                    if sha == blob_hexsha:
                        fnd['rel'] = path
                        fnd['path'] = dest
                        return _add_file_stat(fnd, blob_mode)
            except IOError as exc:
                if exc.errno != errno.ENOENT:
                    raise exc

            with salt.utils.files.fopen(lk_fn, 'w'):
                pass

            for filename in glob.glob(hashes_glob):
                try:
                    os.remove(filename)
                except Exception:
                    pass
            # Write contents of file to their destination in the FS cache
            repo.write_file(blob, dest)
            with salt.utils.files.fopen(blobshadest, 'w+') as fp_:
                fp_.write(blob_hexsha)
            try:
                os.remove(lk_fn)
            except OSError:
                pass
            fnd['rel'] = path
            fnd['path'] = dest
            return _add_file_stat(fnd, blob_mode)

        # No matching file was found in tgt_env. Return a dict with empty paths
        # so the calling function knows the file could not be found.
        return fnd