| 99 | } |
| 100 | |
| 101 | int |
| 102 | Repository_init(Repository *self, PyObject *args, PyObject *kwds) |
| 103 | { |
| 104 | PyObject *backend = NULL; |
| 105 | |
| 106 | if (kwds && PyDict_Size(kwds) > 0) { |
| 107 | PyErr_SetString(PyExc_TypeError, |
| 108 | "Repository takes no keyword arguments"); |
| 109 | return -1; |
| 110 | } |
| 111 | |
| 112 | if (!PyArg_ParseTuple(args, "|O", &backend)) { |
| 113 | return -1; |
| 114 | } |
| 115 | |
| 116 | if (backend == NULL) { |
| 117 | /* Create repository without odb/refdb */ |
| 118 | int err = git_repository_new(&self->repo); |
| 119 | if (err != 0) { |
| 120 | Error_set(err); |
| 121 | return -1; |
| 122 | } |
| 123 | self->owned = 1; |
| 124 | self->config = NULL; |
| 125 | self->index = NULL; |
| 126 | return 0; |
| 127 | } |
| 128 | |
| 129 | self->repo = PyCapsule_GetPointer(backend, "backend"); |
| 130 | if (self->repo == NULL) { |
| 131 | PyErr_SetString(PyExc_TypeError, |
| 132 | "Repository unable to unpack backend."); |
| 133 | return -1; |
| 134 | } |
| 135 | self->owned = 1; |
| 136 | self->config = NULL; |
| 137 | self->index = NULL; |
| 138 | |
| 139 | return 0; |
| 140 | } |
| 141 | |
| 142 | PyDoc_STRVAR(Repository__from_c__doc__, "Init a Repository from a pointer. For internal use only."); |
| 143 | PyObject * |
nothing calls this directly
no test coverage detected
searching dependent graphs…