Git: Enable different reset types for commits in git editors

Change-Id: I0eafbd3db04a7da4ea85457ae67a940c71b49e9b
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
Orgad Shaneh
2015-03-10 12:03:03 +02:00
committed by Orgad Shaneh
parent 1eeca66c29
commit 690a545f8e
2 changed files with 13 additions and 5 deletions

View File

@@ -212,12 +212,13 @@ void GitEditorWidget::checkoutChange()
sourceWorkingDirectory(), m_currentChange);
}
void GitEditorWidget::resetChange()
void GitEditorWidget::resetChange(const QByteArray &resetType)
{
const QString workingDir = sourceWorkingDirectory();
GitClient *client = GitPlugin::instance()->gitClient();
if (client->gitStatus(workingDir, StatusMode(NoUntracked | NoSubmodules))
if (resetType == "hard"
&& client->gitStatus(workingDir, StatusMode(NoUntracked | NoSubmodules))
!= GitClient::StatusUnchanged) {
if (QMessageBox::question(
Core::ICore::mainWindow(), tr("Reset"),
@@ -227,7 +228,7 @@ void GitEditorWidget::resetChange()
return;
}
}
client->reset(workingDir, QLatin1String("--hard"), m_currentChange);
client->reset(workingDir, QLatin1String("--" + resetType), m_currentChange);
}
void GitEditorWidget::cherryPickChange()
@@ -348,7 +349,14 @@ void GitEditorWidget::addChangeActions(QMenu *menu, const QString &change)
menu->addAction(tr("Cherr&y-Pick Change %1").arg(change), this, SLOT(cherryPickChange()));
menu->addAction(tr("Re&vert Change %1").arg(change), this, SLOT(revertChange()));
menu->addAction(tr("C&heckout Change %1").arg(change), this, SLOT(checkoutChange()));
menu->addAction(tr("Hard &Reset to Change %1").arg(change), this, SLOT(resetChange()));
QMenu *resetMenu = new QMenu(tr("&Reset to Change %1").arg(change), menu);
connect(resetMenu->addAction(tr("&Hard")), &QAction::triggered,
this, [this]() { resetChange("hard"); });
connect(resetMenu->addAction(tr("&Mixed")), &QAction::triggered,
this, [this]() { resetChange("mixed"); });
connect(resetMenu->addAction(tr("&Soft")), &QAction::triggered,
this, [this]() { resetChange("soft"); });
menu->addMenu(resetMenu);
}
}

View File

@@ -56,13 +56,13 @@ public slots:
private slots:
void checkoutChange();
void resetChange();
void cherryPickChange();
void revertChange();
void applyDiffChunk(const VcsBase::DiffChunk& chunk, bool revert);
private:
void init();
void resetChange(const QByteArray &resetType);
void addDiffActions(QMenu *menu, const VcsBase::DiffChunk &chunk);
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
QSet<QString> annotationChanges() const;