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

Function cbm_gitignore_parse

src/discover/gitignore.c:283–311  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281/* ── Public API ──────────────────────────────────────────────────── */
282
283cbm_gitignore_t *cbm_gitignore_parse(const char *content) {
284 if (!content) {
285 return NULL;
286 }
287
288 cbm_gitignore_t *gi = calloc(CBM_ALLOC_ONE, sizeof(cbm_gitignore_t));
289 if (!gi) {
290 return NULL;
291 }
292
293 const char *line = content;
294 while (*line) {
295 /* Find end of line */
296 const char *eol = strchr(line, '\n');
297 int len = eol ? (int)(eol - line) : (int)strlen(line);
298
299 /* Skip comments and blank lines */
300 if (len > 0 && line[0] != '#') {
301 gi_add_pattern(gi, line, len);
302 }
303
304 if (!eol) {
305 break;
306 }
307 line = eol + SKIP_ONE;
308 }
309
310 return gi;
311}
312
313cbm_gitignore_t *cbm_gitignore_load(const char *path) {
314 if (!path) {

Callers 3

cbm_gitignore_loadFunction · 0.85
test_gitignore.cFile · 0.85
repro_issue510.cFile · 0.85

Calls 1

gi_add_patternFunction · 0.85

Tested by

no test coverage detected