Commit e6da9083 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

Git: Refactor reset

Remove enum, provide the associated flag in the combobox.

Change-Id: I1c4751c75f59312904fe7c175678f965ac16741d
Reviewed-by: default avatarTobias Hunger <>
parent cbfeb36c
......@@ -869,10 +869,10 @@ bool GitClient::synchronousCheckout(const QString &workingDirectory,
return true;
void GitClient::hardReset(const QString &workingDirectory, const QString &commit)
void GitClient::reset(const QString &workingDirectory, const QString &argument, const QString &commit)
QStringList arguments;
arguments << QLatin1String("reset") << QLatin1String("--hard");
arguments << QLatin1String("reset") << argument;
if (!commit.isEmpty())
arguments << commit;
......@@ -880,18 +880,6 @@ void GitClient::hardReset(const QString &workingDirectory, const QString &commit
connectRepositoryChanged(workingDirectory, cmd);
void GitClient::softReset(const QString &workingDirectory, const QString &commit)
if (commit.isEmpty())
QStringList arguments;
arguments << QLatin1String("reset") << QLatin1String("--soft") << commit;
VcsBase::Command *cmd = executeGit(workingDirectory, arguments, 0, true);
connectRepositoryChanged(workingDirectory, cmd);
void GitClient::addFile(const QString &workingDirectory, const QString &fileName)
QStringList arguments;
......@@ -137,8 +137,7 @@ public:
bool enableAnnotationContextMenu = false, const QStringList &args = QStringList());
void blame(const QString &workingDirectory, const QStringList &args, const QString &fileName,
const QString &revision = QString(), int lineNumber = -1);
void hardReset(const QString &workingDirectory, const QString &commit = QString());
void softReset(const QString &workingDirectory, const QString &commit);
void reset(const QString &workingDirectory, const QString &argument, const QString &commit = QString());
void addFile(const QString &workingDirectory, const QString &fileName);
bool synchronousLog(const QString &workingDirectory,
const QStringList &arguments,
......@@ -708,14 +708,7 @@ void GitPlugin::resetRepository()
LogChangeDialog dialog(true);
dialog.setWindowTitle(tr("Undo Changes to %1").arg(QDir::toNativeSeparators(topLevel)));
if (dialog.runDialog(topLevel))
switch (dialog.resetType()) {
case HardReset:
m_gitClient->hardReset(topLevel, dialog.commit());
case SoftReset:
m_gitClient->softReset(topLevel, dialog.commit());
m_gitClient->reset(topLevel, dialog.resetFlag(), dialog.commit());
void GitPlugin::startRebase()
......@@ -72,8 +72,8 @@ LogChangeDialog::LogChangeDialog(bool isReset, QWidget *parent)
if (isReset) {
popUpLayout->addWidget(new QLabel(tr("Reset type:"), this));
m_resetTypeComboBox = new QComboBox(this);
m_resetTypeComboBox->addItem(tr("Hard Reset"), HardReset);
m_resetTypeComboBox->addItem(tr("Soft Reset"), SoftReset);
m_resetTypeComboBox->addItem(tr("Hard"), QLatin1String("--hard"));
m_resetTypeComboBox->addItem(tr("Soft"), QLatin1String("--soft"));
popUpLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored));
......@@ -112,11 +112,11 @@ QString LogChangeDialog::commit() const
return QString();
ResetType LogChangeDialog::resetType() const
QString LogChangeDialog::resetFlag() const
if (!m_resetTypeComboBox)
return HardReset;
return static_cast<ResetType>(m_resetTypeComboBox->itemData(m_resetTypeComboBox->currentIndex()).toInt());
return QString();
return m_resetTypeComboBox->itemData(m_resetTypeComboBox->currentIndex()).toString();
bool LogChangeDialog::populateLog(const QString &repository)
......@@ -44,13 +44,7 @@ namespace Git {
namespace Internal {
// A dialog that lists SHA1 and subject of the changes
// for reset --hard and --soft.
enum ResetType {
// Used for reset and interactive rebased
class LogChangeDialog : public QDialog
......@@ -60,7 +54,7 @@ public:
bool runDialog(const QString &repository);
QString commit() const;
ResetType resetType() const;
QString resetFlag() const;
bool populateLog(const QString &repository);
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