Skip to content

fix(git): refactor untracked file handling in getAllFileDiffs function#84

Merged
johannesjo merged 1 commit intojohannesjo:mainfrom
FourWindff:fix/changed-files-preview
Apr 24, 2026
Merged

fix(git): refactor untracked file handling in getAllFileDiffs function#84
johannesjo merged 1 commit intojohannesjo:mainfrom
FourWindff:fix/changed-files-preview

Conversation

@FourWindff
Copy link
Copy Markdown
Contributor

Description

Fixes untracked files not appearing in the diff viewer when multiple untracked files reside under a newly created
directory.

getAllFileDiffs previously used git status --porcelain to discover untracked files. When an entire directory
is untracked, Git collapses the output to a single directory entry (e.g. ?? src/components/) instead of listing
each individual file. The code treated this directory path as a file path, stat.isFile() returned false, and
every untracked file inside that directory was silently skipped — so they never appeared in the diff preview.

This change replaces git status --porcelain with git ls-files --others --exclude-standard, which always emits
one line per file regardless of directory structure. This aligns getAllFileDiffs with getChangedFiles, which
already uses the same ls-files command for untracked file detection.

Issues Resolved

  • Untracked files in new directories (e.g. src/components/mdx/Blockquote.tsx) are now correctly included in the
    diff viewer output.
  • Eliminates the discrepancy where the changed-files sidebar (powered by getChangedFiles) showed the files, but
    clicking them opened an empty diff because getAllFileDiffs had dropped them.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@johannesjo
Copy link
Copy Markdown
Owner

Thank you very much ! <3

@johannesjo johannesjo merged commit c20de32 into johannesjo:main Apr 24, 2026
2 checks passed
@FourWindff FourWindff deleted the fix/changed-files-preview branch April 24, 2026 13:40
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.

2 participants