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

Function hashfile

src/pygit2.c:147–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145 "Returns the oid of a new blob from a file path without actually writing\n"
146 "to the odb.");
147PyObject *
148hashfile(PyObject *self, PyObject *args)
149{
150 git_oid oid;
151 PyBytesObject *py_path = NULL;
152 const char* path = NULL;
153 int err;
154
155 if (!PyArg_ParseTuple(args, "O&", PyUnicode_FSConverter, &py_path))
156 return NULL;
157
158 if (py_path != NULL)
159 path = PyBytes_AS_STRING(py_path);
160
161 err = git_odb_hashfile(&oid, path, GIT_OBJECT_BLOB);
162 Py_XDECREF(py_path);
163 if (err < 0)
164 return Error_set(err);
165
166 return git_oid_to_python(&oid);
167}
168
169PyDoc_STRVAR(hash__doc__,
170 "hash(data: bytes) -> Oid\n"

Callers

nothing calls this directly

Calls 2

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…