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

Function Odb_read

src/odb.c:179–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177 "Read raw object data from the object db.");
178
179PyObject *
180Odb_read(Odb *self, PyObject *py_hex)
181{
182 git_oid oid;
183 git_odb_object *obj;
184 size_t len;
185 git_object_t type;
186 PyObject* type_enum;
187 PyObject* tuple;
188
189 len = py_oid_to_git_oid(py_hex, &oid);
190 if (len == 0)
191 return NULL;
192
193 obj = Odb_read_raw(self->odb, &oid, len);
194 if (obj == NULL)
195 return NULL;
196
197 // Convert type to ObjectType enum
198 type = git_odb_object_type(obj);
199 type_enum = pygit2_enum(ObjectTypeEnum, type);
200
201 tuple = Py_BuildValue(
202 "(Oy#)",
203 type_enum,
204 git_odb_object_data(obj),
205 git_odb_object_size(obj));
206
207 git_odb_object_free(obj);
208 return tuple;
209}
210
211PyDoc_STRVAR(Odb_read_header__doc__,
212 "read_header(oid: Oid) -> tuple[enums.ObjectType, int]\n"

Callers

nothing calls this directly

Calls 3

py_oid_to_git_oidFunction · 0.85
Odb_read_rawFunction · 0.85
pygit2_enumFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…