def set_object(self, object, logmsg=None):
        """Set the object we point to, possibly dereference our symbolic reference first.
        If the reference does not exist, it will be created

        :param object: a refspec, a SymbolicReference or an Object instance. SymbolicReferences
            will be dereferenced beforehand to obtain the object they point to
        :param logmsg: If not None, the message will be used in the reflog entry to be
            written. Otherwise the reflog is not altered
        :note: plain SymbolicReferences may not actually point to objects by convention
        :return: self"""
        if isinstance(object, SymbolicReference):
            object = object.object
        # END resolve references

        is_detached = True
        try:
            is_detached = self.is_detached
        except __HOLE__:
            pass
        # END handle non-existing ones

        if is_detached:
            return self.set_reference(object, logmsg)

        # set the commit on our reference
        return self._get_reference().set_object(object, logmsg)
dataset/ETHPy150Open gitpython-developers/GitPython/git/refs/symbolic.py/SymbolicReference.set_object