Skip to content

fix(core): reduce snapshot Git scans - #43774

Closed
opencode-agent[bot] wants to merge 1 commit into
v2from
cpu-git-scan
Closed

opencode-agent[bot] wants to merge 1 commit into
v2from
cpu-git-scan

Conversation

@opencode-agent

@opencode-agent opencode-agent Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • replace parallel diff-files and ls-files --others calls with one stable porcelain-v2 status call
  • classify only worktree-side tracked changes and untracked files, preserving staged-only behavior
  • preserve tracked submodule dirtiness while excluding untracked-only submodule content
  • preserve per-submodule ignore settings while neutralizing unrelated global diff.ignoreSubmodules configuration
  • use sets for candidate filtering

Equivalence verification

Compared the old and new classified candidate sets directly:

  • 8,000 randomized comparisons across 1,000 seeds, four mutation phases, and full/scoped paths
  • targeted edits, deletions, mode changes, symlink changes, ignore rules, intent-to-add, assume-unchanged, skip-worktree, unmerged entries, staged-only and mixed changes, renames, recreated deletions, unusual filenames, and submodules
  • submodule checks include clean, tracked-dirty, untracked-only, moved HEAD, and ignore=all|dirty|untracked configurations

All candidate sets matched.

Verification

  • bun test test/git.test.ts from packages/core (5 passed)
  • git diff --check

Requested by: @rekram1-node (Aiden via Slack)

@opencode-agent opencode-agent Bot changed the title fix(core): reduce snapshot Git scans fix(core): linearize snapshot filtering Aug 21, 2026
@opencode-agent opencode-agent Bot changed the title fix(core): linearize snapshot filtering fix(core): reduce snapshot Git scans Aug 21, 2026
@Enough1122

Copy link
Copy Markdown

AI code review — automated review for reference; please use your judgment.

  • packages/core/src/git.ts:782-816 — parseStatus is a pure, intricate parser (rename pairs consume the following NUL-separated origPath via index++, fixed-width field math in statusPath) yet ships with zero unit tests. Please add direct cases: format-2 renames, filenames containing spaces (relies on skipping exactly N separators), unmerged u rows (10-field prefix), submodule rows, truncated/malformed rows, and empty output.
  • packages/core/src/git.ts:798-800 — excluding staged-only changes (Y === '.') intentionally mirrors the old diff-files semantics; that invariant is load-bearing but easy to break — add a comment noting "worktree-side deltas only" next to the changed computation.
  • packages/core/src/git.ts:426-431 — -c diff.ignoreSubmodules=untracked changes behavior beyond saving a process: untracked content inside submodules will no longer appear as snapshot candidates. If intentional, please state it in the PR description; if not, drop the config override.
  • packages/core/src/git.ts:801-803 — on truncated rows submodule[1] !== '.' evaluates against undefined, so changed fails open and the path is still included — safe direction (extra hashing, never missed changes), but a field-count sanity check before slicing would make silent corruption visible.
  • packages/core/src/git.ts:463 — nit: Array.from(allowed) materializes a second intermediate array; building the complement directly while constructing allowed would avoid it. Trivial.

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants