2

I want to use an alternative diff algorithm for special file extension, e.g. ".java" and the standart diff algorithm for other files.

I can make it via .gitattributes file:

*.java diff=javadiffprogramm

and .gitconfig file:

[diff "javadiffprogramm"]
    command = pathToDiffProgram.

My question is what is the format of input parameters of "javadiffprogramm" and where it should output the result of diff? The result of diff has the format like "@@ -1,7 +1,6 @@...".

Some questions on this topic:

NAlmaz
  • 45
  • 4

1 Answers1

2

This is documented in the git man page as GIT_EXTERNAL_DIFF.

GIT_EXTERNAL_DIFF

When the environment variable GIT_EXTERNAL_DIFF is set, the program named by it is called, instead of the diff invocation described above. For a path that is added, removed, or modified, GIT_EXTERNAL_DIFF is called with 7 parameters:

path old-file old-hex old-mode new-file new-hex new-mode

The docs go on to explain what those parameters are.

Output should be to STDOUT.

Community
  • 1
  • 1
Schwern
  • 153,029
  • 25
  • 195
  • 336
  • Thanks a lot! I have found about 7 input parameters, but nothing about Output. Maybe I wasn't attentive. – NAlmaz Feb 24 '16 at 16:50
  • @NAlmaz I couldn't find information about output either. It's an educated guess based on how Unix tools generally work. If Git wants the output written elsewhere it can redirect it itself. – Schwern Feb 24 '16 at 17:13