Re: Choosing a mergetool according to file type

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: Choosing a mergetool according to file type

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:46:59

Matthieu Moy [off-list ref] writes:
Gregory Jefferis [off-list ref] writes:
quoted
This defines the merge driver but not the mergetool.  A mergetool is
presumably an interactive tool that helps you clean up failed automatic
merges.
This is why I quoted the title of the section
quoted
quoted
       Defining a custom merge driver
Just tried it with 

[merge "filfre"]
       name = feel-free merge driver
       driver = gedit %O %A %B
       recursive = binary

It did launch gedit interactively during the merge.
You are both correct.  Your example runs "gedit" with three files before
merge.  If Gregory's custom mergetool expects the failed half-merge result
as its input, this is not the interface he is looking for.

It shouldn't be hard to teach mergetool/difftool wrapper to support the
per-path tool selection by running "git check-attr".

Right now it uses "diff.tool" and "merge.tool" configuration variables.
In addition, it can arrange to consult "mergetool.$type.diff" and
"mergetool.$type.merge".  These new two variables will override the
existing ones that are now treated as type-agnostic default.

IOW, something like this.

(1) In .gitattributes, define files whose name end with js is of type
    gjefferis in the mergetool namespace:

	*.js	mergetool=gjefferis

(2) In .git/config, define that gjefferis type is handled by diff-doc.js
    and merge-doc.js

    [mergetool "gjefferis"]
	diff = diff-doc.js
        merge = merge-doc.js

(3) Enhance get_configured_merge_tool() in git-mergetool--lib.sh and
    callchain that leads to it.

    type=$(git checkattr mergetool -- $file)
    if test -n "$type"
    then
    	mergetool=$(git config mergetool.$type.merge)
        difftool=$(git config mergetool.$type.diff)
    else
        mergetool=$(git config merge.tool)
        difftool=$(git config diff.tool)
    fi

It appears that right now the function does not know what file it is
dealing with, so you may need to first restructure the callchain a bit,
but it shouldn't be too painful.

Re: Choosing a mergetool according to file type

From: Gregory Jefferis <hidden>
Date: 2016-06-15 22:46:59

On 2009-06-26 17:57, "Junio C Hamano" [off-list ref] wrote:
You are both correct.  Your example runs "gedit" with three files before
merge.  If Gregory's custom mergetool expects the failed half-merge result
as its input, this is not the interface he is looking for.
I think that Matthieu is more correct this time in that I can do what I need
with the merge driver because I don't need the failed half-merge result.
But I prefer the 2 level arrangement of 1) automatic then 2) fixing merge
conflicts manually since there will be other cases where this is required.

Thank you Junio for pointing out how to do add the necessary functionality -
a project for a rainy weekend I guess.

Best,

Greg.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help