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

Function Repository_init

src/repository.c:101–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101int
102Repository_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
142PyDoc_STRVAR(Repository__from_c__doc__, "Init a Repository from a pointer. For internal use only.");
143PyObject *

Callers

nothing calls this directly

Calls 1

Error_setFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…