How could I force mergetool GUI (KDiff3) to be always shown?

Ondrej Peterka picture Ondrej Peterka · Mar 10, 2013 · Viewed 14.3k times · Source

How could I force the mergetool GUI to be always shown and disable any automatic resolving?

Sometimes when there is a conflict during a merge and I use the mergetool, it simply immediately returns after I hit Enter on question "Hit return to start merge resolution tool (kdiff3)" and no GUI is shown and the conflict appears to be resolved.

I have Git configured to use KDiff3 as the mergetool now, but it happened also when I have codecompare as the mergetool specified. I know that there is an option "Auto save and quit on merge without conflicts" in KDiff3, which could theoretically cause the described behaviour, but I have this option disabled/unchecked all the time.

Also, there is the trustExitCode option directly in Git mergetool gitconfig, which I have set to true, but even if I set it to false, the GUI is not shown.

I am not sure who does the auto resolving anyway. Mergetool in some preprocessing or KDiff3?

I am running on Windows and have the Git-extensions installed.

Similar question specific to KDiff3, was asked also here: Kdiff3 won't open with mergetool command

Answer

PiQuer picture PiQuer · Apr 4, 2013

Git has --auto hard coded as a command-line option to KDiff3, which causes the GUI not to show up if all conflicts are auto-resolvable by KDiff3. In the KDiff3 settings you can specify command line options to ignore, but putting --auto there did not work for me.

As a workaround I configured my own variant of KDiff3 as the merge tool:

git config --global mergetool.kdiff3NoAuto.cmd "kdiff3 --L1 \"\$MERGED (Base)\" --L2 \"\$MERGED (Local)\" --L3 \"\$MERGED (Remote)\" -o \"\$MERGED\" \"\$BASE\" \"\$LOCAL\" \"\$REMOTE\""

This is very similar to what Git uses by default for KDiff3, but without the --auto flag.

Now you can call git mergetool -t kdiff3NoAuto or configure kdiff3NoAuto as mergetool globally and KDiff3 will always show up when resolving conflicts.

Regarding the second part of your question, if you really want to disable any automatic resolving, just add --qall to the kdiff3 command line above. But then you have to manually resolve all changes in the file manually, even the ones that did not result in a Git conflict. The best scenario would be: KDiff3 shows how Git merged the files and leaves the conflicts open for the user to choose.