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

Function git_head

src/watcher/watcher.c:133–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131}
132
133static int git_head(const char *root_path, char *out, size_t out_size) {
134 char cmd[CBM_SZ_1K];
135 snprintf(cmd, sizeof(cmd), "git -C \"%s\" rev-parse HEAD 2>%s", root_path, WATCHER_NULDEV);
136 FILE *fp = cbm_popen(cmd, "r");
137 if (!fp) {
138 return CBM_NOT_FOUND;
139 }
140
141 if (fgets(out, (int)out_size, fp)) {
142 size_t len = strlen(out);
143 while (len > 0 && (out[len - SKIP_ONE] == '\n' || out[len - SKIP_ONE] == '\r')) {
144 out[--len] = '\0';
145 }
146 cbm_pclose(fp);
147 return 0;
148 }
149 cbm_pclose(fp);
150 return CBM_NOT_FOUND;
151}
152
153/* Returns true if working tree has changes (modified, untracked, etc.).
154 * Also checks submodules via `git submodule foreach` to detect uncommitted

Callers 3

init_baselineFunction · 0.85
check_changesFunction · 0.85
poll_projectFunction · 0.85

Calls 2

cbm_popenFunction · 0.85
cbm_pcloseFunction · 0.85

Tested by

no test coverage detected