fix(core): respect .gitignore for tracked files in isGitIgnored (#703)#821
Merged
glittercowboy merged 1 commit intogsd-build:mainfrom Mar 2, 2026
Merged
Conversation
…sd-build#703) Without --no-index, git check-ignore only reports files as ignored if they are untracked. Once .planning/ files enter git's index (e.g., from an initial commit before .gitignore was set up), check-ignore returns "not ignored" even when .gitignore explicitly lists .planning/. This means the documented safety net — "if .planning/ is gitignored, commit_docs is automatically false" — silently fails for any repo where .planning/ was ever committed. The --no-index flag checks .gitignore rules regardless of tracking state, matching user expectations. Closes gsd-build#703 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Feb 28, 2026
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What This Fixes
When
.planning/files have been committed to a repo and.planning/is later added to.gitignore, theisGitIgnored()function incore.cjsincorrectly reports them as "not ignored." This means the automaticcommit_docs: falsesafety net — designed to prevent unwanted.planning/commits — silently fails.This is a subtle interaction between git's index and
.gitignorethat can catch people off guard. Once files enter git's tracked index,git check-ignoreconsiders them "not ignored" regardless of what.gitignoresays. It's standard git behavior, but it breaks the assumption that.gitignoreentries are always respected.The Fix
A one-word addition:
--no-indexon thegit check-ignorecall.The
--no-indexflag tells git to evaluate.gitignorerules without consulting the index, which matches what users expect: if.planning/is in.gitignore, treat it as ignored regardless of tracking history.Why It Matters
This is especially relevant for projects that started with
commit_docs: true(the default) and later decided to stop committing planning docs. Without this fix, the transition is silent —.planning/files keep getting committed even after adding them to.gitignore, and the auto-detection safety net that's supposed to catch this never triggers.The issue reporter also noted this compounds with the auto-advance nesting behavior (#668/#686), where agents doing raw
git addbypass thecommit_docsconfig entirely. This fix addresses theisGitIgnored()detection half of that problem.Test Plan
.planning/tracked +.planning/in.gitignore:isGitIgnoredshould returntrue.planning/untracked +.planning/in.gitignore:isGitIgnoredshould returntrue(unchanged behavior).planning/tracked +.planning/NOT in.gitignore:isGitIgnoredshould returnfalse(unchanged behavior)Recovery Note for Affected Users
If
.planning/files are already committed and you want to stop tracking them:git rm -r --cached .planning/ git commit -m "chore: stop tracking .planning/ (now gitignored)"Closes #703
🤖 Generated with Claude Code