Corruption: git "stage selected ranges" on non-UTF8 #144469
Labels
bug
Issue identified by VS Code Team member as probable bug
*duplicate
Issue identified as a duplicate of another issue(s)
git
GIT issues
Issue Type: Bug
The "Stage selected ranges" feature of the built-in git extension corrupts the source code if the source code is in a non-UTF-8 text encoding.
This is specific to the vscode git extension; plain command-line git (
git add -p
) does not suffer from this defect.The following script sets up a clean git repo, produces a text file in text encoding cp1252 (which is Windows) containing "Zürich rocks" (which rocks the git extension's boat, ha!), constructs a good vscode workspace for that, and then we play with vscode to demonstrate the problem.
At this stage, you have vscode running without any extensions; your workspace is enabled for cp1252, and
myfile-cp1252.txt
contains two changes.In vscode, go to the git extension view, click on
myfile-cp1252.txt
, take note of the umlaut in Zürich being all fine and dandy.Now hightlight one of the changed lines and context menu -> "Stage selected ranges", and notice now
IOW, the left-hand side has data corruption, because something in the implementation of the vscode git extension actively performs magic text processing without retaining the workspace encoding cp1252.
Commentary:
Using
git add -p
, you will notice that this works just fine - because git in itself is not aware, and does not care, about text encodings.What's corrupted by "Stage selected ranges" is obviously also corrupted by "Revert selected ranges".
I do not think that this is a regression in 1.65.
VS Code version: Code 1.65.0 (b5205cc, 2022-03-02T11:12:36.248Z)
OS version: Linux x64 5.16.11-200.fc35.x86_64
Restricted Mode: No
The text was updated successfully, but these errors were encountered: