MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / gf_batch_capture

Function gf_batch_capture

src/mcp/test_impact_git.c:1712–1744  ·  view source on GitHub ↗

One exact capture driver for production and deterministic parser tests. */

Source from the content-addressed store, hash-verified

1710
1711/* One exact capture driver for production and deterministic parser tests. */
1712static bool gf_batch_capture(cbm_git_facts_t *facts, cbm_git_bytes_t capture,
1713 const gf_batch_frames_t *frames, cbm_git_facts_error_t *error) {
1714 size_t at = 0;
1715 for (size_t i = 0; i < frames->count; i++) {
1716 if (!gf_batch_gate(facts, error))
1717 return false;
1718 const char *oid = frames->objects ? frames->objects[i].oid : frames->oids[i];
1719 cbm_git_bytes_t remaining = {capture.data ? capture.data + at : NULL, capture.length - at};
1720 gf_batch_header_t header;
1721 if (!gf_batch_header(facts, remaining, oid, frames->width, &header, error))
1722 return false;
1723 size_t size = header.size;
1724 bool check_size = frames->sizes || (frames->objects && frames->has_payload);
1725 size_t expected = frames->sizes ? frames->sizes[i]
1726 : frames->objects ? frames->objects[i].size
1727 : 0;
1728 if (check_size && size != expected)
1729 return gf_error(error, CBM_GIT_FACTS_COMMAND, "Git batch size changed after preflight");
1730 at += header.length;
1731 cbm_git_bytes_t bytes = {0};
1732 if (frames->has_payload && !gf_batch_payload(facts, capture, &at, size, &bytes, error))
1733 return false;
1734 if (frames->objects) {
1735 frames->objects[i].size = size;
1736 frames->objects[i].frame_length = header.length + size + 1;
1737 if (frames->has_payload)
1738 frames->objects[i].bytes = bytes;
1739 }
1740 }
1741 if (at != capture.length)
1742 return gf_error(error, CBM_GIT_FACTS_COMMAND, "Unexpected bytes after Git batch frames");
1743 return gf_batch_gate(facts, error);
1744}
1745
1746#ifdef CBM_ENABLE_TEST_SEAMS
1747bool cbm_git_facts_test_batch_header(cbm_git_bytes_t capture, const char *expected_oid,

Callers 2

gf_batch_commandFunction · 0.85

Calls 4

gf_batch_gateFunction · 0.85
gf_batch_headerFunction · 0.85
gf_errorFunction · 0.85
gf_batch_payloadFunction · 0.85

Tested by

no test coverage detected