Commit b7faf4d6 authored by Petar Perisin's avatar Petar Perisin Committed by Tobias Hunger
Browse files

Git: added custom message to EnsureStash popup



Better overview in stash dialog.

Change-Id: Icb6d3f8e2e068882e661e017ce8a0bb00ec6dba5
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 8b419be1
......@@ -431,7 +431,7 @@ void BranchModel::checkoutBranch(const QModelIndex &idx)
return;
QString errorMessage;
switch (m_client->ensureStash(m_workingDirectory, &errorMessage)) {
switch (m_client->ensureStash(m_workingDirectory, QLatin1String("Branch-Checkout"), 0, &errorMessage)) {
case GitClient::StashUnchanged:
case GitClient::Stashed:
case GitClient::NotStashed:
......
......@@ -1568,17 +1568,17 @@ static inline int askWithDetailedText(QWidget *parent,
}
// Convenience that pops up an msg box.
GitClient::StashResult GitClient::ensureStash(const QString &workingDirectory)
GitClient::StashResult GitClient::ensureStash(const QString &workingDirectory, const QString &keyword, QString *message)
{
QString errorMessage;
const StashResult sr = ensureStash(workingDirectory, &errorMessage);
const StashResult sr = ensureStash(workingDirectory, keyword, message, &errorMessage);
if (sr == StashFailed)
outputWindow()->appendError(errorMessage);
return sr;
}
// Ensure that changed files are stashed before a pull or similar
GitClient::StashResult GitClient::ensureStash(const QString &workingDirectory, QString *errorMessage)
GitClient::StashResult GitClient::ensureStash(const QString &workingDirectory, const QString &keyword, QString *message, QString *errorMessage)
{
QString statusOutput;
switch (gitStatus(workingDirectory, StatusMode(NoUntracked | NoSubmodules),
......@@ -1597,14 +1597,17 @@ GitClient::StashResult GitClient::ensureStash(const QString &workingDirectory, Q
switch (answer) {
case QMessageBox::Cancel:
return StashCanceled;
case QMessageBox::Yes:
if (!executeSynchronousStash(workingDirectory, creatorStashMessage(QLatin1String("push")), errorMessage))
case QMessageBox::Yes: {
const QString stashMessage = creatorStashMessage(keyword);
if (!executeSynchronousStash(workingDirectory, stashMessage, errorMessage))
return StashFailed;
if (message)
*message = stashMessage;
break;
}
case QMessageBox::No: // At your own risk, so.
return NotStashed;
}
return Stashed;
}
......
......@@ -207,8 +207,8 @@ public:
enum StashResult { StashUnchanged, StashCanceled, StashFailed,
Stashed, NotStashed /* User did not want it */ };
StashResult ensureStash(const QString &workingDirectory, QString *errorMessage);
StashResult ensureStash(const QString &workingDirectory);
StashResult ensureStash(const QString &workingDirectory, const QString &keyword, QString *message = 0);
StashResult ensureStash(const QString &workingDirectory, const QString &keyword, QString *message, QString *errorMessage);
bool getCommitData(const QString &workingDirectory, bool amend,
QString *commitTemplate, CommitData *commitData,
......
......@@ -901,7 +901,7 @@ void GitPlugin::pull()
}
}
GitClient::StashResult stashResult = m_gitClient->ensureStash(state.topLevel());
GitClient::StashResult stashResult = m_gitClient->ensureStash(state.topLevel(), QLatin1String("Pull"));
switch (stashResult) {
case GitClient::StashUnchanged:
case GitClient::Stashed:
......@@ -1031,7 +1031,7 @@ void GitPlugin::promptApplyPatch()
void GitPlugin::applyPatch(const QString &workingDirectory, QString file)
{
// Ensure user has been notified about pending changes
switch (m_gitClient->ensureStash(workingDirectory)) {
switch (m_gitClient->ensureStash(workingDirectory, QLatin1String("Apply-Patch"))) {
case GitClient::StashUnchanged:
case GitClient::Stashed:
case GitClient::NotStashed:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment