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

Function pt_git

tests/test_test_impact_tree.c:498–534  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

496}
497
498static bool pt_git(pt_fixture *fx, const char *const *tail, char *output, size_t capacity) {
499 const char *argv[48] = {
500 fx->git, "-C", fx->repo, "-c", "commit.gpgSign=false", "-c", "core.autocrlf=false"};
501 size_t used = 7;
502 for (size_t i = 0; tail[i]; i++) {
503 if (used + 1 >= sizeof(argv) / sizeof(argv[0]))
504 return pt_git_failed(fx, tail, "argv-capacity", -1, NULL);
505 argv[used++] = tail[i];
506 }
507 argv[used] = NULL;
508 cbm_proc_opts_t options = {.bin = fx->git,
509 .argv = argv,
510 .stdout_file = fx->capture,
511 .log_file = fx->log,
512 .quiet_timeout_ms = 10000,
513 .strip_git_repo_env = true};
514 cbm_proc_result_t result = {0};
515 int run_rc = cbm_subprocess_run(&options, &result);
516 if (run_rc != 0 || result.outcome != CBM_PROC_CLEAN || result.exit_code != 0 ||
517 !result.tree_quiesced || result.supervision_failed)
518 return pt_git_failed(fx, tail, "run", run_rc, &result);
519 if (!output)
520 return true;
521 FILE *file = cbm_fopen(fx->capture, "rb");
522 if (!file || !capacity) {
523 if (file)
524 (void)fclose(file);
525 return pt_git_failed(fx, tail, "capture-open-or-capacity", run_rc, &result);
526 }
527 size_t length = fread(output, 1, capacity - 1, file);
528 bool ok = fgetc(file) == EOF && !ferror(file);
529 output[length] = 0;
530 int close_rc = fclose(file);
531 if (close_rc != 0 || !ok)
532 return pt_git_failed(fx, tail, "capture-read-EOF-or-close", run_rc, &result);
533 return true;
534}
535
536static bool pt_oid(pt_fixture *fx, const char *const *argv, char out[65]) {
537 char bytes[80];

Callers 6

pt_oidFunction · 0.85
pt_refFunction · 0.85
pt_index_treeFunction · 0.85
pt_repo_configFunction · 0.85
pt_initFunction · 0.85
pt_pinned_roundFunction · 0.85

Calls 4

pt_git_failedFunction · 0.85
cbm_subprocess_runFunction · 0.85
cbm_fopenFunction · 0.85
freadFunction · 0.85

Tested by

no test coverage detected