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

Function Object_richcompare

src/object.c:259–290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

257}
258
259PyObject *
260Object_richcompare(PyObject *o1, PyObject *o2, int op)
261{
262 PyObject *res;
263
264 if (!PyObject_TypeCheck(o2, &ObjectType)) {
265 Py_INCREF(Py_NotImplemented);
266 return Py_NotImplemented;
267 }
268
269 int equal = git_oid_equal(Object__id((Object *)o1), Object__id((Object *)o2));
270 switch (op) {
271 case Py_NE:
272 res = (equal) ? Py_False : Py_True;
273 break;
274 case Py_EQ:
275 res = (equal) ? Py_True : Py_False;
276 break;
277 case Py_LT:
278 case Py_LE:
279 case Py_GT:
280 case Py_GE:
281 Py_INCREF(Py_NotImplemented);
282 return Py_NotImplemented;
283 default:
284 PyErr_Format(PyExc_RuntimeError, "Unexpected '%d' op", op);
285 return NULL;
286 }
287
288 Py_INCREF(res);
289 return res;
290}
291
292PyGetSetDef Object_getseters[] = {
293 GETTER(Object, id),

Callers

nothing calls this directly

Calls 1

Object__idFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…