Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git doesn't consider actual encoding in diff view #21146

Closed
izacsc opened this issue Feb 22, 2017 · 10 comments · Fixed by #24911
Closed

Git doesn't consider actual encoding in diff view #21146

izacsc opened this issue Feb 22, 2017 · 10 comments · Fixed by #24911
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug git GIT issues verified Verification succeeded
Milestone

Comments

@izacsc
Copy link

izacsc commented Feb 22, 2017

  • VSCode Version: 1.9.1
  • OS Version: Windows 10

Steps to Reproduce:

  1. Open a file with especific file encoding and change it.
  2. Observe encoding diferences in diff view

image

In the example above, I just added a blank line in a Windows 1252 file.

@izacsc izacsc changed the title SCM Preview doesn't consider actual encoding in diff view [GIT] SCM Preview doesn't consider actual encoding in diff view Feb 22, 2017
@joaomoreno joaomoreno added this to the March 2017 milestone Feb 28, 2017
@joaomoreno joaomoreno added bug Issue identified by VS Code Team member as probable bug git GIT issues labels Feb 28, 2017
@bizoo
Copy link

bizoo commented Mar 16, 2017

Note that this issue is not related to SCM Preview, I've the same behavior in 1.10.2 without it enabled.

@eamodio
Copy link
Contributor

eamodio commented Mar 17, 2017

@joaomoreno I have an open request to bring this same functionality to GitLens -- so it would be wonderful if what is done here would be accessible to extensions.

@zabel-xyz
Copy link

For now, I have to go back to the previous version with the command "Disable Preview SCM".
Because, it's too difficult to check the git differences with this encoding issue.
(VSCode 1.11.1)

@eamodio
Copy link
Contributor

eamodio commented Apr 9, 2017

I was hoping the new auto-detect of file encoding would help here, but it looks like that feature only works for actual files on disk and not via content providers. :(

@joaomoreno
Copy link
Member

Merged #24911 which enables decoding with the encoding configured in settings. This helps most users.

Can't really fix it all the way without #824.

@PorkyProgs
Copy link

PorkyProgs commented Sep 13, 2017

I guess that I am suffering from the same problem. I am not wise with GIT (I just hope it works) so I cannot say what encoding my files are being saved within the Git Repository.
I am having the following special effect when I compare my current file wit the one in the repository:
image
I am using:
image
And when I did a Git Diff from the cmdline I got:
Dev2-GIT[Develop]:09.13 14:09>git diff HEAD .\Runbooks\Manage-RBADObjects.ps1 diff --git a/Runbooks/Manage-RBADObjects.ps1 b/Runbooks/Manage-RBADObjects.ps1 index bf755e8..9869c25 100644 Binary files a/Runbooks/Manage-RBADObjects.ps1 and b/Runbooks/Manage-RBADObjects.ps1 differ
However, I am left no wiser after the event.
I wonder if the problem occurs during the uploading of the files into the Git Repository or if the data is per default saved in Git using different encoding.
When I view my Git Settings I have .....
Dev2-GIT[Develop]:09.13 14:09>git config --list core.symlinks=false core.autocrlf=true core.fscache=true color.diff=auto color.status=auto color.branch=auto color.interactive=true help.format=html rebase.autosquash=true http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt diff.astextplain.textconv=astextplain filter.lfs.clean=git-lfs clean -- %f filter.lfs.smudge=git-lfs smudge -- %f filter.lfs.required=true filter.lfs.process=git-lfs filter-process credential.helper=manager gui.recentrepo=C:/Depo/RB/Dev2-GIT user.name=Porky user.email=ilovegit@gmx.de difftool.sourcetree.cmd='C:/Users/Porky/Documents/PortableApps/WinMergePortable/WinMergePortable.exe' "$LOCAL" "$REMOTE" core.excludesfile=C:\Depo\RB\Dev2-GIT\.gitignore core.editor=code --wait http.proxy=http://149.249.158.30:8080 credential.helper=wincred core.repositoryformatversion=0 core.filemode=false core.bare=false core.logallrefupdates=true core.symlinks=false core.ignorecase=true core.hidedotfiles=dotGitOnly gui.wmstate=normal remote.origin.url=ssh://git@Our.Git.Repository.net:7999/Dev/sma.git remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* remote.origin.pushurl=ssh://git@Our.Git.Repository.net:7999/Dev/sma.git gitflow.branch.master=master gitflow.branch.develop=develop gitflow.prefix.feature=feature/ gitflow.prefix.release=release/ gitflow.prefix.hotfix=hotfix/ gitflow.prefix.support=support/ gitflow.prefix.versiontag= branch.master.remote=origin branch.master.merge=refs/heads/master branch.develop.remote=origin branch.develop.merge=refs/heads/develop user.name=Porky user.email=ilovegit@gmx.de

So far I have not been able to isolate exactly where the problem is, is it a Git problem or a Visual Team Studio problem? Incidentally, if it helps I am on a Win7SP1 box. I often edit files in the Powershell ISE and presume files are being save using UTF8.
Thanks for your suggestions in advance,
Porky

@joaomoreno joaomoreno changed the title [GIT] SCM Preview doesn't consider actual encoding in diff view Git doesn't consider actual encoding in diff view Nov 16, 2017
@larsxschneider
Copy link

I am working on a patch series for core Git to help Git understand different encodings. If this sounds interesting to you, then I would love to hear your feedback on my proposal: https://github.com/git/git/pull/440/files#diff-6fb066a3d66afe00c0995f97f5c680fd

The current mailing list discussion is here if you want to chime in:
https://public-inbox.org/git/DC552BF4-3E87-41E0-BF92-4BA9633D374E@gmail.com/

@vkavalchuk
Copy link

vkavalchuk commented Mar 22, 2018

I have the same issue with the Mercurial plugin (https://marketplace.visualstudio.com/items?itemName=mrcrowl.hg). Problem is the same on both views.

Inline diff view:
default

Diff view. Whole document marked as changed, but 2 lines deleted only:
default

Preferenced file encoding is set to "files.encoding": "windows-1251". VSCode version:
default

@joaomoreno
Copy link
Member

joaomoreno commented Mar 27, 2018

Fixed by having git attempt to detect encoding when files.autoGuessEncoding is enabled.

Some encodings are still improperly detected: https://github.com/Microsoft/vscode/issues?q=is%3Aopen+is%3Aissue+label%3Afile-encoding+label%3Aupstream

@bizoo
Copy link

bizoo commented Apr 4, 2018

IMHO, the only good way to solve this issue is to use the encoding of the view, so to first resolve #824.

Why having a proper API to set/get encoding is so long to be done ? Seriously, it's not a rhetorical question: Is it because it's difficult or because it's a very low priority thing ? Or something else ?

@vscodebot vscodebot bot locked and limited conversation to collaborators May 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug git GIT issues verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants