Skip to content

fix(vcs): batch untracked diff checks#15

Merged
CreatorGhost merged 2 commits into
devfrom
vcs-batch-untracked
Jul 12, 2026
Merged

fix(vcs): batch untracked diff checks#15
CreatorGhost merged 2 commits into
devfrom
vcs-batch-untracked

Conversation

@CreatorGhost

@CreatorGhost CreatorGhost commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Port of upstream anomalyco/opencode#35997.

Adds diffUntracked() using a temporary git index so untracked-file diffs are computed in one batched git invocation instead of per-file spawns — a large speedup for repos with many untracked files and for no-HEAD (freshly-initialized) repos.

Verified: bun test test/project/vcs.test.ts (14 pass) and bun typecheck from packages/opencode. Applied cleanly.

Summary by CodeRabbit

  • New Features

    • Added support for displaying patches and file statistics for untracked files.
    • Untracked changes are now included in diff results for repositories without an initial commit.
    • Improved handling of files with special characters in their names.
  • Bug Fixes

    • Diff generation now reliably falls back when untracked-file processing cannot be completed.
    • Improved patch batching for mixed tracked and untracked changes.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f25a28ee-0cbb-4828-bcf1-02e33c62c33d

📥 Commits

Reviewing files that changed from the base of the PR and between b834fdc and 53e9832.

📒 Files selected for processing (3)
  • packages/opencode/src/git/index.ts
  • packages/opencode/src/project/vcs.ts
  • packages/opencode/test/project/vcs.test.ts

📝 Walkthrough

Walkthrough

Adds a Git API for batching untracked patches and statistics through a temporary index. The VCS layer uses these batches for repositories without a HEAD, with tests covering call sequencing, per-file metadata, and special filenames.

Changes

Untracked diff batching

Layer / File(s) Summary
Git untracked diff API
packages/opencode/src/git/index.ts
Adds diffUntracked, using nul-delimited pathspecs, a temporary Git index, unified patch and numstat commands, fail-closed results, and cleanup.
Patch batch handling
packages/opencode/src/project/vcs.ts
Adds PatchBatch.includesUntracked and propagates it through untracked batching and capped per-file patch handling.
No-HEAD VCS integration and validation
packages/opencode/src/project/vcs.ts, packages/opencode/test/project/vcs.test.ts
Builds untracked batches when no HEAD exists and tests patch output, statistics, call order, and special filenames.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant VcsTrack
  participant GitStatus
  participant GitDiffUntracked
  participant GitRepository
  VcsTrack->>GitStatus: inspect repository status
  GitStatus-->>VcsTrack: untracked files
  VcsTrack->>GitRepository: check HEAD
  GitRepository-->>VcsTrack: no HEAD
  VcsTrack->>GitDiffUntracked: batch untracked files
  GitDiffUntracked-->>VcsTrack: patch and statistics
  VcsTrack-->>GitRepository: construct per-file diff output
Loading
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch vcs-batch-untracked

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@CreatorGhost CreatorGhost force-pushed the vcs-batch-untracked branch from b8b75fd to 730aa43 Compare July 12, 2026 06:57
@CreatorGhost

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

…ilenames

Addresses Opus review of PR #15: guard diffUntracked against a failed
intent-to-add (return empty batch so caller falls back to per-file native
patches) and add a no-HEAD untracked test exercising NUL-pathspec escaping.
@CreatorGhost CreatorGhost force-pushed the vcs-batch-untracked branch from 730aa43 to 53e9832 Compare July 12, 2026 13:28
@CreatorGhost CreatorGhost merged commit a377911 into dev Jul 12, 2026
4 of 6 checks passed
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.

1 participant