| 511 | "Returns True if a ref by this name exists, or False otherwise."); |
| 512 | |
| 513 | PyObject * |
| 514 | RefdbBackend_exists(RefdbBackend *self, PyObject *py_str) |
| 515 | { |
| 516 | int err, exists; |
| 517 | const char *ref_name; |
| 518 | if (self->refdb_backend->exists == NULL) { |
| 519 | Py_INCREF(Py_NotImplemented); |
| 520 | return Py_NotImplemented; |
| 521 | } |
| 522 | |
| 523 | if (!PyUnicode_Check(py_str)) { |
| 524 | PyErr_SetString(PyExc_TypeError, |
| 525 | "RefdbBackend.exists takes a string argument"); |
| 526 | return NULL; |
| 527 | } |
| 528 | ref_name = PyUnicode_AsUTF8(py_str); |
| 529 | |
| 530 | err = self->refdb_backend->exists(&exists, self->refdb_backend, ref_name); |
| 531 | if (err != 0) |
| 532 | return Error_set(err); |
| 533 | |
| 534 | if (exists) |
| 535 | Py_RETURN_TRUE; |
| 536 | else |
| 537 | Py_RETURN_FALSE; |
| 538 | } |
| 539 | |
| 540 | PyDoc_STRVAR(RefdbBackend_lookup__doc__, |
| 541 | "lookup(refname: str) -> Reference\n" |