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

Function Reference_init

src/reference.c:143–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141}
142
143int
144Reference_init(Reference *self, PyObject *args, PyObject *kwds)
145{
146 const char *name;
147 git_oid oid, peel;
148 PyObject *py_oid, *py_peel;
149
150 if (kwds && PyDict_Size(kwds) > 0) {
151 PyErr_SetString(PyExc_TypeError, "Reference takes no keyword arguments");
152 return -1;
153 }
154
155 Py_ssize_t nargs = PyTuple_Size(args);
156 if (nargs == 2) {
157 return Reference_init_symbolic(self, args, kwds);
158 } else if (nargs != 3) {
159 PyErr_SetString(PyExc_TypeError,
160 "Invalid arguments to Reference constructor");
161 return -1;
162 }
163
164 if (!PyArg_ParseTuple(args, "sOO", &name, &py_oid, &py_peel)) {
165 return -1;
166 }
167
168 py_oid_to_git_oid(py_oid, &oid);
169 if (py_peel != Py_None) {
170 py_oid_to_git_oid(py_peel, &peel);
171 }
172
173 self->reference = git_reference__alloc(name, &oid, &peel);
174 return 0;
175}
176
177void
178Reference_dealloc(Reference *self)

Callers

nothing calls this directly

Calls 2

Reference_init_symbolicFunction · 0.85
py_oid_to_git_oidFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…