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

Function Commit_parents__get__

src/commit.c:231–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

229PyDoc_STRVAR(Commit_parents__doc__, "The list of parent commits.");
230
231PyObject *
232Commit_parents__get__(Commit *self)
233{
234 Repository *py_repo;
235 unsigned int i, parent_count;
236 const git_oid *parent_oid;
237 git_commit *parent;
238 int err;
239 PyObject *py_parent;
240 PyObject *list;
241
242 if (Object__load((Object*)self) == NULL) { return NULL; } // Lazy load
243
244 parent_count = git_commit_parentcount(self->commit);
245 list = PyList_New(parent_count);
246 if (!list)
247 return NULL;
248
249 py_repo = self->repo;
250 for (i=0; i < parent_count; i++) {
251 parent_oid = git_commit_parent_id(self->commit, i);
252 if (parent_oid == NULL) {
253 Py_DECREF(list);
254 Error_set(GIT_ENOTFOUND);
255 return NULL;
256 }
257
258 err = git_commit_lookup(&parent, py_repo->repo, parent_oid);
259 if (err < 0) {
260 Py_DECREF(list);
261 return Error_set_oid(err, parent_oid, GIT_OID_HEXSZ);
262 }
263
264 py_parent = wrap_object((git_object*)parent, py_repo, NULL);
265 if (py_parent == NULL) {
266 Py_DECREF(list);
267 return NULL;
268 }
269
270 PyList_SET_ITEM(list, i, py_parent);
271 }
272
273 return list;
274}
275
276PyDoc_STRVAR(Commit_parent_ids__doc__, "The list of parent commits' ids.");
277

Callers

nothing calls this directly

Calls 4

Object__loadFunction · 0.85
Error_setFunction · 0.85
Error_set_oidFunction · 0.85
wrap_objectFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…