def read_file(self, sha, file_path, diff=None):
        cmd = ['cat-file', '--batch', '--follow-symlinks']
        obj_key = '{revision}:{file_path}'.format(revision=sha, file_path=file_path)
        content = self.run(cmd, input=obj_key)
        info, content = content.split('\n', 1)
        if info.endswith('missing'):
            raise ContentReadError('No such file at revision: {}'.format(obj_key))
        if any(info.startswith(s) for s in ('symlink', 'dangling', 'loop')):
            raise ContentReadError('Unable to read file contents: {}'.format(info.split()[0]))
        if not re.match(r'^[a-f0-9]+ blob \d+$', info):
            raise ContentReadError('Unrecognized metadata for {}: {!r}'.format(obj_key, info))
        assert content.endswith('\n')
        content = content[:-1]
        if diff is None:
            return content

        return self._selectively_apply_diff(file_path, content, diff)
Read the content of a file at a given revision.
dataset/ETHPy150Open dropbox/changes/changes/vcs/git.py/GitVcs.read_file