MCPcopy Create free account
hub / github.com/libgit2/pygit2 / init_file_backend

Function init_file_backend

src/pygit2.c:198–232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196 "\n"
197 "Open repo backend given path.");
198PyObject *
199init_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
235PyDoc_STRVAR(reference_is_valid_name__doc__,

Callers 1

__init__Method · 0.85

Calls 1

Error_set_strFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…