forked from qt-creator/qt-creator
Git: Support stash --keep-index
Task-number: QTCREATORBUG-13587 Change-Id: I23f62b961df73872ae980d95b91a3285c0e367c1 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
c9df079885
commit
42e0ea62f6
@@ -1773,10 +1773,13 @@ QString GitClient::synchronousStash(const QString &workingDirectory, const QStri
|
||||
|
||||
bool GitClient::executeSynchronousStash(const QString &workingDirectory,
|
||||
const QString &message,
|
||||
bool unstagedOnly,
|
||||
QString *errorMessage) const
|
||||
{
|
||||
QStringList arguments;
|
||||
arguments << QLatin1String("stash") << QLatin1String("save");
|
||||
if (unstagedOnly)
|
||||
arguments << QLatin1String("--keep-index");
|
||||
if (!message.isEmpty())
|
||||
arguments << message;
|
||||
const unsigned flags = VcsBasePlugin::ShowStdOutInLogWindow
|
||||
@@ -3530,8 +3533,9 @@ void GitClient::StashInfo::stashPrompt(const QString &command, const QString &st
|
||||
} else if (msgBox.clickedButton() == cancelButton) {
|
||||
m_stashResult = StashCanceled;
|
||||
} else if (msgBox.clickedButton() == stashButton) {
|
||||
m_stashResult = m_client->executeSynchronousStash(m_workingDir,
|
||||
creatorStashMessage(command), errorMessage) ? StashUnchanged : StashFailed;
|
||||
const bool result = m_client->executeSynchronousStash(
|
||||
m_workingDir, creatorStashMessage(command), false, errorMessage);
|
||||
m_stashResult = result ? StashUnchanged : StashFailed;
|
||||
} else if (msgBox.clickedButton() == stashAndPopButton) {
|
||||
executeStash(command, errorMessage);
|
||||
}
|
||||
@@ -3540,7 +3544,7 @@ void GitClient::StashInfo::stashPrompt(const QString &command, const QString &st
|
||||
void GitClient::StashInfo::executeStash(const QString &command, QString *errorMessage)
|
||||
{
|
||||
m_message = creatorStashMessage(command);
|
||||
if (!m_client->executeSynchronousStash(m_workingDir, m_message, errorMessage))
|
||||
if (!m_client->executeSynchronousStash(m_workingDir, m_message, false, errorMessage))
|
||||
m_stashResult = StashFailed;
|
||||
else
|
||||
m_stashResult = Stashed;
|
||||
|
||||
@@ -202,6 +202,7 @@ public:
|
||||
|
||||
bool executeSynchronousStash(const QString &workingDirectory,
|
||||
const QString &message = QString(),
|
||||
bool unstagedOnly = false,
|
||||
QString *errorMessage = 0) const;
|
||||
bool synchronousStashRestore(const QString &workingDirectory,
|
||||
const QString &stash,
|
||||
|
||||
@@ -502,6 +502,11 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
context, true, SLOT(stash()));
|
||||
action->setToolTip(tr("Saves the current state of your work and resets the repository."));
|
||||
|
||||
action = createRepositoryAction(stashMenu, tr("Stash Unstaged Files"), "Git.StashUnstaged",
|
||||
context, true, SLOT(stashUnstaged()));
|
||||
action->setToolTip(tr("Saves the current state of your unstaged files and resets the repository "
|
||||
"to its staged state."));
|
||||
|
||||
action = createRepositoryAction(stashMenu, tr("Take Snapshot..."), "Git.StashSnapshot",
|
||||
context, true, SLOT(stashSnapshot()));
|
||||
action->setToolTip(tr("Saves the current state of your work."));
|
||||
@@ -1259,7 +1264,7 @@ void GitPlugin::applyPatch(const QString &workingDirectory, QString file)
|
||||
m_gitClient->endStashScope(workingDirectory);
|
||||
}
|
||||
|
||||
void GitPlugin::stash()
|
||||
void GitPlugin::stash(bool unstagedOnly)
|
||||
{
|
||||
if (!DocumentManager::saveAllModifiedDocuments())
|
||||
return;
|
||||
@@ -1268,11 +1273,16 @@ void GitPlugin::stash()
|
||||
QTC_ASSERT(state.hasTopLevel(), return);
|
||||
|
||||
const QString topLevel = state.topLevel();
|
||||
m_gitClient->executeSynchronousStash(topLevel);
|
||||
m_gitClient->executeSynchronousStash(topLevel, QString(), unstagedOnly);
|
||||
if (m_stashDialog)
|
||||
m_stashDialog->refresh(topLevel, true);
|
||||
}
|
||||
|
||||
void GitPlugin::stashUnstaged()
|
||||
{
|
||||
stash(true);
|
||||
}
|
||||
|
||||
void GitPlugin::stashSnapshot()
|
||||
{
|
||||
// Prompt for description, restore immediately and keep on working.
|
||||
|
||||
@@ -125,7 +125,8 @@ private slots:
|
||||
|
||||
void startAmendCommit();
|
||||
void startFixupCommit();
|
||||
void stash();
|
||||
void stash(bool unstagedOnly = false);
|
||||
void stashUnstaged();
|
||||
void stashSnapshot();
|
||||
void stashPop();
|
||||
void branchList();
|
||||
|
||||
Reference in New Issue
Block a user