fix(git): include untracked files in diffs - #250
Conversation
Generate no-index diffs for untracked files during unstaged detection. Closes #198
|
Warning Review limit reached
Next review available in: 56 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 23a1bbfe08
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| .map((file) => { | ||
| const result = spawnSync('git', ['diff', '--no-index', '--', '/dev/null', file], { |
There was a problem hiding this comment.
Avoid spawning one Git process per untracked file
When a working tree contains hundreds or thousands of non-ignored untracked files, this synchronous map launches a separate git diff process for every file before prompting or applying the configured diff truncation. In the inspected Linux environment, 1,000 tiny files took about 14 seconds, so an untracked generated or dependency tree can make suggest appear hung for minutes; generate the untracked patch in a bounded/batched operation or stop once the usable diff limit is reached.
Useful? React with 👍 / 👎.
| if (result.error) throw result.error; | ||
| if (result.status !== 0 && result.status !== 1) { | ||
| throw new Error(result.stderr.trim() || `git diff --no-index exited with code ${result.status}`); | ||
| } | ||
| return result.stdout; |
There was a problem hiding this comment.
Do not treat every exit status 1 as a valid diff
When the untracked entry is an embedded Git repository, git ls-files --others returns a directory such as nested/, and git diff --no-index /dev/null nested/ emits Could not access 'nested/null' while also exiting with status 1. This condition accepts that access error as an ordinary difference, discards the empty stdout, and ultimately reports no changes, so the original untracked-only failure remains for repositories adding a submodule or embedded repository; distinguish an actual patch from status-1 errors or handle directory entries explicitly.
Useful? React with 👍 / 👎.
|
| .split('\0') | ||
| .filter(Boolean) | ||
| .map((file) => { | ||
| const result = spawnSync('git', ['diff', '--no-index', '--', '/dev/null', file], { |
|
|
||
| export function getUnstagedDiff(): DiffResult { | ||
| const diff = execSync('git diff', { | ||
| const trackedDiff = execSync('git diff', { |




Summary
Ensures the single-repository suggestion flow recognizes and analyzes untracked files when no staged changes exist.
Changes
Testing
npm run buildnode --test tests/git-diff.test.mjsRelated
Closes #198