Skip to content

fix(core): respect .gitignore for tracked files in isGitIgnored (#703)#821

Merged
glittercowboy merged 1 commit intogsd-build:mainfrom
Tibsfox:fix/config-and-path-corrections
Mar 2, 2026
Merged

fix(core): respect .gitignore for tracked files in isGitIgnored (#703)#821
glittercowboy merged 1 commit intogsd-build:mainfrom
Tibsfox:fix/config-and-path-corrections

Conversation

@Tibsfox
Copy link
Contributor

@Tibsfox Tibsfox commented Feb 28, 2026

What This Fixes

When .planning/ files have been committed to a repo and .planning/ is later added to .gitignore, the isGitIgnored() function in core.cjs incorrectly reports them as "not ignored." This means the automatic commit_docs: false safety net — designed to prevent unwanted .planning/ commits — silently fails.

This is a subtle interaction between git's index and .gitignore that can catch people off guard. Once files enter git's tracked index, git check-ignore considers them "not ignored" regardless of what .gitignore says. It's standard git behavior, but it breaks the assumption that .gitignore entries are always respected.

The Fix

A one-word addition: --no-index on the git check-ignore call.

- execSync('git check-ignore -q -- ' + targetPath...
+ execSync('git check-ignore -q --no-index -- ' + targetPath...

The --no-index flag tells git to evaluate .gitignore rules 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 add bypass the commit_docs config entirely. This fix addresses the isGitIgnored() detection half of that problem.

Test Plan

  • Project with .planning/ tracked + .planning/ in .gitignore: isGitIgnored should return true
  • Project with .planning/ untracked + .planning/ in .gitignore: isGitIgnored should return true (unchanged behavior)
  • Project with .planning/ tracked + .planning/ NOT in .gitignore: isGitIgnored should return false (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

…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>
@glittercowboy glittercowboy merged commit 023d3bc into gsd-build:main Mar 2, 2026
9 checks passed
cavanaug added a commit to cavanaug/get-shit-done that referenced this pull request Mar 3, 2026
Combined commits:
- fix(core): add --no-index to isGitIgnored for tracked file detection (gsd-build#703)
- fix(phase): add ROADMAP.md fallback to cmdPhaseComplete next-phase scan
- fix(core): prefer in-progress milestone marker in getMilestoneInfo
- fix(state): support both bold and plain field formats in state parsing
- fix(cli): preserve multi-word commit messages in CLI router
- fix(state): support both bold and plain field formats in all state.cjs functions
- fix(gemini): use AfterTool instead of PostToolUse for Gemini CLI hooks
- fix(opencode): detect runtime config directory instead of hardcoding .claude
- fix(workflow): use Skill instead of Task for auto-advance phase transitions
- fix(state): scope phase counting to current milestone
- fix(state): derive total_phases from ROADMAP when phases lack directories
- Merge pull request gsd-build#821 from Tibsfox/fix/config-and-path-corrections
- Merge pull request gsd-build#822 from Tibsfox/fix/core-lifecycle-state
- Merge pull request gsd-build#824 from Tibsfox/fix/gemini-hook-event
- Merge pull request gsd-build#825 from Tibsfox/fix/opencode-hardcoded-paths
- Merge pull request gsd-build#826 from Tibsfox/fix/auto-advance-nesting
- docs: add Copilot CLI runtime integration design doc
- docs(01-copilot-runtime): create phase plan — 3 plans for copilot runtime integration
- test(01-01): add failing tests for getCopilotSkillAdapterHeader + convertClaudeCommandToCopilotSkill
- feat(01-01): implement getCopilotSkillAdapterHeader, convertClaudeCommandToCopilotSkill, convertClaudeAgentToCopilotAgent
- test(01-02): add failing tests for installCopilotHooks + stripGsdFromCopilotHooks
- feat(01-02): implement installCopilotHooks and stripGsdFromCopilotHooks
- feat(01-03): wire copilot into arg parsing, getDirName, getGlobalDir, getConfigDirFromHome, banner, help, promptRuntime
- feat(01-03): wire copilot into install/uninstall/finishInstall + integration test
- refactor(install): collapse 4 converter helpers into 2 parameterized functions
- Revert "refactor(install): collapse 4 converter helpers into 2 parameterized functions"
- fix(copilot): restore 4 separate converter functions, fix Copilot-only bugs
- fix(copilot): omit metadata/short-description from Copilot SKILL.md frontmatter
- Merge branch 'gsd-build:main' into copilot_cli
- test(copilot): add missing agent and skill coverage
- test(copilot): add metadata/short-description stripping test for convertClaudeCommandToCopilotSkill
- remove: ➖ remove copilot planning documents
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

isGitIgnored() fails for tracked files — missing --no-index flag

2 participants