Skip to content

Find commit that adds a file without git log --follow - #2382

Open
Krrishkumar125 wants to merge 1 commit into
changesets:mainfrom
Krrishkumar125:fix/slow-commit-lookup-no-follow
Open

Krrishkumar125 wants to merge 1 commit into
changesets:mainfrom
Krrishkumar125:fix/slow-commit-lookup-no-follow

Conversation

@Krrishkumar125

Copy link
Copy Markdown

Fixes #2364.

What

getCommitsThatAddFiles in @changesets/git used git log --diff-filter=AC --follow to find the commit that added each changeset file. --follow turns on rename detection against every file in the parent tree. On git 2.56 that work also runs for each parent of a merge commit, and in a blobless clone git lazily fetches those blobs to do the comparison. Running it once per changeset means a repo with many pending changesets can pull in most of the tree, and changeset version can take many minutes in CI.

This replaces --follow with a two step lookup:

  1. Find where a file was added with git log --diff-filter=A --no-renames.
  2. If that commit renamed the file into place, read the rename with a single git diff --name-status -M between that commit and its parent, then keep walking back under the old name.

The returned commit is the same one --follow returned.

Why

--follow's cost is rename detection across the whole parent tree, repeated per changeset. The rename only matters at the one commit that added the file, so checking there is enough and avoids the tree wide scan and the lazy blob fetches.

Tests

  • All existing getCommitsThatAddFiles tests pass, including the rename, rename-then-tweak, exact-copy and highly-similar cases.
  • Added a test for a chain of renames (a.js to b.js to c.js) resolving back to the original add commit from a depth 1 shallow clone.

Run with pnpm vitest run packages/git/src/index.test.ts (37 passed).

git 2.56 made --follow much slower in blobless clones because it does
rename detection against every file in the parent tree, once per parent
of a merge. For a monorepo with many pending changesets this can make
changeset version take many minutes. Find the add with renames off and
check for a rename only on that single commit, walking the chain back
when there is one, which returns the same commit as --follow did.
Copilot AI balanced review requested due to automatic review settings November 15, 2026 11:48
@netlify

netlify Bot commented Nov 15, 2026

Copy link
Copy Markdown

👷 Deploy request for changesets pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit e9b4d6b

@changeset-bot

changeset-bot Bot commented Nov 15, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e9b4d6b

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

This PR includes changesets to release 6 packages
Name Type
@changesets/git Patch
@changesets/apply-release-plan Patch
@changesets/cli Patch
@changesets/read Patch
@changesets/release-utils Patch
@changesets/get-release-plan 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

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@codecov

codecov Bot commented Nov 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.53%. Comparing base (9a035ec) to head (e9b4d6b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2382      +/-   ##
==========================================
+ Coverage   87.47%   87.53%   +0.05%     
==========================================
  Files          78       78              
  Lines        2971     2985      +14     
  Branches      851      858       +7     
==========================================
+ Hits         2599     2613      +14     
  Misses        337      337              
  Partials       35       35              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

ota-meshi added a commit to mmd-toolkit/mmd-toolkit that referenced this pull request Nov 16, 2026
…o the release job does not run out of memory (#113)

On git 2.56 each lookup in this repository takes about 290 MB, and
changesets runs one for each pending changeset at once. The patch of
@changesets/git follows changesets/changesets#2382.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

changeset version is very slow in blobless clones with git 2.56 because of git log --follow

2 participants