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

Function cbm_git_branch_resolve

src/git/git_context.c:331–353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

329}
330
331int cbm_git_branch_resolve(const char *path, bool *is_git, char *branch, size_t branch_size) {
332 if (!is_git || !branch || branch_size == 0) {
333 return CBM_NOT_FOUND;
334 }
335 *is_git = false;
336 branch[0] = '\0';
337 if (!path || !path[0]) {
338 return CBM_NOT_FOUND;
339 }
340 if (!cbm_is_dir(path)) {
341 return 0;
342 }
343 char worktree_root[GIT_OUTPUT_MAX];
344 if (git_capture_into(path, "rev-parse --show-toplevel", worktree_root, sizeof(worktree_root)) !=
345 0) {
346 return 0;
347 }
348 *is_git = true;
349 if (git_capture_into(path, "symbolic-ref --quiet --short HEAD", branch, branch_size) != 0) {
350 snprintf(branch, branch_size, "%s", "DETACHED");
351 }
352 return 0;
353}
354
355char *cbm_git_context_branch_qn(const char *project_name, const cbm_git_context_t *ctx) {
356 const char *project = project_name && project_name[0] ? project_name : "project";

Callers 2

populate_project_recordFunction · 0.85
branch_resolve_agreesFunction · 0.85

Calls 2

cbm_is_dirFunction · 0.85
git_capture_intoFunction · 0.85

Tested by 1

branch_resolve_agreesFunction · 0.68