forked from qt-creator/qt-creator
Git: added custom message to EnsureStash popup
Better overview in stash dialog. Change-Id: Icb6d3f8e2e068882e661e017ce8a0bb00ec6dba5 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
committed by
Tobias Hunger
parent
8b419be12f
commit
b7faf4d674
@@ -431,7 +431,7 @@ void BranchModel::checkoutBranch(const QModelIndex &idx)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
QString errorMessage;
|
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::StashUnchanged:
|
||||||
case GitClient::Stashed:
|
case GitClient::Stashed:
|
||||||
case GitClient::NotStashed:
|
case GitClient::NotStashed:
|
||||||
|
@@ -1568,17 +1568,17 @@ static inline int askWithDetailedText(QWidget *parent,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convenience that pops up an msg box.
|
// 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;
|
QString errorMessage;
|
||||||
const StashResult sr = ensureStash(workingDirectory, &errorMessage);
|
const StashResult sr = ensureStash(workingDirectory, keyword, message, &errorMessage);
|
||||||
if (sr == StashFailed)
|
if (sr == StashFailed)
|
||||||
outputWindow()->appendError(errorMessage);
|
outputWindow()->appendError(errorMessage);
|
||||||
return sr;
|
return sr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that changed files are stashed before a pull or similar
|
// 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;
|
QString statusOutput;
|
||||||
switch (gitStatus(workingDirectory, StatusMode(NoUntracked | NoSubmodules),
|
switch (gitStatus(workingDirectory, StatusMode(NoUntracked | NoSubmodules),
|
||||||
@@ -1597,14 +1597,17 @@ GitClient::StashResult GitClient::ensureStash(const QString &workingDirectory, Q
|
|||||||
switch (answer) {
|
switch (answer) {
|
||||||
case QMessageBox::Cancel:
|
case QMessageBox::Cancel:
|
||||||
return StashCanceled;
|
return StashCanceled;
|
||||||
case QMessageBox::Yes:
|
case QMessageBox::Yes: {
|
||||||
if (!executeSynchronousStash(workingDirectory, creatorStashMessage(QLatin1String("push")), errorMessage))
|
const QString stashMessage = creatorStashMessage(keyword);
|
||||||
|
if (!executeSynchronousStash(workingDirectory, stashMessage, errorMessage))
|
||||||
return StashFailed;
|
return StashFailed;
|
||||||
|
if (message)
|
||||||
|
*message = stashMessage;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case QMessageBox::No: // At your own risk, so.
|
case QMessageBox::No: // At your own risk, so.
|
||||||
return NotStashed;
|
return NotStashed;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Stashed;
|
return Stashed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -207,8 +207,8 @@ public:
|
|||||||
|
|
||||||
enum StashResult { StashUnchanged, StashCanceled, StashFailed,
|
enum StashResult { StashUnchanged, StashCanceled, StashFailed,
|
||||||
Stashed, NotStashed /* User did not want it */ };
|
Stashed, NotStashed /* User did not want it */ };
|
||||||
StashResult ensureStash(const QString &workingDirectory, QString *errorMessage);
|
StashResult ensureStash(const QString &workingDirectory, const QString &keyword, QString *message = 0);
|
||||||
StashResult ensureStash(const QString &workingDirectory);
|
StashResult ensureStash(const QString &workingDirectory, const QString &keyword, QString *message, QString *errorMessage);
|
||||||
|
|
||||||
bool getCommitData(const QString &workingDirectory, bool amend,
|
bool getCommitData(const QString &workingDirectory, bool amend,
|
||||||
QString *commitTemplate, CommitData *commitData,
|
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) {
|
switch (stashResult) {
|
||||||
case GitClient::StashUnchanged:
|
case GitClient::StashUnchanged:
|
||||||
case GitClient::Stashed:
|
case GitClient::Stashed:
|
||||||
@@ -1031,7 +1031,7 @@ void GitPlugin::promptApplyPatch()
|
|||||||
void GitPlugin::applyPatch(const QString &workingDirectory, QString file)
|
void GitPlugin::applyPatch(const QString &workingDirectory, QString file)
|
||||||
{
|
{
|
||||||
// Ensure user has been notified about pending changes
|
// 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::StashUnchanged:
|
||||||
case GitClient::Stashed:
|
case GitClient::Stashed:
|
||||||
case GitClient::NotStashed:
|
case GitClient::NotStashed:
|
||||||
|
Reference in New Issue
Block a user