Repository navigation
Conversation
Add two cases for Diff#findSimilar: - With renamesFromRewrites, the old side of a rewritten file is a rename source, so moving its content to a new path is reported as Added + Renamed. - renamesFromRewrites: false must not clear renames. Both fail on main, where renamesFromRewrites is passed to renames().
DiffFindOptions.renamesFromRewrites was forwarded to git2::DiffFindOptions::renames(), so it toggled GIT_DIFF_FIND_RENAMES instead of GIT_DIFF_FIND_RENAMES_FROM_REWRITES. Setting it to true never used rewritten files as rename sources, and setting it to false cleared an explicit renames: true. Forward it to renames_from_rewrites(), as StatusOptions already does.
|
@poketopa is attempting to deploy a commit to the Toss Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Diff#findSimilarpassedrenamesFromRewritestogit2::DiffFindOptions::renames(), so the option toggledGIT_DIFF_FIND_RENAMESinstead ofGIT_DIFF_FIND_RENAMES_FROM_REWRITES:renamesFromRewrites: truenever used the old side of a rewritten file as a rename source. WhenAis rewritten and its old content moves toA-renamed, the result wasModified A+Added A-renamedinstead ofAdded A+Renamed A -> A-renamed.renamesFromRewrites: falsecleared an explicitrenames: true. With no find flag left, libgit2 falls back todiff.renames, so renames were not detected when that config isfalse.Changes
renamesFromRewritestorenames_from_rewrites(), the setterStatusOptionsalready uses for its field of the same name.tests/diff.spec.ts. Both fail onmainand pass with this change.The public API and the generated
index.js/index.d.tsare unchanged. libgit2 turns onGIT_DIFF_FIND_RENAMESwheneverGIT_DIFF_FIND_RENAMES_FROM_REWRITESis set, so callers passing onlyrenamesFromRewrites: truestill get rename detection. They now also get rewritten files used as rename sources, which is what the option documents.Validation
Verified locally on macOS ARM64 with Rust 1.91.0 and Node.js 24.1.0:
yarn install --immutablejust format,just lint, andjust typecheckjust test: Vitest reported 244 passed and 1 existing test skipped; the Rust test target has no teststests/diff.spec.tsagainstmain: both new cases fail (Modified+Added, andDeleted+Added)yarn buildmatches the committedindex.jsandindex.d.tsgit diff --check