Skip to content

fix(git): add --ignore-cr-at-eol to git diff commands - #35654

Closed
iiAhmedYT wants to merge 1 commit into
anomalyco:devfrom
iiAhmedYT:dev
Closed

iiAhmedYT wants to merge 1 commit into
anomalyco:devfrom
iiAhmedYT:dev

Conversation

@iiAhmedYT

Copy link
Copy Markdown

Issue for this PR

Closes #27276, Closes #30357

Type of change

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

What does this PR do?

On Windows, the Review window and Changes tab show modified files as if the entire file was rewritten. The root cause is the hardcoded core.autocrlf=false in packages/opencode/src/git/index.ts.

Windows defaults to core.autocrlf=true, which converts LF->CRLF on checkout. The VCS layer overrides this to false, so git diff compares CRLF working trees against LF repository blobs literally, marking every text file line as changed.

Fix: Add --ignore-cr-at-eol to all 4 git diff commands in git/index.ts so git ignores carriage-return at end-of-line during comparison. This makes a single-line edit in a 1000-line file show as +1/-1 instead of +1000/-1000.

How did you verify your code works?

  • --ignore-cr-at-eol makes git treat \r\n and \n as identical in diff computation. Affects all diff modes: --name-status, --numstat, --patch (single and bulk).
  • Works on every git diff variant. Supported since Git 2.26 (2020).
  • No-op on platforms without CRLF working trees (macOS/Linux).
  • Actual file content is unchanged -- only the diff display ignores CR at line endings.

Screenshots / recordings

N/A

Checklist

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

@iiAhmedYT

iiAhmedYT commented Jul 7, 2026 •

Copy link
Copy Markdown
Author

Also likely related: #33750
Windows user reporting phantom diffs in changes panel that don't exist according to terminal git status. Same CRLF root cause.

On Windows core.autocrlf=false forces literal CRLF/LF comparison
between working tree and index. This makes git diff report every
line as changed when only line endings differ.

Adding --ignore-cr-at-eol to all git diff/patch commands makes
CRLF differences transparent in diff display, so a 1-line edit
shows as +/-1 instead of +/-1000.
@PandaYuuHa

Copy link
Copy Markdown

Thanks for working on this. I think adding --ignore-cr-at-eol is a workaround rather than addressing the root cause.

The Git service currently overrides repository/user configuration with:

-c core.autocrlf=false
-c core.symlinks=true

On Windows, this can conflict with a checkout using core.autocrlf=true and core.symlinks=false. The former causes CRLF-only false positives, while the latter causes symlink placeholders such as packages/docs/openapi.json and various PNG/ICO/SVG/manifest files to appear as type changes or deletions. These files are stored as mode 120000 in Git.

--ignore-cr-at-eol also only affects git diff; git status can remain inconsistent, and legitimate CR changes may be hidden.

A more complete fix would be to stop overriding these two settings and let Git respect the repository/user configuration:

 const cfg = [
   "--no-optional-locks",
-  "-c",
-  "core.autocrlf=false",
   "-c",
   "core.fsmonitor=false",
   "-c",
   "core.longpaths=true",
-  "-c",
-  "core.symlinks=true",
   "-c",
   "core.quotepath=false",
 ] as const

It would also be useful to add regression tests for a CRLF checkout with core.autocrlf=true and a symlink placeholder checkout with core.symlinks=false. This should fix both issues without changing the intended diff semantics.

@iiAhmedYT

Copy link
Copy Markdown
Author

As much as I wanted it fixed, It's sadly not going to happen. They ignore most PRs here.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Review panel show wrong changes [Bug] Git diff shows unmodified files as "Modified" on Windows (CRLF + symlink type changes)

2 participants