| 278 | " specified in `flags` (only applicable when `as_path` is set).\n"); |
| 279 | |
| 280 | PyObject * |
| 281 | Blob__write_to_queue(Blob *self, PyObject *args, PyObject *kwds) |
| 282 | { |
| 283 | PyObject *py_queue = NULL; |
| 284 | PyObject *py_ready = NULL; |
| 285 | PyObject *py_closed = NULL; |
| 286 | Py_ssize_t chunk_size = STREAM_CHUNK_SIZE; |
| 287 | char *as_path = NULL; |
| 288 | PyObject *py_oid = NULL; |
| 289 | int err; |
| 290 | char *keywords[] = {"queue", "ready", "closed", "chunk_size", "as_path", "flags", "commit_id", NULL}; |
| 291 | git_blob_filter_options opts = GIT_BLOB_FILTER_OPTIONS_INIT; |
| 292 | git_filter_options filter_opts = GIT_FILTER_OPTIONS_INIT; |
| 293 | git_filter_list *fl = NULL; |
| 294 | git_blob *blob = NULL; |
| 295 | const git_oid *blob_oid; |
| 296 | struct blob_filter_stream writer; |
| 297 | |
| 298 | if (!PyArg_ParseTupleAndKeywords(args, kwds, "OOO|nzIO", keywords, |
| 299 | &py_queue, &py_ready, &py_closed, |
| 300 | &chunk_size, &as_path, &opts.flags, |
| 301 | &py_oid)) |
| 302 | return NULL; |
| 303 | |
| 304 | if (Object__load((Object*)self) == NULL) { return NULL; } // Lazy load |
| 305 | |
| 306 | /* we load our own copy of this blob since libgit2 objects are not |
| 307 | * thread-safe */ |
| 308 | blob_oid = Object__id((Object*)self); |
| 309 | err = git_blob_lookup(&blob, git_blob_owner(self->blob), blob_oid); |
| 310 | if (err < 0) |
| 311 | return Error_set(err); |
| 312 | |
| 313 | if (as_path != NULL && |
| 314 | !((opts.flags & GIT_BLOB_FILTER_CHECK_FOR_BINARY) != 0 && |
| 315 | git_blob_is_binary(blob))) |
| 316 | { |
| 317 | if (py_oid != NULL && py_oid != Py_None) |
| 318 | { |
| 319 | err = py_oid_to_git_oid(py_oid, &opts.attr_commit_id); |
| 320 | if (err < 0) |
| 321 | return Error_set(err); |
| 322 | } |
| 323 | |
| 324 | if ((opts.flags & GIT_BLOB_FILTER_NO_SYSTEM_ATTRIBUTES) != 0) |
| 325 | filter_opts.flags |= GIT_FILTER_NO_SYSTEM_ATTRIBUTES; |
| 326 | if ((opts.flags & GIT_BLOB_FILTER_ATTRIBUTES_FROM_HEAD) != 0) |
| 327 | filter_opts.flags |= GIT_FILTER_ATTRIBUTES_FROM_HEAD; |
| 328 | if ((opts.flags & GIT_BLOB_FILTER_ATTRIBUTES_FROM_COMMIT) != 0) |
| 329 | filter_opts.flags |= GIT_FILTER_ATTRIBUTES_FROM_COMMIT; |
| 330 | git_oid_cpy(&filter_opts.attr_commit_id, &opts.attr_commit_id); |
| 331 | |
| 332 | err = git_filter_list_load_ext(&fl, git_blob_owner(blob), blob, |
| 333 | as_path, GIT_FILTER_TO_WORKTREE, |
| 334 | &filter_opts); |
| 335 | if (err < 0) |
| 336 | { |
| 337 | if (blob != NULL) |
nothing calls this directly
no test coverage detected
searching dependent graphs…