'Set a refname to new_ref only if it currently equals old_ref.'

def set_if_equals(self, name, old_ref, new_ref):

    if (name == 'HEAD'):
        return True
    refs = self._load_check_ref(name, old_ref)
    if (not isinstance(refs, dict)):
        return False
    refs[name] = new_ref
    self._write_refs(refs)
    self._refs[name] = new_ref
    return True
