Skip to content

fix(core): respect repository line endings and symlinks in git diffs - #64884

Merged
neriousy merged 1 commit into
devfrom
vcs-autocrlf
Nov 19, 2026
Merged

neriousy merged 1 commit into
devfrom
vcs-autocrlf

Conversation

@neriousy

@neriousy neriousy commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Issue for this PR

Closes #64863

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

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:

  • With core.autocrlf=true (the Git for Windows system default), blobs are LF and the checkout is CRLF. Forcing false compares them byte for byte, so every line of every edited file shows as changed.
  • With core.symlinks=false (Windows clones without symlink permission), symlinks are checked out as plain files holding their target. Forcing true reports 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=false and --no-optional-locks stay. The snapshot repository's autocrlf = false in packages/core/src/git.ts is unchanged.

I went with this rather than --ignore-cr-at-eol (#27277, #35654) because that flag only affects how patch lines are compared. git status and --name-status would still list CRLF-only files as modified, and it does nothing for symlinks.

Risk: this only changes results for repos whose config sets autocrlf or symlinks=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?

  • Two regression tests in packages/core/test/vcs.test.ts: a repo with core.autocrlf=true and 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 a core.symlinks=false repo 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.ts in packages/core and bun test test/vcs.test.ts in packages/server pass on Windows. bun typecheck in packages/core passes.

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #55360

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@neriousy
neriousy merged commit 0a297bf into dev Nov 19, 2026
13 checks passed
@neriousy
neriousy deleted the vcs-autocrlf branch November 19, 2026 14:08
joe-ieta pushed a commit to joe-ieta/OpenCode.My that referenced this pull request Nov 19, 2026
@amrkmn amrkmn mentioned this pull request Nov 23, 2026
1 task
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.

[Bug] Windows VCS diff still shows whole files modified — the 2025 autocrlf fix (PR #4356) lost in V2 rewrite, reproduces on v2.3.2

1 participant