Microsoft/vscode

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

Open

#96 104 ouverte le 24 avr. 2020

Voir sur GitHub
 (12 commentaires) (1 réaction) (1 assigné)TypeScript (10 221 forks)batch import
buggithelp wanted

Métriques du dépôt

Stars
 (74 848 stars)
Métriques de merge PR
 (Merge moyen 14h 20m) (999 PRs mergées en 30 j)

Description

  • VSCode Version: Tested on 1.44.2 and 1.45.0 insiders
  • OS Version: Windows 10 Build 18363

Steps to Reproduce:

  1. Make any change in a file which has CRLF line endings in the git repository

image

  1. Stage the change from the git diff UI in vscode using "stage selected ranges"

image

  1. use git diff --staged to see the diff of the file (making sure diff.wsErrorHighlight is set to "all", otherwise you still can't see the changes), and see that the line endings for the entire file have now changed: image

image

This is especially insidious if you happen to have core.autocrlf set to true, because the files will continue to look identical on disk when checked out, they will only differ in the repo itself (and when you go to submit a PR, it looks like the whole file changed, but github doesn't identify that the change is in the line endings, which can lead to lots of confusion when you look back on disk and see no change).

Also, the git diff UI in VS Code will not show the differences, even with Ignore Trim Whitespace set to false, which means the user has no idea that his line endings are being clobbered, potentially for weeks or months.

Does this issue occur when all extensions are disabled?: Yes, tested with a fresh install of latest stable (1.44.2) with no extensions

Guide contributeur