| 92 | } |
| 93 | |
| 94 | static int |
| 95 | pgit_odb_backend_read_prefix(git_oid *oid_out, void **ptr, size_t *sz, git_object_t *type, |
| 96 | git_odb_backend *_be, const git_oid *short_id, size_t len) |
| 97 | { |
| 98 | // short_id to hex |
| 99 | char short_id_hex[GIT_OID_HEXSZ]; |
| 100 | git_oid_nfmt(short_id_hex, len, short_id); |
| 101 | |
| 102 | // Call callback |
| 103 | pgit_odb_backend *be = (pgit_odb_backend *)_be; |
| 104 | PyObject *result = PyObject_CallMethod(be->py_backend, "read_prefix_cb", "s#", short_id_hex, len); |
| 105 | if (result == NULL) |
| 106 | return git_error_for_exc(); |
| 107 | |
| 108 | // Parse output from callback |
| 109 | PyObject *py_oid_out; |
| 110 | Py_ssize_t type_value; |
| 111 | Py_ssize_t py_sz; |
| 112 | const char *bytes; |
| 113 | if (!PyArg_ParseTuple(result, "ny#O", &type_value, &bytes, &py_sz, &py_oid_out) || !bytes) { |
| 114 | Py_DECREF(result); |
| 115 | return GIT_EUSER; |
| 116 | } |
| 117 | *type = (git_object_t)type_value; |
| 118 | *sz = (size_t)py_sz; |
| 119 | |
| 120 | *ptr = git_odb_backend_data_alloc(_be, *sz); |
| 121 | if (!*ptr) { |
| 122 | Py_DECREF(result); |
| 123 | return GIT_EUSER; |
| 124 | } |
| 125 | |
| 126 | memcpy(*ptr, bytes, *sz); |
| 127 | py_oid_to_git_oid(py_oid_out, oid_out); |
| 128 | Py_DECREF(result); |
| 129 | return 0; |
| 130 | } |
| 131 | |
| 132 | static int |
| 133 | pgit_odb_backend_read_header(size_t *len, git_object_t *type, |
nothing calls this directly
no test coverage detected
searching dependent graphs…