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

Is it possible to integrate Difftastic #11618

Open
Gyokur0 opened this issue Mar 6, 2024 · 11 comments
Open

Is it possible to integrate Difftastic #11618

Gyokur0 opened this issue Mar 6, 2024 · 11 comments

Comments

@Gyokur0
Copy link

Gyokur0 commented Mar 6, 2024

Feature description

I'm not sure if this is a feature request or a bug.
I use the Open Source tool Difftastic and have the executable (difft.exe) in a location covered by my PATH variable, so I can call it anywhere by the executable name (difft).

If I now set in my gitconfig the following:
[diff]
external = difft

The diff area in gitextensions is now completely empty (in the branch view and the commit area)

I have no idea how the diff ui is implemented in gitextensions and if such a integration is even possible. Apparently you pick up the setting otherwise the window would not be empty if I set it.

Environment

  • GitExtensions version: 4.2.1
  • GIT version: 2.44
  • OS version: Windows
  • .NET version: -
@gerhardol
Copy link
Member

Short answer: No
GE parses git-diff output to determine filenames, what lines that are changed and to apply coloring, so difftastic filter will cause this parsing to fail.

However, #11590 enables use of git diff coloring instead of the GE "engine". That is still in "patch" format.
As a second step in the PR, it enables git-word-diff format that is only partially in "patch" format as an alternative view. It is for instance not possible to stage changes in the diff, line numbers are "approximate".

It could maybe be possible to display difftastic/delta/diff-so-fancy as a "display only" alternative view too. For instance line numbers in GE will likely be missing.

@Gyokur0
Copy link
Author

Gyokur0 commented Mar 7, 2024

Thanks for the fast answer.
Now I know that GE needs the git-diff output.

Looking forward how #11590 works out.

A "display only" viewer would be cool, so one could switch between the GE diff and one or more "display only" viewers (perhaps via a dropdown)
The other diff views could be configured via GE or with the difftool section in gitconfig (but here mixed GUI or commandline applications could be problematic)

@TheMiles
Copy link

+1 for this feature request

1 similar comment
@GrzegorzGawlikH
Copy link

+1 for this feature request

@gerhardol
Copy link
Member

gerhardol commented Mar 25, 2024

I have played around a little with this.
It is not obvious how to do this, but first some examples
All of these requires #11628 (that has other dependencies), most changes in #11590 (that is merged)

Regardless, this will be a major hack.

--
Git coloring

image

Git word diff

image

Difftastic
Not obviously better

image

Some design/usage questions

Invocation:
I expectthat is is something you toggle with normal (patch) diff. git-word-diff is very useful when reviewing
Hotkey and diff list menuitem (second alternative could be in FileViewer too)

  • Invoke once, next selection is normal diff (similar to Blame in 4.x)
  • Sticky setting, like git-word-diff (or Blame in FileTree)
    Suggestion: Sticky, similar to git-word-diff. Menu dropdown Patch/Git-word-diff/difftastic

Configuration:
The binary can be installed in various locations and it is maybe not good to require that the binary is set.
The command must be separately configurable in Windows/WSL
difftastic in Ubuntu installed with snap requires env var to run https://snapcraft.io/install/difftastic/ubuntu (but that maybe requires a wrapper script)
One way to config this is to setup a difftool. (that would prepare for other tools to)
In addition to installing difftastic, this is not a smooth experience
The example uses the following:
[difftool "difftastic"]
cmd = /c/cygwin/home/ejgo/bin/difft.exe --background=light --color=always --context=3 --width=120 "$LOCAL" "$REMOTE"
Only Git commands are cached now so some reasons to use Git difftool
Suggestion: Use difftool, check the Git setting before enabling the toggle or allowing hotkey.

Integration:
difftastic output is not really parsable. Maybe the line numbers can be parsed to allow navigation and open-by-line (that would make the parsing difftastic specific, not generic)

Some options can be set with options or env var
difftastic has a dark/light theme, not configurable (the Git colors for the other commands can be tweaked by the user, even if the defaults should be improved). It is not impossible to replace the colors (but not safe for future changes)
The context lines can be be configured
The width is default 80 which looks weird. It could be possible to adjust to the full detected viewer width, but that could be hard to read. Hardcode a max size?
Use difftastic syntax highlighting instead of GE?
Suggestion: New CustomDiff. Maybe align with git-word-diff, maybe navigation.

@gerhardol
Copy link
Member

gerhardol commented Apr 1, 2024

A draft with integration of file numbers is in tmp/git-coloring
Tests are needed

An example with the combined side-by-side and single line presentation used:
image

image

Difftastic is not designed to have a parsable output, this is not a full implementation .
If Difftastic change output, it should still be seen in the GE viewer though (but line numbers etc may fail).

@arnonuem
Copy link

arnonuem commented Apr 3, 2024

Can we not convert this task into something like - configure custom merge and diff tool?
Because i would like to use the difftool of intellj for example like described here:
https://youtrack.jetbrains.com/issue/IDEA-198656/Release-the-diff-merge-tool-as-a-standalone-product

@gerhardol
Copy link
Member

Can we not convert this task into something like - configure custom merge and diff tool? Because i would like to use the difftool of intellj for example like described here: https://youtrack.jetbrains.com/issue/IDEA-198656/Release-the-diff-merge-tool-as-a-standalone-product

GE uses the GUI tools you have configured in setting git-config

This is about using the text output from command line tools.
And it will be possible to use any other cli tool as long as they can be configured as a difftool and you name it difftastic. But the linenumbers and info will probably not be parsed correctly, just displaying the raw output.

@pmiossec
Copy link
Member

pmiossec commented Apr 3, 2024

Can we not convert this task into something like - configure custom merge and diff tool?

It has been made like that because diffstatic is a command line tool that a custom output text and so require a specific handling.

Because i would like to use the difftool of intellj for example like described here: https://youtrack.jetbrains.com/issue/IDEA-198656/Release-the-diff-merge-tool-as-a-standalone-product

It's seems that intellij diff/merge is a graphical tool that could already be integrated as a git diff/merge tool using command line or through git extension setting panel.

You should explain a little more in details why it is not possible and what should be improved.

If it's just that the command line arguments are lacking in git extensions (it is right), it just needs to be added but is no way related to diffstatic (complex) integration.

@pmiossec
Copy link
Member

pmiossec commented Apr 3, 2024

Sorry to add: if it is the case, so it is not the right place to discuss about it and you should open another issue.

@gerhardol
Copy link
Member

An update pushed to tmp/git-coloring. There are some parsing issues, Difftastic is not intended to be used this way. But the output is quite useful.
A PR will depend on #11673 and tests too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants