mirror of
https://github.com/DeusData/codebase-memory-mcp.git
synced 2026-11-09 09:11:00 +08:00
cbm_gitignore_merge copied src patterns into dst one strdup at a time and returned void on failure, leaving dst with a partial set of patterns and no signal to the caller. If the dropped pattern was the critical exclude (the .git/info/exclude entry that prevents an OOM walk), the bug could silently recur with some patterns applied and others dropped. Make the merge atomic: on any allocation failure roll back the partial copies so dst is left exactly as it was, and return bool so callers can tell. The .gitignore caller now degrades gracefully (exclude patterns skipped, as if the file were absent) instead of ending up with a half-merged matcher. Adds a reproduce-first test that injects a strdup failure mid-merge via a test seam and asserts dst is unchanged; it is red without the rollback. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>