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

Function cbm_gitignore_parse

src/discover/gitignore.c:256–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

254/* ── Public API ──────────────────────────────────────────────────── */
255
256cbm_gitignore_t *cbm_gitignore_parse(const char *content) {
257 if (!content) {
258 return NULL;
259 }
260
261 cbm_gitignore_t *gi = calloc(CBM_ALLOC_ONE, sizeof(cbm_gitignore_t));
262 if (!gi) {
263 return NULL;
264 }
265
266 const char *line = content;
267 while (*line) {
268 /* Find end of line */
269 const char *eol = strchr(line, '\n');
270 int len = eol ? (int)(eol - line) : (int)strlen(line);
271
272 /* Skip comments and blank lines */
273 if (len > 0 && line[0] != '#') {
274 gi_add_pattern(gi, line, len);
275 }
276
277 if (!eol) {
278 break;
279 }
280 line = eol + SKIP_ONE;
281 }
282
283 return gi;
284}
285
286cbm_gitignore_t *cbm_gitignore_load(const char *path) {
287 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