code: def set_object(self, object, logmsg=None):  # @ReservedAssignment
          
          if isinstance(object, SymbolicReference):
              object = object.object  # @ReservedAssignment
          # END resolve references
  
          is_detached = True
          try:
              is_detached = self.is_detached
          except ValueError:
              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)
docs: 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