From e75875a094d3e2d3eac94ff962310810c91d6cec Mon Sep 17 00:00:00 2001 From: "Legein, Zach (SP)" Date: Fri, 6 Mar 2026 14:07:35 -0600 Subject: [PATCH] fix: filter out gitignore negation patterns to prevent excluding all files Negation patterns in .gitignore (lines starting with !) were being passed through to minimatch, which caused them to match ALL files instead of being ignored. For example, `!.vscode/settings.json` would match every file path because minimatch interprets the leading `!` as "NOT this pattern". This caused the entire index to be purged after initialization in projects with negation patterns in their .gitignore (common in monorepos). The fix filters out negation patterns in readGitignore() since they are meant to un-ignore files, not to add exclusion patterns. Made-with: Cursor --- src/commands/init.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/init.ts b/src/commands/init.ts index e0c4a9c..356b0c3 100644 --- a/src/commands/init.ts +++ b/src/commands/init.ts @@ -103,7 +103,7 @@ export function readGitignore(projectPath: string): string[] { return content .split('\n') .map(line => line.trim()) - .filter(line => line && !line.startsWith('#')) // Keine Kommentare/Leerzeilen + .filter(line => line && !line.startsWith('#') && !line.startsWith('!')) // Skip comments, empty lines, and negation patterns .map(pattern => { // Glob-kompatibel machen if (pattern.endsWith('/')) {