forked from qt-creator/qt-creator
Git: Use stash pop instead of apply...
... when the stash should be removed on successful pop Change-Id: I39b2c01b0a518d3c70bcb8dc898191cca6d3e84d Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
53443616e5
commit
daef1fbb88
@@ -207,10 +207,7 @@ void BranchDialog::checkout()
|
|||||||
if (!stashMessage.isEmpty() && branchCheckoutDialog.moveLocalChangesToNextBranch())
|
if (!stashMessage.isEmpty() && branchCheckoutDialog.moveLocalChangesToNextBranch())
|
||||||
gitClient->stashPop(m_repository);
|
gitClient->stashPop(m_repository);
|
||||||
else if (branchCheckoutDialog.popStashOfNextBranch())
|
else if (branchCheckoutDialog.popStashOfNextBranch())
|
||||||
gitClient->synchronousStashRestore(m_repository, stashName);
|
gitClient->synchronousStashRestore(m_repository, stashName, true);
|
||||||
|
|
||||||
if (branchCheckoutDialog.hasStashForNextBranch())
|
|
||||||
gitClient->synchronousStashRemove(m_repository, stashName);
|
|
||||||
}
|
}
|
||||||
enableButtons();
|
enableButtons();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2282,12 +2282,13 @@ void GitClient::stashPop(const QString &workingDirectory)
|
|||||||
|
|
||||||
bool GitClient::synchronousStashRestore(const QString &workingDirectory,
|
bool GitClient::synchronousStashRestore(const QString &workingDirectory,
|
||||||
const QString &stash,
|
const QString &stash,
|
||||||
|
bool pop,
|
||||||
const QString &branch /* = QString()*/,
|
const QString &branch /* = QString()*/,
|
||||||
QString *errorMessage)
|
QString *errorMessage)
|
||||||
{
|
{
|
||||||
QStringList arguments(QLatin1String("stash"));
|
QStringList arguments(QLatin1String("stash"));
|
||||||
if (branch.isEmpty())
|
if (branch.isEmpty())
|
||||||
arguments << QLatin1String("apply") << stash;
|
arguments << QLatin1String(pop ? "pop" : "apply") << stash;
|
||||||
else
|
else
|
||||||
arguments << QLatin1String("branch") << branch << stash;
|
arguments << QLatin1String("branch") << branch << stash;
|
||||||
QByteArray outputText;
|
QByteArray outputText;
|
||||||
|
|||||||
@@ -150,6 +150,7 @@ public:
|
|||||||
QString *errorMessage = 0);
|
QString *errorMessage = 0);
|
||||||
bool synchronousStashRestore(const QString &workingDirectory,
|
bool synchronousStashRestore(const QString &workingDirectory,
|
||||||
const QString &stash,
|
const QString &stash,
|
||||||
|
bool pop = false,
|
||||||
const QString &branch = QString(),
|
const QString &branch = QString(),
|
||||||
QString *errorMessage = 0);
|
QString *errorMessage = 0);
|
||||||
bool synchronousStashRemove(const QString &workingDirectory,
|
bool synchronousStashRemove(const QString &workingDirectory,
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ bool GitVersionControl::vcsRestoreSnapshot(const QString &topLevel, const QStrin
|
|||||||
QString stashName;
|
QString stashName;
|
||||||
success = m_client->stashNameFromMessage(topLevel, name, &stashName)
|
success = m_client->stashNameFromMessage(topLevel, name, &stashName)
|
||||||
&& m_client->synchronousReset(topLevel)
|
&& m_client->synchronousReset(topLevel)
|
||||||
&& m_client->synchronousStashRestore(topLevel, stashName);
|
&& m_client->synchronousStashRestore(topLevel, stashName, true);
|
||||||
}
|
}
|
||||||
} while (false);
|
} while (false);
|
||||||
return success;
|
return success;
|
||||||
|
|||||||
@@ -338,7 +338,7 @@ void StashDialog::restoreCurrent()
|
|||||||
// Make sure repository is not modified, restore. The command will
|
// Make sure repository is not modified, restore. The command will
|
||||||
// output to window on success.
|
// output to window on success.
|
||||||
const bool success = promptForRestore(&name, 0, &errorMessage)
|
const bool success = promptForRestore(&name, 0, &errorMessage)
|
||||||
&& gitClient()->synchronousStashRestore(m_repository, name, QString(), &errorMessage);
|
&& gitClient()->synchronousStashRestore(m_repository, name, false, QString(), &errorMessage);
|
||||||
if (success) {
|
if (success) {
|
||||||
refresh(m_repository, true); // Might have stashed away local changes.
|
refresh(m_repository, true); // Might have stashed away local changes.
|
||||||
} else {
|
} else {
|
||||||
@@ -355,7 +355,7 @@ void StashDialog::restoreCurrentInBranch()
|
|||||||
QString branch;
|
QString branch;
|
||||||
QString name = m_model->at(index).name;
|
QString name = m_model->at(index).name;
|
||||||
const bool success = promptForRestore(&name, &branch, &errorMessage)
|
const bool success = promptForRestore(&name, &branch, &errorMessage)
|
||||||
&& gitClient()->synchronousStashRestore(m_repository, name, branch, &errorMessage);
|
&& gitClient()->synchronousStashRestore(m_repository, name, false, branch, &errorMessage);
|
||||||
if (success) {
|
if (success) {
|
||||||
refresh(m_repository, true); // git deletes the stash, unfortunately.
|
refresh(m_repository, true); // git deletes the stash, unfortunately.
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user