def set_parent_commit(self, commit, check=True):
        if commit is None:
            self._parent_commit = None
            return self
        # end handle None
        pcommit = self.repo.commit(commit)
        pctree = pcommit.tree
        if self.k_modules_file not in pctree:
            raise ValueError("Tree of commit %s did not contain the %s file" % (commit, self.k_modules_file))
        # END handle exceptions

        prev_pc = self._parent_commit
        self._parent_commit = pcommit

        if check:
            parser = self._config_parser(self.repo, self._parent_commit, read_only=True)
            if not parser.has_section(sm_section(self.name)):
                self._parent_commit = prev_pc
                raise ValueError("Submodule at path %r did not exist in parent commit %s" % (self.path, commit))
            # END handle submodule did not exist
        # END handle checking mode

        # update our sha, it could have changed
        # If check is False, we might see a parent-commit that doens't even contain the submodule anymore.
        # in that case, mark our sha as being NULL
        try:
            self.binsha = pctree[self.path].binsha
        except KeyError:
            self.binsha = self.NULL_BIN_SHA
        # end

        self._clear_cache()
        return self
Set this instance to use the given commit whose tree is supposed to
dataset/ETHPy150Open gitpython-developers/GitPython/git/objects/submodule/base.py/Submodule.set_parent_commit