forked from qt-creator/qt-creator
Git: Introduce StashGuard
Offers the user to stash changes (if relevant), stores the results and pops the stash when it goes out of scope (unless disabled) Change-Id: Ibc0d2a5d3e3c953062fb17ecba903ca814524837 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -443,18 +443,11 @@ void BranchModel::checkoutBranch(const QModelIndex &idx)
|
||||
if (branch.isEmpty())
|
||||
return;
|
||||
|
||||
GitClient::StashGuard stashGuard(m_workingDirectory, QLatin1String("Branch-Checkout"));
|
||||
if (stashGuard.stashingFailed(false))
|
||||
return;
|
||||
stashGuard.preventPop();
|
||||
QString errorMessage;
|
||||
switch (m_client->ensureStash(m_workingDirectory, QLatin1String("Branch-Checkout"), true, 0, &errorMessage)) {
|
||||
case GitClient::StashUnchanged:
|
||||
case GitClient::Stashed:
|
||||
case GitClient::NotStashed:
|
||||
break;
|
||||
case GitClient::StashCanceled:
|
||||
return;
|
||||
case GitClient::StashFailed:
|
||||
VcsBase::VcsBaseOutputWindow::instance()->appendError(errorMessage);
|
||||
return;
|
||||
}
|
||||
if (m_client->synchronousCheckoutBranch(m_workingDirectory, branch, &errorMessage)) {
|
||||
if (errorMessage.isEmpty()) {
|
||||
QModelIndex currentIdx = currentBranch();
|
||||
|
||||
Reference in New Issue
Block a user