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

Function expand_git_path

src/discover/discover.c:228–257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226}
227
228static bool expand_git_path(const char *path, char *out, size_t out_sz) {
229 if (!path || !path[0] || !out || out_sz == 0) {
230 return false;
231 }
232 char normalized[CBM_SZ_4K];
233 snprintf(normalized, sizeof(normalized), "%s", path);
234 cbm_normalize_path_sep(normalized);
235
236 if (normalized[0] != '~') {
237 snprintf(out, out_sz, "%s", normalized);
238 cbm_normalize_path_sep(out);
239 return out[0] != '\0';
240 }
241
242 if (normalized[1] != '\0' && normalized[1] != '/') {
243 return false; /* ~user expansion is intentionally not supported. */
244 }
245
246 const char *home = cbm_get_home_dir();
247 if (!home || home[0] == '\0') {
248 return false;
249 }
250 if (normalized[1] == '\0') {
251 snprintf(out, out_sz, "%s", home);
252 cbm_normalize_path_sep(out);
253 } else {
254 path_join(out, out_sz, home, normalized + GIT_TILDE_PREFIX_LEN);
255 }
256 return out[0] != '\0';
257}
258
259static bool read_core_excludes_file(const char *config_path, char *out, size_t out_sz) {
260 FILE *f = cbm_fopen(config_path, "r");

Callers 1

read_core_excludes_fileFunction · 0.85

Calls 3

cbm_normalize_path_sepFunction · 0.85
cbm_get_home_dirFunction · 0.85
path_joinFunction · 0.85

Tested by

no test coverage detected