-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Feature description
This is related to #11464, the word-diff part is probably dependent on that change that requires support for ansi escapes for terminal colors.
However, the discussion on what type of improvement that is reasonable is separate.
--
Git Extensions has a basic algorithm to show changed blocks of changes in a patch.
https://github.com/gitextensions/gitextensions/blob/master/GitUI/Editor/Diff/DiffHighlightService.cs#L105
This is useful, but if there are more changes on a line it is insufficient
git-diff do not show word diff by default, only patches with added/deleted lines.
It is however possible ro enable word-diff, similar to to GH.
https://git-scm.com/docs/git-diff#Documentation/git-diff.txt-color
However, the changes is no longer presented as a patch
git-diff word-diff also has a "porcelain" format, but that is not possible to use to recreate a patch format.
The reason is that added/removed empty lines is not marked and that initial whitespace on new/deleted lines are presented as context. (You can guess with a high probability.)
This example can be presented correctly
(This is how I want to present the changes, you see changes very quickly).
Other tools have tried to overcome the Git word-diff limitation.
The diff-highlight script is in the Git repo and post process the output (some more than GE built in).
This includes https://github.com/so-fancy/diff-so-fancy (adding to diff-highlight)
Some examples in Delta
https://dandavison.github.io/delta/comparisons-with-other-tools.html
GitHub has an improved algorithm that show changes word by word::
--
Several ways forward to improve the GE diff:
- Fix the empty line and whitespace issue in the porcelain output. (will probably be a porcelain v2). Not so simple: https://github.com/git/git/blob/master/diff.c#L1947
- Add a --word-diff=patch to Git - also not easy.
- Improve the GE algorithm from the other open sourced implementations. delta - see architecture in https://github.com/dandavison/delta/blob/main/ARCHITECTURE.md
If patch format is not changed, other diff presentations could be provided even if they are not presented as patches, so you can toggle the presentation
- --diff-word=color as above similar to the concept in Highlight with Git diff implementation - highlight moved code #11464 (using syntax highlighting, should be a separate shortcut and context menu).
- Allow including a filter in GE to filter the output in for instance delta.
Environment
- Git Extensions 33.33.33
- Build 2555afe6d7461476cb01320cca0023231e4f28cb
- Git 2.43.0.windows.1
- Microsoft Windows NT 10.0.19045.0
- .NET 8.0.1
- DPI 96dpi (no scaling)
- Portable: False
- Microsoft.WindowsDesktop.App Versions
Microsoft.WindowsDesktop.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.0-rc.2.23479.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]