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

Function expand_git_path

src/discover/discover.c:217–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215}
216
217static bool expand_git_path(const char *path, char *out, size_t out_sz) {
218 if (!path || !path[0] || !out || out_sz == 0) {
219 return false;
220 }
221 char normalized[CBM_SZ_4K];
222 snprintf(normalized, sizeof(normalized), "%s", path);
223 cbm_normalize_path_sep(normalized);
224
225 if (normalized[0] != '~') {
226 snprintf(out, out_sz, "%s", normalized);
227 cbm_normalize_path_sep(out);
228 return out[0] != '\0';
229 }
230
231 if (normalized[1] != '\0' && normalized[1] != '/') {
232 return false; /* ~user expansion is intentionally not supported. */
233 }
234
235 const char *home = cbm_get_home_dir();
236 if (!home || home[0] == '\0') {
237 return false;
238 }
239 if (normalized[1] == '\0') {
240 snprintf(out, out_sz, "%s", home);
241 cbm_normalize_path_sep(out);
242 } else {
243 path_join(out, out_sz, home, normalized + GIT_TILDE_PREFIX_LEN);
244 }
245 return out[0] != '\0';
246}
247
248static bool read_core_excludes_file(const char *config_path, char *out, size_t out_sz) {
249 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