Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 798
Ondrej Peterka Avatar asked Mar 10 '13 10:03

Ondrej Peterka


People also ask

What is ABC in kdiff3?

A refers to the version your merge target is based on. If you Merge from branch to trunk, 'A' will be the previous trunk version. B is what you currently have in your local trunk folder, including local changes. C is the Version you wanna merge on top of B.

What is Mergetool?

DESCRIPTION. Use git mergetool to run one of several merge utilities to resolve merge conflicts. It is typically run after git merge. If one or more <file> parameters are given, the merge tool program will be run to resolve differences on each file (skipping those without conflicts).


2 Answers

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.

like image 97
PiQuer Avatar answered Sep 19 '22 12:09

PiQuer


Bob esponja's comment to the accepted answer worked perfectly for me using KDiff3 0.9.98.

Add --auto to Command line options to ignore: under

Settings | Configure KDiff3... | Integration tab. 

KDiff3 comes up with the Conflicts dialog indicating Nr of unsolved conflicts: 0, but then you have can inspect/modify the merged state as needed.

A bit more convenient than configuring your own variant as it will work as intended whether from git mergetool, Source Tree or whatever tool engages mergetool.

like image 36
jamezzz Avatar answered Sep 22 '22 12:09

jamezzz