code: def _read_object_from_repo(self, rev=None, relpath=None, sha=None):
      
      if sha:
        spec = sha + b'\n'
      else:
        assert rev is not None
        assert relpath is not None
        rev = ensure_text(rev)
        relpath = ensure_text(relpath)
        relpath = self._fixup_dot_relative(relpath)
        spec = '{}:{}\n'.format(rev, relpath).encode('utf-8')
  
      self._maybe_start_cat_file_process()
      self._cat_file_process.stdin.write(spec)
      self._cat_file_process.stdin.flush()
      header = None
      while not header:
        header = self._cat_file_process.stdout.readline()
        if self._cat_file_process.poll() is not None:
          raise self.GitDiedException("Git cat-file died while trying to read '{}'.".format(spec))
  
      header = header.rstrip()
      parts = header.rsplit(SPACE, 2)
      if len(parts) == 2:
        assert parts[1] == b'missing'
        raise self.MissingFileException(rev, relpath)
  
      _, object_type, object_len = parts
  
      # Read the object data
      blob = bytes(self._cat_file_process.stdout.read(int(object_len)))
  
      # Read the trailing newline
      assert self._cat_file_process.stdout.read(1) == b'\n'
      assert len(blob) == int(object_len)
      return object_type, blob
docs: Read an object from the git repo.
      This is implemented via a pipe to git cat-file --batch