From 647c65c96e91d79202f3261b818559389baf5de8 Mon Sep 17 00:00:00 2001
From: Orgad Shaneh <orgad.shaneh@audiocodes.com>
Date: Tue, 5 Nov 2013 20:47:10 +0200
Subject: [PATCH] Git: Suggest mergetool on stash restore conflicts

Removed warning popup, but stderr is still visible in Version Control pane

Change-Id: I6f5779f0382b8ead1e7140eb6ad533ea0c91dcc2
Reviewed-by: Petar Perisin <petar.perisin@gmail.com>
---
 src/plugins/git/gitclient.cpp   | 16 ++--------------
 src/plugins/git/gitclient.h     |  3 +--
 src/plugins/git/stashdialog.cpp | 18 +++++++-----------
 3 files changed, 10 insertions(+), 27 deletions(-)

diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp
index ac047f0ac76..dfc9e7af165 100644
--- a/src/plugins/git/gitclient.cpp
+++ b/src/plugins/git/gitclient.cpp
@@ -3529,26 +3529,14 @@ void GitClient::stashPop(const QString &workingDirectory)
 bool GitClient::synchronousStashRestore(const QString &workingDirectory,
                                         const QString &stash,
                                         bool pop,
-                                        const QString &branch /* = QString()*/,
-                                        QString *errorMessage)
+                                        const QString &branch /* = QString()*/)
 {
     QStringList arguments(QLatin1String("stash"));
     if (branch.isEmpty())
         arguments << QLatin1String(pop ? "pop" : "apply") << stash;
     else
         arguments << QLatin1String("branch") << branch << stash;
-    QByteArray outputText;
-    QByteArray errorText;
-    const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText,
-                                        VcsBasePlugin::ExpectRepoChanges);
-    if (rc) {
-        const QString output = commandOutputFromLocal8Bit(outputText);
-        if (!output.isEmpty())
-            outputWindow()->append(output);
-    } else {
-        msgCannotRun(arguments, workingDirectory, errorText, errorMessage);
-    }
-    return rc;
+    return executeAndHandleConflicts(workingDirectory, arguments);
 }
 
 bool GitClient::synchronousStashRemove(const QString &workingDirectory,
diff --git a/src/plugins/git/gitclient.h b/src/plugins/git/gitclient.h
index f21a1486728..69709b90306 100644
--- a/src/plugins/git/gitclient.h
+++ b/src/plugins/git/gitclient.h
@@ -197,8 +197,7 @@ public:
     bool synchronousStashRestore(const QString &workingDirectory,
                                  const QString &stash,
                                  bool pop = false,
-                                 const QString &branch = QString(),
-                                 QString *errorMessage = 0);
+                                 const QString &branch = QString());
     bool synchronousStashRemove(const QString &workingDirectory,
                                 const QString &stash = QString(),
                                 QString *errorMessage = 0);
diff --git a/src/plugins/git/stashdialog.cpp b/src/plugins/git/stashdialog.cpp
index fecdedddd85..153173e4b30 100644
--- a/src/plugins/git/stashdialog.cpp
+++ b/src/plugins/git/stashdialog.cpp
@@ -323,12 +323,10 @@ void StashDialog::restoreCurrent()
     QString name = m_model->at(index).name;
     // Make sure repository is not modified, restore. The command will
     // output to window on success.
-    const bool success = promptForRestore(&name, 0, &errorMessage)
-                         && gitClient()->synchronousStashRestore(m_repository, name, false, QString(), &errorMessage);
-    if (success) {
+    if (promptForRestore(&name, 0, &errorMessage)
+            && gitClient()->synchronousStashRestore(m_repository, name)) {
         refresh(m_repository, true); // Might have stashed away local changes.
-    } else {
-        if (!errorMessage.isEmpty())
+    } else if (!errorMessage.isEmpty()) {
         warning(msgRestoreFailedTitle(name), errorMessage);
     }
 }
@@ -340,13 +338,11 @@ void StashDialog::restoreCurrentInBranch()
     QString errorMessage;
     QString branch;
     QString name = m_model->at(index).name;
-    const bool success = promptForRestore(&name, &branch, &errorMessage)
-                         && gitClient()->synchronousStashRestore(m_repository, name, false, branch, &errorMessage);
-    if (success) {
+    if (promptForRestore(&name, &branch, &errorMessage)
+            && gitClient()->synchronousStashRestore(m_repository, name, false, branch)) {
         refresh(m_repository, true); // git deletes the stash, unfortunately.
-    } else {
-        if (!errorMessage.isEmpty())
-            warning(msgRestoreFailedTitle(name), errorMessage);
+    } else if (!errorMessage.isEmpty()) {
+        warning(msgRestoreFailedTitle(name), errorMessage);
     }
 }
 
-- 
GitLab