sublimehq / sublime_merge

Issue tracker for Sublime Merge
https://www.sublimemerge.com
276 stars 14 forks source link

Stage Hunk messes with windows-1252 encoded files. #725

Closed deathaxe closed 4 years ago

deathaxe commented 4 years ago

Version info

Description

One of my repositories contains ANSI encoded files as the corresponding engineering application is from the 90's and doesn't know about utf-8. Therefore the i18n.filesencoding=Windows-1252 is set in the repositories .git/config file.

Steps to reproduce

  1. When saving the Windows-1252 encoded H5.asc file the diffs are displayed corectly.

    grafik

  2. When hitting "Stage" or git add H5.asc everything works as expected as well.

    grafik

  3. When hitting "Stage Hunk" (instead of "stage" from step 2), the corresponding hunk looks like utf-8 encoded but displayed as ANSI in the staging area.

    grafik

    At the same time, all lines containing none-ascii characters like ä, ö, ß, etc. are slightly highlighted in the working directory, too, even though the content looks equal and correct on both panes.

    grafik

  4. If hitting "Unsage Hunk" for the former staged hunk git fails with an error message.

    grafik

    I guess it detects conflicts due to changed encodings?

Expected behavior

Staging/Unstaging hunks should handle all file-encodings gracefully and respect the i18n.filesencoding setting.

Debug Info

=== App Version Information ===
Build: 2006

=== Git Version Information ===
Using Git: C:\Programs\Git\cmd\git.exe (custom)
git version 2.26.0.windows.1
PATH: c:\programs\git\cmd;c:\programs\git\mingw64\bin;c:\programs\git\usr\bin;c:\programs\gitextensions;c:\tools;c:\tools\sysinternals;c:\tools\winscp;c:\program files (x86)\common files\acronis\snapapi\;c:\program files (x86)\common files\emc;c:\program files (x86)\common files\siemens\sqlany;c:\program files (x86)\danfoss drives\communication module\bin;c:\program files (x86)\intel\opencl sdk\3.0\bin\x64;c:\program files (x86)\intel\opencl sdk\3.0\bin\x86;c:\program files (x86)\kaspersky lab\kaspersky endpoint security for windows\;c:\program files (x86)\pkware\pkzipc;c:\program files (x86)\siemens\installdisk;c:\program files (x86)\siemens\step7\s7bin;c:\program files\common files\siemens\automation\simatic oam\bin;c:\windows;c:\windows\system32;c:\windows\system32\wbem;c:\windows\system32\windowspowershell\v1.0\;c:\windows\syswow64\empirum;C:\Programs\Git\cmd;C:\Programs\Git\mingw64\bin;C:\Programs\Git\usr\bin;C:\Users\Public\Documents\RAD Studio\6.0\BPL

=== Browse Page Information ===
HEAD: 2ab17cf5228c28039c27d500afed09459ec2137e
Is in merge: 0
Is in cherry_pick: 0
Is in rebase: 0
Is in revert: 0

=== Git Status Information ===
MM H5.asc
 M H5/FB_WZV.awl
 M H5/FC_KSS_Ausblasen.awl
 M H5/FC_KSS_Hochdruck.awl
 M H5/FC_MMS_Aufrufe.awl
 M H5/FC_WZV_Steuerung.awl
 M H5/IDB_WZV.awl
?? export.vbs
?? split.ps1

=== Our Status Information ===
MM H5.asc
 M H5/FB_WZV.awl
 M H5/FC_KSS_Ausblasen.awl
 M H5/FC_KSS_Hochdruck.awl
 M H5/FC_MMS_Aufrufe.awl
 M H5/FC_WZV_Steuerung.awl
 M H5/IDB_WZV.awl
?? export.vbs
?? split.ps1

