Skip to content

fix: exclude git-ignored files from staged snapshot divergence check - #1621

Open
skoshx wants to merge 2 commits into
mainfrom
cursor/triage-1620-3694
Open

fix: exclude git-ignored files from staged snapshot divergence check#1621
skoshx wants to merge 2 commits into
mainfrom
cursor/triage-1620-3694

Conversation

@skoshx

@skoshx skoshx commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Root Cause

The parseStagedSnapshotDivergences function was treating ALL non-space worktree statuses as divergences, including "!" (git-ignored files). Since git-ignored files can never be staged, they should not block --staged scans with divergence errors.

Git status with --ignored=matching includes ignored files with worktree status "!". The existing condition if (worktreeStatus !== " ") caught these ignored files along with genuinely modified files, causing false positives on every commit in projects with git-ignored config files (e.g., .opencode/package.json).

Scope

The fix is narrowly scoped to exclude only worktree status "!" from the divergence check:

if (worktreeStatus !== " " && worktreeStatus !== "!") {

This preserves the correct behavior for:

  • Genuinely modified tracked config files (still blocked, as intended)
  • Untracked-but-not-ignored config files (still reported, as intended)
  • Staged source files with later worktree edits (still isolated, as intended)

Only git-ignored config files are now correctly excluded, since they structurally cannot cause the "staged snapshot doesn't match worktree" problem this gate exists to prevent.

Changes

  • Updated parse-staged-snapshot-divergences.ts to exclude worktree status "!"
  • Split the existing test into two cases: ordinary untracked (still reported) and ignored (now accepted)
  • Added unit test for the "!" status parser behavior
  • Added integration test for the reported .opencode/package.json case

Testing

All existing tests pass, including:

  • The new regression tests for git-ignored config files
  • The existing divergence detection tests (unchanged behavior for tracked files)
  • Full test suite (278 files passed)
  • Lint and typecheck clean

Parity Analysis

This fix doesn't affect diagnostic rules or scan output - it only fixes a pre-scan gate check that was incorrectly blocking --staged mode. Parity is not applicable since:

  1. This is a gate check fix, not a rule change
  2. The change only affects --staged mode, which isn't used in corpus scans
  3. No diagnostic output changes - only the ability to proceed with the scan

Closes #1620

Open in Web Open in Cursor 

cursoragent and others added 2 commits August 9, 2026 15:46
Co-authored-by: Skosh <skoshx@users.noreply.github.com>
Co-authored-by: Skosh <skoshx@users.noreply.github.com>
@pkg-pr-new

pkg-pr-new Bot commented Aug 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/eslint-plugin-react-doctor@1621
npm i https://pkg.pr.new/oxlint-plugin-react-doctor@1621
npm i https://pkg.pr.new/react-doctor@1621

commit: aa1fb80

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

React Doctor found no new issues. 🎉

Reviewed by React Doctor for commit aa1fb80.

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Interactive terminal E2E

Terminal Control verified the built CLI at aa1fb80 in a real PTY:

  • selected a project interactively and observed Scanning... before the three-second Git delay completed
  • waited for the clean result and exercised the compact report
  • opened copy context and the GitHub Actions confirmation, then cancelled safely

Download the edited MP4 and PNG evidence

@skoshx
skoshx marked this pull request as ready for review August 9, 2026 15:53
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.

--staged divergence gate false-positives on git-ignored config files (e.g. a gitignored local package.json)

2 participants