Bug 552840 - Teach JGit to handle external difftools defined in .gitattributes
Summary: Teach JGit to handle external difftools defined in .gitattributes
Status: RESOLVED FIXED
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: 5.6   Edit
Hardware: PC All
: P3 enhancement (vote)
Target Milestone: 6.2   Edit
Assignee: Andrey Loskutov CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 356832
Blocks: 552338 552838
  Show dependency tree
 
Reported: 2019-11-08 08:50 EST by Mykola Zakharchuk CLA
Modified: 2022-06-02 05:24 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mykola Zakharchuk CLA 2019-11-08 08:50:18 EST
JGit needs to be capable to work with difftools defined in .gitattributes.
Comment 1 Eclipse Genie CLA 2019-12-05 10:31:05 EST
New Gerrit change created: https://git.eclipse.org/r/153906
Comment 2 Andrey Loskutov CLA 2020-01-10 07:21:49 EST
(In reply to Mykola Zakharchuk from comment #0)
> JGit needs to be capable to work with difftools defined in .gitattributes.

See bug 552838 comment 1 for a longer explanation & UI prototype that needs this change in JGit.
Comment 3 Andre Bossert CLA 2020-01-13 08:01:06 EST
That is a very needed feature! Do you know if it's supported as "difftool" in .gitaatributes in native C-Git? I cannot find any documentation about it...
Comment 4 Andrey Loskutov CLA 2020-01-13 09:38:35 EST
(In reply to Andre Bossert from comment #3)
> Do you know if it's supported as "difftool"
> in .gitaatributes in native C-Git? I cannot find any documentation about
> it...

I think we've invented the "git attributes" part because we didn't found anything existing in this area that would match.

Note: https://git-scm.com/docs/gitattributes has following section:

--------------
Defining an external diff driver
The definition of a diff driver is done in gitconfig, not gitattributes file, so strictly speaking this manual page is a wrong place to talk about it. However…​

To define an external diff driver jcdiff, add a section to your $GIT_DIR/config file (or $HOME/.gitconfig file) like this:

[diff "jcdiff"]
	command = j-c-diff
When Git needs to show you a diff for the path with diff attribute set to jcdiff, it calls the command you specified with the above configuration, i.e. j-c-diff, with 7 parameters, just like GIT_EXTERNAL_DIFF program is called. See git[1] for details.
--------------

This is completely different to what do *we* need.

We don't want the tool to *modify* the diff output, we want *another* tool to be used during diff/merge on top of *unmodified* diff output.

There were also existing tool definitions in gitconfig (https://git-scm.com/docs/git-difftool & https://git-scm.com/docs/git-mergetool), so all what we "invented" was to combine existing definitions of difftool / mergetool from gitconfig with generic possibility to specify any custom git attributes.

So we came in with the following example

----- .gitconfig --------
[difftool "customTool"]
   cmd = /home/user/diff_tool.sh - $LOCAL - - $REMOTE
-------------------------

----- .gitattributes --------
attributes:
 *.txt 		difftool=customTool
-----------------------------
Comment 5 Andre Bossert CLA 2020-01-13 10:53:07 EST
OK, i understand, we need the same feature :) I know all this "diff" and "merge" driver stuff. We define own merge drivers for rhapsody in .gitattributes and they are used during merge. Buf for difftool usage we need script that decides what difftool should be used during "git difftool". May be it can be added to C-Git too...
Comment 6 Eclipse Genie CLA 2020-07-28 11:19:13 EDT
New Gerrit change created: https://git.eclipse.org/r/c/jgit/jgit/+/166943