Skip to content

Scope the git diff worktree walk - #145

Merged
aron-cf merged 1 commit into
mainfrom
git-diff-scoped-status
Sep 14, 2026
Merged

aron-cf merged 1 commit into
mainfrom
git-diff-scoped-status

Conversation

@aron-cf

@aron-cf aron-cf commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

The diff() function now previously walked the entire file tree when the paths argument was provided. Now it walks only the list applicable to the filter.

To see the difference, take a repository with one source file and three thousand vendor files, change the source file, and diff just that directory:

const patch = await ws.git.diff({ paths: ["src"] });
paths visited time
before 3,001 326 ms
after 1 19 ms

Devin Review

@changeset-bot

changeset-bot Bot commented Sep 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c815262

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@cloudflare/computer Patch
@cloudflare/dofs Patch
@cloudflare/computer-rpc Patch
@cloudflare/computerd Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@pkg-pr-new

pkg-pr-new Bot commented Sep 14, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@cloudflare/computer@145

commit: c815262

diff({ paths }) filtered after statusMatrix had already walked the whole
worktree and handed every path to its map callback. Once a synced
node_modules is in the tree that walk dominates a diff that the caller
scoped to a handful of files.

Pass the requested paths to isomorphic-git's filepaths so the traversal
is pruned up front. filepaths uses the same "exact path or directory
prefix" rule as makePathFilter, so this is a traversal hint only: the
filter stays the authority on what is emitted and results are unchanged.

normalizeFilepaths returns undefined when the caller asked for no
scoping, or when a path normalizes to the repo root, so isomorphic-git's
own default of ['.'] stands rather than scoping to everything.
@aron-cf
aron-cf force-pushed the git-diff-scoped-status branch from 805035c to c815262 Compare September 14, 2026 12:21
@aron-cf
aron-cf merged commit a495760 into main Sep 14, 2026
19 checks passed
@aron-cf
aron-cf deleted the git-diff-scoped-status branch September 14, 2026 12:29
@github-actions github-actions Bot mentioned this pull request Sep 14, 2026
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