forked from qt-creator/qt-creator
Git: Always allow stash before cherry-pick/revert
Currently done only from "Actions on Commits" Change-Id: Ide34e198e72f554ba6fd75ef21aaaf35917b4f6a Reviewed-by: Petar Perisin <petar.perisin@gmail.com> Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
8aa1c9bc37
commit
aad68917b9
@@ -3155,7 +3155,11 @@ void GitClient::rebase(const QString &workingDirectory, const QString &baseBranc
|
|||||||
bool GitClient::synchronousRevert(const QString &workingDirectory, const QString &commit)
|
bool GitClient::synchronousRevert(const QString &workingDirectory, const QString &commit)
|
||||||
{
|
{
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
QString command = QLatin1String("revert");
|
const QString command = QLatin1String("revert");
|
||||||
|
// Do not stash if --continue or --abort is given as the commit
|
||||||
|
if (!commit.startsWith(QLatin1Char('-')) && !beginStashScope(workingDirectory, command))
|
||||||
|
return false;
|
||||||
|
|
||||||
arguments << command << QLatin1String("--no-edit") << commit;
|
arguments << command << QLatin1String("--no-edit") << commit;
|
||||||
|
|
||||||
return executeAndHandleConflicts(workingDirectory, arguments, command);
|
return executeAndHandleConflicts(workingDirectory, arguments, command);
|
||||||
@@ -3164,7 +3168,11 @@ bool GitClient::synchronousRevert(const QString &workingDirectory, const QString
|
|||||||
bool GitClient::synchronousCherryPick(const QString &workingDirectory, const QString &commit)
|
bool GitClient::synchronousCherryPick(const QString &workingDirectory, const QString &commit)
|
||||||
{
|
{
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
QString command = QLatin1String("cherry-pick");
|
const QString command = QLatin1String("cherry-pick");
|
||||||
|
// Do not stash if --continue or --abort is given as the commit
|
||||||
|
if (!commit.startsWith(QLatin1Char('-')) && !beginStashScope(workingDirectory, command))
|
||||||
|
return false;
|
||||||
|
|
||||||
arguments << command << commit;
|
arguments << command << commit;
|
||||||
|
|
||||||
return executeAndHandleConflicts(workingDirectory, arguments, command);
|
return executeAndHandleConflicts(workingDirectory, arguments, command);
|
||||||
|
@@ -857,28 +857,23 @@ void GitPlugin::startChangeRelatedAction()
|
|||||||
|
|
||||||
if (!ensureAllDocumentsSaved())
|
if (!ensureAllDocumentsSaved())
|
||||||
return;
|
return;
|
||||||
QString command;
|
|
||||||
bool (GitClient::*commandFunction)(const QString&, const QString&);
|
bool (GitClient::*commandFunction)(const QString&, const QString&);
|
||||||
switch (dialog.command()) {
|
switch (dialog.command()) {
|
||||||
case CherryPick:
|
case CherryPick:
|
||||||
command = QLatin1String("Cherry-pick");
|
|
||||||
commandFunction = &GitClient::synchronousCherryPick;
|
commandFunction = &GitClient::synchronousCherryPick;
|
||||||
break;
|
break;
|
||||||
case Revert:
|
case Revert:
|
||||||
command = QLatin1String("Revert");
|
|
||||||
commandFunction = &GitClient::synchronousRevert;
|
commandFunction = &GitClient::synchronousRevert;
|
||||||
break;
|
break;
|
||||||
case Checkout:
|
case Checkout:
|
||||||
command = QLatin1String("Checkout");
|
if (!m_gitClient->beginStashScope(workingDirectory, QLatin1String("Checkout")))
|
||||||
|
return;
|
||||||
commandFunction = &GitClient::synchronousCheckout;
|
commandFunction = &GitClient::synchronousCheckout;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_gitClient->beginStashScope(workingDirectory, command))
|
|
||||||
return;
|
|
||||||
|
|
||||||
(m_gitClient->*commandFunction)(workingDirectory, change);
|
(m_gitClient->*commandFunction)(workingDirectory, change);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user