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

Function Odb_write

src/odb.c:256–290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

254 "object.");
255
256PyObject *
257Odb_write(Odb *self, PyObject *args)
258{
259 int err;
260 git_oid oid;
261 git_odb_stream* stream;
262 int type_id;
263 const char* buffer;
264 Py_ssize_t buflen;
265 git_otype type;
266
267 if (!PyArg_ParseTuple(args, "Is#", &type_id, &buffer, &buflen))
268 return NULL;
269
270 type = int_to_loose_object_type(type_id);
271 if (type == GIT_OBJECT_INVALID)
272 return PyErr_Format(PyExc_ValueError, "%d", type_id);
273
274 err = git_odb_open_wstream(&stream, self->odb, buflen, type);
275 if (err < 0)
276 return Error_set(err);
277
278 err = git_odb_stream_write(stream, buffer, buflen);
279 if (err) {
280 git_odb_stream_free(stream);
281 return Error_set(err);
282 }
283
284 err = git_odb_stream_finalize_write(&oid, stream);
285 git_odb_stream_free(stream);
286 if (err)
287 return Error_set(err);
288
289 return git_oid_to_python(&oid);
290}
291
292PyDoc_STRVAR(Odb_exists__doc__,
293 "exists(oid: Oid) -> bool\n"

Callers

nothing calls this directly

Calls 3

int_to_loose_object_typeFunction · 0.85
Error_setFunction · 0.85
git_oid_to_pythonFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…