| 1955 | } |
| 1956 | |
| 1957 | static bool gf_batch_preflight(gf_batch_work_t *work, cbm_git_facts_error_t *error) { |
| 1958 | size_t worst_header = work->facts->identity.oid_hex_length + 7 + gf_batch_digits(SIZE_MAX); |
| 1959 | size_t batch = work->facts->options.stdout_limit / worst_header; |
| 1960 | if (!batch) |
| 1961 | batch = 1; |
| 1962 | for (size_t first = 0; first < work->unique_count;) { |
| 1963 | if (!gf_gate(work->facts, error)) |
| 1964 | return false; |
| 1965 | size_t count = work->unique_count - first; |
| 1966 | if (count > batch) |
| 1967 | count = batch; |
| 1968 | if (!gf_batch_command(work, first, count, false, error)) |
| 1969 | return false; |
| 1970 | first += count; |
| 1971 | } |
| 1972 | size_t total = 0; |
| 1973 | for (size_t i = 0; i < work->unique_count; i++) { |
| 1974 | if (!gf_gate(work->facts, error)) |
| 1975 | return false; |
| 1976 | size_t frame = work->objects[i].frame_length; |
| 1977 | if (frame > work->facts->options.stdout_limit || frame > SIZE_MAX - total) |
| 1978 | return gf_limit(work->facts, error, "Git batch payload frame exceeds output limit"); |
| 1979 | total += frame; |
| 1980 | } |
| 1981 | if (total > work->facts->options.total_output_limit - work->facts->output_bytes) |
| 1982 | return gf_limit(work->facts, error, "Git batch payloads exceed remaining output limit"); |
| 1983 | return gf_gate(work->facts, error); |
| 1984 | } |
| 1985 | |
| 1986 | static bool gf_batch_read_payloads(gf_batch_work_t *work, cbm_git_facts_error_t *error) { |
| 1987 | for (size_t first = 0; first < work->unique_count;) { |
no test coverage detected