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:

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks a lot! I have found about 7 input parameters, but nothing about Output. Maybe I wasn't attentive.
@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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.