Observed file-size limits request cancellation. They are not instantaneous * disk quotas; final retained bytes are bounded independently after quiescence. */
| 473 | /* Observed file-size limits request cancellation. They are not instantaneous |
| 474 | * disk quotas; final retained bytes are bounded independently after quiescence. */ |
| 475 | static bool gf_run_input(cbm_git_facts_t *facts, const char *const *arguments, int count, |
| 476 | bool allow_exit_one, const cbm_git_bytes_t *input, gf_result_t *out, |
| 477 | cbm_git_facts_error_t *error) { |
| 478 | memset(out, 0, sizeof(*out)); |
| 479 | out->exit_code = -1; |
| 480 | if (!gf_gate(facts, error)) |
| 481 | return false; |
| 482 | if (facts->commands >= facts->options.command_limit) |
| 483 | return gf_limit(facts, error, "Git command-count limit exceeded"); |
| 484 | const char *argv[GF_ARG_CAP]; |
| 485 | int argc = 0; |
| 486 | const char *prefix[] = {facts->options.git_executable, |
| 487 | "--no-replace-objects", |
| 488 | "--no-pager", |
| 489 | "--literal-pathspecs", |
| 490 | "-C", |
| 491 | facts->options.root, |
| 492 | "-c", |
| 493 | "protocol.allow=never", |
| 494 | "-c", |
| 495 | "core.fsmonitor=false"}; |
| 496 | size_t prefix_count = sizeof(prefix) / sizeof(prefix[0]); |
| 497 | size_t directory_count = facts->command_git_dir ? 4 : 0; |
| 498 | if (count < 1 || count >= GF_ARG_CAP || |
| 499 | (size_t)count + prefix_count + directory_count + (size_t)facts->git_pin_count + 2 > |
| 500 | GF_ARG_CAP) |
| 501 | return gf_error(error, CBM_GIT_FACTS_INVALID, "Invalid internal Git command"); |
| 502 | for (size_t i = 0; i < prefix_count; i++) |
| 503 | argv[argc++] = prefix[i]; |
| 504 | if (facts->no_lazy_fetch) |
| 505 | argv[argc++] = "--no-lazy-fetch"; |
| 506 | if (facts->command_git_dir) { |
| 507 | argv[argc++] = "--git-dir"; |
| 508 | argv[argc++] = facts->command_git_dir; |
| 509 | argv[argc++] = "--work-tree"; |
| 510 | argv[argc++] = facts->identity.root; |
| 511 | } |
| 512 | for (int i = 0; i < facts->git_pin_count; i++) |
| 513 | argv[argc++] = facts->git_pins[i]; |
| 514 | for (int i = 0; i < count; i++) |
| 515 | argv[argc++] = arguments[i]; |
| 516 | argv[argc] = NULL; |
| 517 | gf_capture_t capture; |
| 518 | if (!gf_capture_create(facts, &capture, error)) |
| 519 | return false; |
| 520 | bool ok = gf_gate(facts, error) && gf_capture_input(facts, &capture, input, error); |
| 521 | cbm_subprocess_t *process = NULL; |
| 522 | cbm_proc_result_t result = {0}; |
| 523 | if (ok) { |
| 524 | cbm_proc_opts_t options = {.bin = facts->options.git_executable, |
| 525 | .argv = argv, |
| 526 | .log_file = capture.err, |
| 527 | .quiet_timeout_ms = 0, |
| 528 | .cancel_grace_ms = CBM_SUBPROCESS_DEFAULT_CANCEL_GRACE_MS, |
| 529 | .strip_git_repo_env = true, |
| 530 | .stdout_file = capture.out, |
| 531 | .stdin_file = input ? capture.in : NULL}; |
| 532 | facts->commands++; |
no test coverage detected