Re: Choosing a mergetool according to file type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Matthieu Moy <Matthieu.Moy@xxxxxxx> writes:

> Gregory Jefferis <jefferis@xxxxxxxxx> writes:
>
>> 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
>
>>>        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.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]