From 573958e79f1033f502690c5ca2821c8c95f8414b Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Thu, 23 Jun 2016 21:52:00 +0300 Subject: [PATCH] Git: Prompt for unchanged file after custom mergetool fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To reproduce, create a conflict and configure a custom mergetool that does nothing: git config mergetool.my.cmd true git config merge.tool my Then execute merge tool from Qt Creator. The merge tool process hangs while asking how to handle the unchanged file, and can only be killed externally. Change-Id: I4d2a91061bd7549e308f6a25f106e6a7afc5cadb Reviewed-by: André Hartmann --- src/plugins/git/mergetool.cpp | 24 +++++++++++++++--------- src/plugins/git/mergetool.h | 1 + 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/plugins/git/mergetool.cpp b/src/plugins/git/mergetool.cpp index a0a8de0fed1..d62aabfd92c 100644 --- a/src/plugins/git/mergetool.cpp +++ b/src/plugins/git/mergetool.cpp @@ -218,6 +218,18 @@ void MergeTool::addButton(QMessageBox *msgBox, const QString &text, char key) msgBox->addButton(text, QMessageBox::AcceptRole)->setProperty("key", key); } +void MergeTool::prompt(const QString &title, const QString &question) +{ + if (QMessageBox::question(Core::ICore::dialogParent(), title, question, + QMessageBox::Yes | QMessageBox::No, + QMessageBox::No) == QMessageBox::Yes) { + m_process->write("y\n"); + } else { + m_process->write("n\n"); + } + m_process->waitForBytesWritten(); +} + void MergeTool::readData() { while (m_process->bytesAvailable()) { @@ -231,16 +243,10 @@ void MergeTool::readData() m_localState = waitAndReadStatus(m_localInfo); m_remoteState = waitAndReadStatus(m_remoteInfo); chooseAction(); + } else if (line.startsWith("Was the merge successful")) { + prompt(tr("Unchanged File"), tr("Was the merge successful?")); } else if (line.startsWith("Continue merging")) { - if (QMessageBox::question(Core::ICore::dialogParent(), tr("Continue Merging"), - tr("Continue merging other unresolved paths?"), - QMessageBox::Yes | QMessageBox::No, - QMessageBox::No) == QMessageBox::Yes) { - m_process->write("y\n"); - } else { - m_process->write("n\n"); - } - m_process->waitForBytesWritten(); + prompt(tr("Continue Merging"), tr("Continue merging other unresolved paths?")); } } } diff --git a/src/plugins/git/mergetool.h b/src/plugins/git/mergetool.h index cb776e7627e..3acdd83adbc 100644 --- a/src/plugins/git/mergetool.h +++ b/src/plugins/git/mergetool.h @@ -64,6 +64,7 @@ public: }; private: + void prompt(const QString &title, const QString &question); void readData(); void done();