Skip to content

Preserve CRLF during partial staging - #328187

Open
Vivek JM (vivekjm) wants to merge 2 commits into
microsoft:mainfrom
vivekjm:fix/git-stage-crlf
Open

Preserve CRLF during partial staging#328187
Vivek JM (vivekjm) wants to merge 2 commits into
microsoft:mainfrom
vivekjm:fix/git-stage-crlf

Conversation

@vivekjm

Copy link
Copy Markdown
Contributor

Fixes #96104

Partial staging hashes the edited contents with hash-object --path. When core.autocrlf is enabled, Git applies that setting during hashing and silently converts an indexed CRLF file to LF, including lines outside the selected range.

This checks the indexed line ending with git ls-files --eol and disables core.autocrlf only while hashing files whose index form is CRLF. Other files and configured clean filters keep their existing behavior.

Tests run:

  • npm run gulp compile-extension:git (0 errors)
  • Focused CRLF partial-staging regression test (1 passing)
  • Full Git extension test suite (57 passing, 2 pre-existing pending)
  • Pre-commit hygiene and diff checks

Copilot AI review requested due to automatic review settings July 30, 2026 10:09
@vs-code-engineering

vs-code-engineering Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Ladislau Szomoru (@lszomoru)

Matched files:

  • extensions/git/src/git.ts
  • extensions/git/src/main.ts
  • extensions/git/src/test/smoke.test.ts

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

Pull request overview

Preserves indexed CRLF line endings during partial Git staging.

Changes:

  • Detects indexed CRLF files before hashing.
  • Temporarily disables core.autocrlf for those files.
  • Adds CRLF regression coverage.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
extensions/git/src/git.ts Adjusts partial-staging object hashing.
extensions/git/src/test/smoke.test.ts Adds CRLF partial-staging coverage.

Comment thread extensions/git/src/git.ts Outdated
Comment thread extensions/git/src/git.ts Outdated
Comment thread extensions/git/src/test/smoke.test.ts
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.

Git - "Stage selected ranges" clobbers line endings for the entire file without any warning (Windows)

3 participants