=== Git Config Information ===
add.interactive.usebuiltin=true
branch.develop.merge=refs/heads/develop
branch.develop.remote=origin
branch.master.merge=refs/heads/master
branch.master.remote=origin
core.autocrlf=true
core.bare=false
core.editor="C:/Tools/Sublime Text/sublime_text.exe" -w --multiinstance
core.excludesfile=C:\Users\Developer\Documents\gitignore_global.txt
core.filemode=false
core.fscache=true
core.ignorecase=true
core.logallrefupdates=true
core.repositoryformatversion=0
core.symlinks=false
credential.helper=manager
diff.astextplain.textconv=astextplain
diff.guitool=p4merge
fetch.prune=false
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
filter.lfs.smudge=git-lfs smudge -- %f
http.sslbackend=schannel
http.sslverify=false
i18n.filesencoding=Windows-1252
pull.rebase=false
rebase.autostash=false
rebase.usebuiltin=true
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.origin.url=K:\Entwicklung\Repositories\H5\PLC.git
stash.usebuiltin=true
user.email=---
user.name=---

=== Our Config Information ===
Git Config Path Information
Using config path: /C/ProgramData/Git/config
Using config path: /C/Programs/Git/mingw64/etc/gitconfig
Using config path: /C/Users/Developer/.config/git/config
Using config path: /C/Users/Developer/.gitconfig
Using config path: /D/Maschinen/H5/0000_Grundprojekt/PLC/Quellen/.git/config

Our config output is different to the Git config output
add.interactive.usebuiltin=true
branch.develop.merge=refs/heads/develop
branch.develop.remote=origin
branch.master.merge=refs/heads/master
branch.master.remote=origin
color.branch=auto
color.diff=auto
color.interactive=true
color.status=auto
core.autocrlf=true
core.bare=false
core.editor="C:/Tools/Sublime Text/sublime_text.exe" -w --multiinstance
core.excludesfile=C:\Users\Developer\Documents\gitignore_global.txt
core.filemode=false
core.fscache=true
core.ignorecase=true
core.logallrefupdates=true
core.repositoryformatversion=0
core.symlinks=false
credential.helper=manager
diff.astextplain.textconv=astextplain
fetch.prune=false
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.process=git-lfs filter-process --skip
filter.lfs.required=true
filter.lfs.smudge=git-lfs smudge --skip -- %f
help.format=html
http.sslbackend=schannel
http.sslverify=false
i18n.filesencoding=Windows-1252
pull.rebase=false
rebase.autosquash=true
rebase.autostash=false
rebase.usebuiltin=true
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.origin.url=K:\Entwicklung\Repositories\H5\PLC.git
stash.usebuiltin=true
user.email=---
user.name=---

=== Git Attributes Information ===
git check_attr --all output
H5.asc
H5/FB_WZV.awl
H5/FC_KSS_Ausblasen.awl
H5/FC_KSS_Hochdruck.awl
H5/FC_MMS_Aufrufe.awl
H5/FC_WZV_Steuerung.awl
H5/IDB_WZV.awl

=== Our Modified Files Newline Normalisation and EOL Information ===
H5.asc: autocrlf - crlf
H5/FB_WZV.awl: autocrlf - crlf
H5/FC_KSS_Ausblasen.awl: autocrlf - crlf
H5/FC_KSS_Hochdruck.awl: autocrlf - crlf
H5/FC_MMS_Aufrufe.awl: autocrlf - crlf
H5/FC_WZV_Steuerung.awl: autocrlf - crlf
H5/IDB_WZV.awl: autocrlf - crlf
BenjaminSchaaf commented 4 years ago

From my research it doesn't seem like i18n.filesencoding is a standard git setting. The gui.encoding config or the encoding attribute are used to tell git gui applications which encoding to use. The Hunk staging not working is definitely a bug though, thanks for finding that.

deathaxe commented 4 years ago

Honestly, didn't investigate that in detail. Git for Windows and GitExtensions are installed on my box. Maybe the latter one added it to the config.

deathaxe commented 4 years ago

Fixed in SM 2009