From 771fe03cfeda0b8514556ca29889fb35116a41c5 Mon Sep 17 00:00:00 2001
From: Petar Perisin <petar.perisin@gmail.com>
Date: Thu, 11 Jul 2013 22:53:38 +0200
Subject: [PATCH] Git - couple fixes in branch based auto stash

- do not start stash scope when creating auto stash
- return if reset fails

Change-Id: I471abc1d430351192c46ac78041949ba81f11b09
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
---
 src/plugins/git/branchdialog.cpp | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/plugins/git/branchdialog.cpp b/src/plugins/git/branchdialog.cpp
index 8fc07d8e0de..11459f3a31e 100644
--- a/src/plugins/git/branchdialog.cpp
+++ b/src/plugins/git/branchdialog.cpp
@@ -192,15 +192,17 @@ void BranchDialog::checkout()
         m_model->checkoutBranch(idx);
     } else if (branchCheckoutDialog.exec() == QDialog::Accepted && m_model) {
 
-        QString stashMessage;
-        if (branchCheckoutDialog.makeStashOfCurrentBranch()
-                || branchCheckoutDialog.moveLocalChangesToNextBranch()) {
-
-            if (!gitClient->beginStashScope(m_repository, currentBranch + QLatin1String("-AutoStash"), NoPrompt))
+        if (branchCheckoutDialog.makeStashOfCurrentBranch()) {
+            if (!gitClient->executeSynchronousStash(m_repository,
+                            currentBranch + QLatin1String("-AutoStash"))) {
+                return;
+            }
+        } else if (branchCheckoutDialog.moveLocalChangesToNextBranch()) {
+            if (!gitClient->beginStashScope(m_repository, QLatin1String("Checkout"), NoPrompt))
                 return;
-            stashMessage = gitClient->stashInfo(m_repository).stashMessage();
         } else if (branchCheckoutDialog.discardLocalChanges()) {
-            gitClient->synchronousReset(m_repository);
+            if (!gitClient->synchronousReset(m_repository))
+                return;
         }
 
         m_model->checkoutBranch(idx);
@@ -214,7 +216,7 @@ void BranchDialog::checkout()
             }
         }
 
-        if (!stashMessage.isEmpty() && branchCheckoutDialog.moveLocalChangesToNextBranch())
+        if (branchCheckoutDialog.moveLocalChangesToNextBranch())
             gitClient->endStashScope(m_repository);
         else if (branchCheckoutDialog.popStashOfNextBranch())
             gitClient->synchronousStashRestore(m_repository, stashName, true);
-- 
GitLab