diff --git a/src/plugins/git/branchdialog.cpp b/src/plugins/git/branchdialog.cpp index 65132e6d5aecc1e307d55bf11417b823a03168e3..dc25d9da015a0cd8e7691e0de76240ad5b56a6ba 100644 --- a/src/plugins/git/branchdialog.cpp +++ b/src/plugins/git/branchdialog.cpp @@ -207,10 +207,7 @@ void BranchDialog::checkout() if (!stashMessage.isEmpty() && branchCheckoutDialog.moveLocalChangesToNextBranch()) gitClient->stashPop(m_repository); else if (branchCheckoutDialog.popStashOfNextBranch()) - gitClient->synchronousStashRestore(m_repository, stashName); - - if (branchCheckoutDialog.hasStashForNextBranch()) - gitClient->synchronousStashRemove(m_repository, stashName); + gitClient->synchronousStashRestore(m_repository, stashName, true); } enableButtons(); } diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index 10fb74785da8668e31fba98b5e56edbce390cc68..1fb2a931a0c57e9eb31cc8d18929ea38b4e31d41 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -2282,12 +2282,13 @@ void GitClient::stashPop(const QString &workingDirectory) bool GitClient::synchronousStashRestore(const QString &workingDirectory, const QString &stash, + bool pop, const QString &branch /* = QString()*/, QString *errorMessage) { QStringList arguments(QLatin1String("stash")); if (branch.isEmpty()) - arguments << QLatin1String("apply") << stash; + arguments << QLatin1String(pop ? "pop" : "apply") << stash; else arguments << QLatin1String("branch") << branch << stash; QByteArray outputText; diff --git a/src/plugins/git/gitclient.h b/src/plugins/git/gitclient.h index 72e8c74dd5897e0ed244c1aa661113c5f6c7f691..c589da0f46a12a8afd20c52fbe15980d9228cafd 100644 --- a/src/plugins/git/gitclient.h +++ b/src/plugins/git/gitclient.h @@ -150,6 +150,7 @@ public: QString *errorMessage = 0); bool synchronousStashRestore(const QString &workingDirectory, const QString &stash, + bool pop = false, const QString &branch = QString(), QString *errorMessage = 0); bool synchronousStashRemove(const QString &workingDirectory, diff --git a/src/plugins/git/gitversioncontrol.cpp b/src/plugins/git/gitversioncontrol.cpp index 013a6c9e1d92525f72e37464d09830f766603720..752c607ba771ad04689ba4406f65b6ae7ba72351 100644 --- a/src/plugins/git/gitversioncontrol.cpp +++ b/src/plugins/git/gitversioncontrol.cpp @@ -218,7 +218,7 @@ bool GitVersionControl::vcsRestoreSnapshot(const QString &topLevel, const QStrin QString stashName; success = m_client->stashNameFromMessage(topLevel, name, &stashName) && m_client->synchronousReset(topLevel) - && m_client->synchronousStashRestore(topLevel, stashName); + && m_client->synchronousStashRestore(topLevel, stashName, true); } } while (false); return success; diff --git a/src/plugins/git/stashdialog.cpp b/src/plugins/git/stashdialog.cpp index c12d491b6083ad6c7ecc18a9fd96b5b8586f2836..a4c2d3ffdd3b1cdf1749917606798a2e4db73a71 100644 --- a/src/plugins/git/stashdialog.cpp +++ b/src/plugins/git/stashdialog.cpp @@ -338,7 +338,7 @@ void StashDialog::restoreCurrent() // 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, QString(), &errorMessage); + && gitClient()->synchronousStashRestore(m_repository, name, false, QString(), &errorMessage); if (success) { refresh(m_repository, true); // Might have stashed away local changes. } else { @@ -355,7 +355,7 @@ void StashDialog::restoreCurrentInBranch() QString branch; QString name = m_model->at(index).name; const bool success = promptForRestore(&name, &branch, &errorMessage) - && gitClient()->synchronousStashRestore(m_repository, name, branch, &errorMessage); + && gitClient()->synchronousStashRestore(m_repository, name, false, branch, &errorMessage); if (success) { refresh(m_repository, true); // git deletes the stash, unfortunately. } else {