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

Function py_hex_to_git_oid

src/oid.c:53–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53size_t
54py_hex_to_git_oid(PyObject *py_oid, git_oid *oid)
55{
56 PyObject *py_hex;
57 int err;
58 char *hex;
59 Py_ssize_t len;
60
61 /* Unicode */
62 if (PyUnicode_Check(py_oid)) {
63 py_hex = PyUnicode_AsASCIIString(py_oid);
64 if (py_hex == NULL)
65 return 0;
66
67 err = PyBytes_AsStringAndSize(py_hex, &hex, &len);
68 if (err) {
69 Py_DECREF(py_hex);
70 return 0;
71 }
72
73 err = git_oid_fromstrn(oid, hex, len);
74 Py_DECREF(py_hex);
75 if (err < 0) {
76 PyErr_SetObject(Error_type(err), py_oid);
77 return 0;
78 }
79
80 return (size_t)len;
81 }
82
83 /* Type error */
84 PyErr_SetObject(PyExc_TypeError, py_oid);
85 return 0;
86}
87
88size_t
89py_oid_to_git_oid(PyObject *py_oid, git_oid *oid)

Callers 2

py_oid_to_git_oidFunction · 0.85
Oid_initFunction · 0.85

Calls 1

Error_typeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…