Git: Abort mergetool if not configured

When merge.tool is not configured, mergetool is not started, and the
following message is displayed:

This message is displayed because 'merge.tool' is not configured.
See 'git mergetool --tool-help' or 'git help config' for more details.
'git mergetool' will now attempt to use one of the following tools:
opendiff kdiff3 tkdiff xxdiff meld tortoisemerge gvimdiff diffuse diffmerge
ecmerge p4merge araxis bc codecompare emerge vimdiff
Merging:
test.cpp

Normal merge conflict for 'test.cpp':
  {local}: modified file
  {remote}: modified file
Hit return to start merge resolution tool (vimdiff):

On Windows, vimdiff is the default, and since it is textual, if we use it,
we have no way to pass any input for it, then we reach a dead-end.

On Linux/KDE (if DISPLAY is set), Git defaults to kdiff3. This is better,
but we cannot count on it even being installed.

Just abort with a warning on this case, and let the user [install and]
configure the preferred (graphical) mergetool.

Change-Id: I7144d9348a4d1ee03176b71b4ac2242b16795403
Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
Orgad Shaneh
2018-06-17 15:24:30 +03:00
committed by Orgad Shaneh
parent 3bbe535b95
commit aae153db1b

View File

@@ -235,6 +235,13 @@ void MergeTool::readData()
prompt(tr("Unchanged File"), tr("Was the merge successful?")); prompt(tr("Unchanged File"), tr("Was the merge successful?"));
} else if (m_line.startsWith("Continue merging")) { } else if (m_line.startsWith("Continue merging")) {
prompt(tr("Continue Merging"), tr("Continue merging other unresolved paths?")); prompt(tr("Continue Merging"), tr("Continue merging other unresolved paths?"));
} else if (m_line.startsWith("Hit return")) {
QMessageBox::warning(
Core::ICore::dialogParent(), tr("Merge Tool"),
tr("<html><body><p>Merge tool is not configured.</p>\n"
"<p>Run git config --global merge.tool &lt;tool&gt; to configure it, "
"then try again</p></body></html>"));
m_process->kill();
} else if (m_line.endsWith('\n')) { } else if (m_line.endsWith('\n')) {
// Skip unidentified lines // Skip unidentified lines
m_line.clear(); m_line.clear();