سؤال

Is it possible to set a custom tool for merging files with a specific extension in Git?

Thanks for any pointers!

Update

I wasn't able to come up with any better solution than defining a custom difftool and calling it by hand as @jarodeells suggested:

[diff]
    tool = mydiff
[difftool "mydiff"]
    cmd="script.sh \"$LOCAL\" \"$REMOTE\""

Then calling it explicitly:

$ git difftool -t mydiff someFileWith.ext
هل كانت مفيدة؟

المحلول

If not already supported, install a shell script that keys off the extension and calls the correct merge tool.

نصائح أخرى

Update: See @Ackdari comments below. The external tool doesn't have to be command-line based. I'm not sure how git uses binary = True when an external tool is used, but I suspect it might be needed for all flows to work.

If your external diff tool* is command-line only (no GUI), You can use the built-in gitattributes for this:

in .gitconfig add:

[diff "my_diff"]
    command = Tools/csv_diff
    binary = true # Not sure this is required.

and in .gitattributes (either global or per repository, see here) add:

*.csv diff=my_diff

[*] The command for the external diff tool will be called by git with the 7 parameters detailed under GIT_EXTERNAL_DIFF in the manual here.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top