Commit 690a545f authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

Git: Enable different reset types for commits in git editors

Change-Id: I0eafbd3db04a7da4ea85457ae67a940c71b49e9b
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent 1eeca66c
......@@ -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);
}
}
......
......@@ -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;
......
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