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

Function pgit_odb_backend_read

src/odb_backend.c:59–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57} pgit_odb_backend;
58
59static int
60pgit_odb_backend_read(void **ptr, size_t *sz, git_object_t *type,
61 git_odb_backend *_be, const git_oid *oid)
62{
63 pgit_odb_backend *be = (pgit_odb_backend *)_be;
64
65 PyObject *py_oid = git_oid_to_python(oid);
66 if (py_oid == NULL)
67 return GIT_EUSER;
68
69 PyObject *result = PyObject_CallMethod(be->py_backend, "read_cb", "N", py_oid);
70 if (result == NULL)
71 return git_error_for_exc();
72
73 const char *bytes;
74 Py_ssize_t type_value;
75 Py_ssize_t py_sz;
76 if (!PyArg_ParseTuple(result, "ny#", &type_value, &bytes, &py_sz) || !bytes) {
77 Py_DECREF(result);
78 return GIT_EUSER;
79 }
80 *type = (git_object_t)type_value;
81 *sz = (size_t)py_sz;
82
83 *ptr = git_odb_backend_data_alloc(_be, *sz);
84 if (!*ptr) {
85 Py_DECREF(result);
86 return GIT_EUSER;
87 }
88
89 memcpy(*ptr, bytes, *sz);
90 Py_DECREF(result);
91 return 0;
92}
93
94static int
95pgit_odb_backend_read_prefix(git_oid *oid_out, void **ptr, size_t *sz, git_object_t *type,

Callers

nothing calls this directly

Calls 2

git_oid_to_pythonFunction · 0.85
git_error_for_excFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…