Repository navigation
fix(core): respect repository line endings and symlinks in git diffs - #64884
Conversation
There was a problem hiding this comment.
The fix works. I ran the #64863 reproduction with OpenCode started from source and core.autocrlf=true in the system git config. On the base, /api/vcs/diff reports a.txt +50 -50. With this change it reports +1 -1, the same as git diff --numstat. With autocrlf=true, the batched untracked-file path and the per-file git diff --no-index fallback still produce identical patches. The two new tests fail on the base and pass with the fix. The core and server VCS tests and the tsc type check pass.
Public API: unchanged. The HTTP response shape is the same; only the results for repositories that set core.autocrlf or core.symlinks=false change, and they now match git's own output.
No blocking concerns.
Related: #55360
…nomalyco#64884) (cherry picked from commit 0a297bf)
Issue for this PR
Closes #64863
Type of change
What does this PR do?
The git VCS plugin ran every command against the user's checkout with
-c core.autocrlf=false -c core.symlinks=true. These flags were copied from the snapshot repository when the git-backed review modes were added (#17961). They are right there, because both sides of a snapshot diff are raw bytes, but wrong for a real checkout:core.autocrlf=true(the Git for Windows system default), blobs are LF and the checkout is CRLF. Forcingfalsecompares them byte for byte, so every line of every edited file shows as changed.core.symlinks=false(Windows clones without symlink permission), symlinks are checked out as plain files holding their target. Forcingtruereports each one as modified.This drops both overrides so the review pane uses the repository's own config and matches
git status/git diff.fsmonitor=false,longpaths=true,quotepath=falseand--no-optional-locksstay. The snapshot repository'sautocrlf = falseinpackages/core/src/git.tsis unchanged.I went with this rather than
--ignore-cr-at-eol(#27277, #35654) because that flag only affects how patch lines are compared.git statusand--name-statuswould still list CRLF-only files as modified, and it does nothing for symlinks.Risk: this only changes results for repos whose config sets
autocrlforsymlinks=false, and there it now matches what git itself reports. VCS patches are only displayed, never applied back to files.How did you verify your code works?
packages/core/test/vcs.test.ts: a repo withcore.autocrlf=trueand a one-line edit to a CRLF file reports+1 -1(it was+20 -20, and an untouched CRLF file now stays out of the list), and acore.symlinks=falserepo with a committed symlink is clean. Both fail before the fix.bun run script/test.ts test/vcs.test.ts test/plugin/vcs-init.test.tsinpackages/coreandbun test test/vcs.test.tsinpackages/serverpass on Windows.bun typecheckinpackages/corepasses.Screenshots / recordings
N/A
Checklist
Added by the opencode bot (AI-generated).
Related: #55360