sublimehq / sublime_merge

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

Diff not match git output #1929

Open hyrious opened 2 weeks ago

hyrious commented 2 weeks ago

Version info

Description

The diff view seems not matching git itself. See the commit diff from github: https://github.com/hyrious/typst-syntax-highlight/commit/daee996baf44b0bc3a8a05aa24e2c9472703563e.diff and the screenshot:

image

Hint: the { and } lines are chosen differently.

I have tried using every git algorithm in comparing with the settings in Sublime Merge, using system git or bundled git. However it seems there's no way to let Sublime Merge render the same as git.

Steps to reproduce

You can test it on a new git repository, by committing the file's 2 versions:

// version 1
[
    {
        "foo": 1
    },
    {
        "end": 0
    }
]
// version 2
[
    {
        "foo": 1
    },
    {
        "bar": 2
    },
    {
        "end": 0
    }
]

Then try to print the commit diff with git diff HEAD~1, and compare the output with Sublime Merge.

image

Expected behavior

The diff output should match git.

Debug Information

=== App Version Information ===
Build: 2096

=== Git Version Information ===
Using Git: C:\Program Files\Git\cmd\git.exe (system)
git version 2.45.1.windows.1
PATH: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Program Files\Sublime Text\;C:\Program Files\Sublime Merge;C:\Program Files\dotnet\;C:\Users\hyrious\Appdata\Local\Ruby\bin;C:\Users\hyrious\scoop\apps\mpv\current;C:\Users\hyrious\scoop\shims;C:\Users\hyrious\AppData\Local\Microsoft\WindowsApps;C:\Users\hyrious\AppData\Roaming\npm;C:\Users\hyrious\AppData\Local\Programs\Microsoft VS Code\bin

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

=== Git Status Information ===

=== Our Status Information ===

=== Git Config Information ===
alias.commend=commit --amend --no-edit
alias.it=!git init && git commit -m root --allow-empty
alias.l=!git log --graph --abbrev-commit --decorate --all --format=format:"%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(dim white) - %an%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n %C(white)%s%C(reset)"
alias.please=push --force-with-lease
alias.st=status --short --branch
alias.wip=!git add -A && git commit --no-verify -m "--wip-- [skip ci]"
branch.autosetuprebase=always
core.autocrlf=true
core.bare=false
core.editor="C:\\Program Files\\Sublime Text\\subl.exe" -w
core.filemode=false
core.fscache=true
core.ignorecase=true
core.logallrefupdates=true
core.repositoryformatversion=0
core.symlinks=false
credential.helper=cache --timeout=604800
credential.https://dev.azure.com.usehttppath=true
credential.https://gist.github.com.helper=!'C:\Users\hyrious\scoop\apps\gh\current\bin\gh.exe' auth git-credential
credential.https://github.com.helper=!'C:\Users\hyrious\scoop\apps\gh\current\bin\gh.exe' auth git-credential
diff.astextplain.textconv=astextplain
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
help.format=html
http.sslbackend=openssl
http.sslcainfo=C:/Program Files/Git/mingw64/etc/ssl/certs/ca-bundle.crt
init.defaultbranch=main
pager.status=true
pull.ff=only
user.email=hyrious@outlook.com
user.name=hyrious

=== Our Config Information ===
Git Config Path Information
Using config path: /C/ProgramData/Git/config
Using config path: /C/Program Files/Git/etc/gitconfig
Using config path: /C/Users/hyrious/.config/git/config
Using config path: /C/Users/hyrious/.gitconfig
Using config path: /C/Users/hyrious/Documents/Aqua/aaa/.git/config

Our config output is identical to the Git config output

=== Git Attributes Information ===
git check_attr --all output

=== Our Modified Files Newline Normalisation and EOL Information ===

=== Our Modified Files Flag Information ===
Ignoring symlinks: 1
themilkman commented 2 weeks ago

I did notice the same behavior in the past (and can reproduce your example). I find this interesting in ST (safe-mode), too:

Before saving the file, image => ST internal change detection? before_save After saving => the Sublime git impl? after_save