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

Function pt_populate

tests/test_test_impact_tree.c:646–686  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

644}
645
646static bool pt_populate(pt_fixture *fx) {
647 fx->large = cbm_arena_alloc(&fx->arena, PT_LARGE);
648 if (!fx->large)
649 return false;
650 for (size_t i = 0; i < PT_LARGE; i++)
651 fx->large[i] = (unsigned char)(i % 251U);
652 fx->rows[0] = (pt_row){
653 .path = "binary.bin", .mode = 0100644, .bytes = pt_binary, .length = sizeof(pt_binary)};
654 fx->rows[1] = (pt_row){
655 .path = "copy.bin", .mode = 0100644, .bytes = pt_shared, .length = sizeof(pt_shared) - 1};
656 fx->rows[2] =
657 (pt_row){.path = "empty", .mode = 0100644, .bytes = (const unsigned char *)"", .length = 0};
658 fx->rows[3] =
659 (pt_row){.path = "large", .mode = 0100644, .bytes = fx->large, .length = PT_LARGE};
660 fx->rows[4] = (pt_row){.path = "nested/source.c",
661 .mode = 0100644,
662 .bytes = pt_after,
663 .length = sizeof(pt_after) - 1};
664 fx->rows[5] = (pt_row){
665 .path = "run", .mode = 0100755, .bytes = pt_shared, .length = sizeof(pt_shared) - 1};
666 fx->count = 6;
667 for (size_t i = 0; i < fx->count; i++)
668 if (!pt_object(fx, "blob", fx->rows[i].bytes, fx->rows[i].length, fx->rows[i].oid))
669 return false;
670 pt_row ancestor[PT_ROWS];
671 memcpy(ancestor, fx->rows, sizeof(ancestor));
672 ancestor[4].bytes = pt_before;
673 ancestor[4].length = sizeof(pt_before) - 1;
674 if (!pt_object(fx, "blob", pt_before, sizeof(pt_before) - 1, ancestor[4].oid))
675 return false;
676 strcpy(fx->before_oid, ancestor[4].oid);
677 char empty[65], before[65], after[65];
678 return pt_index_tree(fx, NULL, 0, empty) && pt_commit(fx, empty, NULL, NULL, "A", fx->a) &&
679 pt_commit(fx, empty, fx->a, NULL, "P", fx->p) &&
680 pt_index_tree(fx, ancestor, fx->count, before) &&
681 pt_commit(fx, before, fx->a, NULL, "Q", fx->q) &&
682 pt_index_tree(fx, fx->rows, fx->count, after) &&
683 pt_commit(fx, after, fx->p, fx->q, "H", fx->head) &&
684 pt_commit(fx, before, fx->q, NULL, "B", fx->base) &&
685 pt_ref(fx, "refs/heads/topic", fx->head) && pt_ref(fx, "refs/heads/base", fx->base);
686}
687
688static bool pt_open_facts(pt_fixture *fx) {
689 cbm_git_facts_options_t options = {.root = fx->repo,

Callers 3

pt_pinned_roundFunction · 0.85
ptr_setupFunction · 0.85

Calls 5

pt_objectFunction · 0.85
pt_index_treeFunction · 0.85
pt_commitFunction · 0.85
pt_refFunction · 0.85
cbm_arena_allocFunction · 0.50

Tested by

no test coverage detected