| 196 | "\n" |
| 197 | "Open repo backend given path."); |
| 198 | PyObject * |
| 199 | init_file_backend(PyObject *self, PyObject *args) |
| 200 | { |
| 201 | PyBytesObject *py_path = NULL; |
| 202 | const char* path = NULL; |
| 203 | unsigned int flags = 0; |
| 204 | int err = GIT_OK; |
| 205 | git_repository *repository = NULL; |
| 206 | PyObject *result = NULL; |
| 207 | |
| 208 | if (!PyArg_ParseTuple(args, "O&|I", PyUnicode_FSConverter, &py_path, &flags)) |
| 209 | return NULL; |
| 210 | if (py_path != NULL) |
| 211 | path = PyBytes_AS_STRING(py_path); |
| 212 | |
| 213 | err = git_repository_open_ext(&repository, path, flags, NULL); |
| 214 | |
| 215 | if (err == GIT_OK) { |
| 216 | result = PyCapsule_New(repository, "backend", NULL); |
| 217 | } else { |
| 218 | result = NULL; |
| 219 | Error_set_str(err, path); |
| 220 | |
| 221 | if (repository) { |
| 222 | git_repository_free(repository); |
| 223 | } |
| 224 | |
| 225 | if (err == GIT_ENOTFOUND) { |
| 226 | PyErr_Format(GitError, "Repository not found at %s", path); |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | Py_XDECREF(py_path); |
| 231 | return result; |
| 232 | } |
| 233 | |
| 234 | |
| 235 | PyDoc_STRVAR(reference_is_valid_name__doc__, |
no test coverage detected
searching dependent graphs…