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

Function pt_init

tests/test_test_impact_tree.c:604–644  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

602}
603
604static bool pt_init(pt_fixture *fx, unsigned width) {
605 memset(fx, 0, sizeof(*fx));
606 cbm_arena_init(&fx->arena);
607 fx->width = width;
608 const char *home = th_mktempdir("cbm-pinned-tree");
609 if (!home || strlen(home) >= sizeof(fx->home))
610 return pt_setup_step("init:home", false);
611 strcpy(fx->home, home);
612 /* Owned fixture home prevents an unrelated user directory probe. */
613 const char *git = cbm_find_cli("git", fx->home);
614 if (!git || strlen(git) >= sizeof(fx->git))
615 return pt_setup_step("init:git-resolution", false);
616#ifdef _WIN32
617 if (!((git[0] && git[1] == ':' && (git[2] == '/' || git[2] == '\\')) ||
618 (git[0] == '\\' && git[1] == '\\')))
619 return pt_setup_step("init:git-absolute-path", false);
620#else
621 if (git[0] != '/')
622 return pt_setup_step("init:git-absolute-path", false);
623#endif
624 strcpy(fx->git, git);
625 if (!pt_join(fx->repo, fx->home, "repo") || !pt_join(fx->capture, fx->home, "stdout") ||
626 !pt_join(fx->log, fx->home, "stderr") || !pt_join(fx->input, fx->home, "input") ||
627 th_mkdir_p(fx->repo) != 0)
628 return pt_setup_step("init:path-and-mkdir", false);
629 if (!pt_private_parent(fx))
630 return pt_setup_step("init:private-parent", false);
631 const char *init[] = {"-c",
632 "init.templateDir=",
633 "init",
634 "--quiet",
635 width == 40 ? "--object-format=sha1" : "--object-format=sha256",
636 "--initial-branch=topic",
637 NULL};
638 char sentinel[PT_PATH];
639 return pt_setup_step("init:git-init", pt_git(fx, init, NULL, 0)) &&
640 pt_setup_step("init:git-config", pt_repo_config(fx)) &&
641 pt_setup_step("init:sentinel-path", pt_join(sentinel, fx->parent, "sentinel")) &&
642 pt_setup_step("init:sentinel-write", pt_write(sentinel, "parent-owned\n", 13)) &&
643 pt_setup_step("init:sentinel-audit", pt_parent_only_sentinel(fx->parent));
644}
645
646static bool pt_populate(pt_fixture *fx) {
647 fx->large = cbm_arena_alloc(&fx->arena, PT_LARGE);

Callers 3

pt_pinned_roundFunction · 0.85
ptr_setupFunction · 0.85

Calls 11

th_mktempdirFunction · 0.85
pt_setup_stepFunction · 0.85
cbm_find_cliFunction · 0.85
pt_joinFunction · 0.85
th_mkdir_pFunction · 0.85
pt_private_parentFunction · 0.85
pt_gitFunction · 0.85
pt_repo_configFunction · 0.85
pt_writeFunction · 0.85
pt_parent_only_sentinelFunction · 0.85
cbm_arena_initFunction · 0.50

Tested by

no test coverage detected