diff --git a/src/plugins/git/changeselectiondialog.cpp b/src/plugins/git/changeselectiondialog.cpp index 8a750cd4db8923b9d3774f2fd1dbf7439693cd4c..edf49194ab1cd8b921cba75e776ca01c5e8ad8a2 100644 --- a/src/plugins/git/changeselectiondialog.cpp +++ b/src/plugins/git/changeselectiondialog.cpp @@ -53,6 +53,7 @@ ChangeSelectionDialog::ChangeSelectionDialog(const QString &workingDirectory, QW , m_showButton(new QPushButton(tr("Show"), this)) , m_cherryPickButton(new QPushButton(tr("Cherry Pick"), this)) , m_revertButton(new QPushButton(tr("Revert"), this)) + , m_checkoutButton(new QPushButton(tr("Checkout"), this)) , m_cancelButton(new QPushButton(tr("Cancel"), this)) , m_command(NoCommand) { @@ -71,6 +72,7 @@ ChangeSelectionDialog::ChangeSelectionDialog(const QString &workingDirectory, QW QHBoxLayout* buttonsLine = new QHBoxLayout(); buttonsLine->addWidget(m_cancelButton); buttonsLine->addStretch(); + buttonsLine->addWidget(m_checkoutButton); buttonsLine->addWidget(m_revertButton); buttonsLine->addWidget(m_cherryPickButton); buttonsLine->addWidget(m_showButton); @@ -91,6 +93,7 @@ ChangeSelectionDialog::ChangeSelectionDialog(const QString &workingDirectory, QW connect(m_showButton, SIGNAL(clicked()), this, SLOT(acceptShow())); connect(m_cherryPickButton, SIGNAL(clicked()), this, SLOT(acceptCherryPick())); connect(m_revertButton, SIGNAL(clicked()), this, SLOT(acceptRevert())); + connect(m_checkoutButton, SIGNAL(clicked()), this, SLOT(acceptCheckout())); connect(m_cancelButton, SIGNAL(clicked()), this, SLOT(reject())); recalculateDetails(m_changeNumberEdit->text()); @@ -116,6 +119,12 @@ ChangeCommand ChangeSelectionDialog::command() const return m_command; } +void ChangeSelectionDialog::acceptCheckout() +{ + m_command = Checkout; + accept(); +} + void ChangeSelectionDialog::acceptCherryPick() { m_command = CherryPick; diff --git a/src/plugins/git/changeselectiondialog.h b/src/plugins/git/changeselectiondialog.h index 0f2e77e6ea940451296ea646b11373732d849418..a7a5fad38e7343455b194e34a38b0b5c264efae8 100644 --- a/src/plugins/git/changeselectiondialog.h +++ b/src/plugins/git/changeselectiondialog.h @@ -46,6 +46,7 @@ namespace Internal { enum ChangeCommand { NoCommand, + Checkout, CherryPick, Revert, Show @@ -66,6 +67,7 @@ public: private slots: void setDetails(int exitCode); void recalculateDetails(const QString &ref); + void acceptCheckout(); void acceptCherryPick(); void acceptRevert(); void acceptShow(); @@ -83,6 +85,7 @@ private: QPushButton* m_showButton; QPushButton* m_cherryPickButton; QPushButton* m_revertButton; + QPushButton* m_checkoutButton; QPushButton* m_cancelButton; ChangeCommand m_command; diff --git a/src/plugins/git/gitclient.h b/src/plugins/git/gitclient.h index 79af177e4d7cec504e807e9d9d9332c5d7fb9c48..2619a41fa634c64471ce180ef58456b85bc5c8b6 100644 --- a/src/plugins/git/gitclient.h +++ b/src/plugins/git/gitclient.h @@ -155,7 +155,9 @@ public: QString revision = QString(), QString *errorMessage = 0, bool revertStaging = true); // Checkout branch - bool synchronousCheckout(const QString &workingDirectory, const QString &ref, QString *errorMessage = 0); + bool synchronousCheckout(const QString &workingDirectory, const QString &ref, QString *errorMessage); + bool synchronousCheckout(const QString &workingDirectory, const QString &ref) + { return synchronousCheckout(workingDirectory, ref, 0); } // Do a stash and return identier. enum { StashPromptDescription = 0x1, StashImmediateRestore = 0x2, StashIgnoreUnchanged = 0x4 }; diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index 63061d8cc8287f3451bc61dbf2071b1025b9499c..862b375bfda0f41072650eeabdae23db721a103b 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -763,6 +763,10 @@ void GitPlugin::startChangeRelatedAction() command = QLatin1String("Revert"); commandFunction = &GitClient::revertCommit; break; + case Checkout: + command = QLatin1String("Checkout"); + commandFunction = &GitClient::synchronousCheckout; + break; default: return; }