diff --git a/src/plugins/git/branchdialog.cpp b/src/plugins/git/branchdialog.cpp index ae883675cb387be972f9cb85d03286a9892f638a..b804fea5a9af0992b8c429beb609b7600d142db4 100644 --- a/src/plugins/git/branchdialog.cpp +++ b/src/plugins/git/branchdialog.cpp @@ -73,6 +73,7 @@ BranchDialog::BranchDialog(QWidget *parent) : m_ui(new Ui::BranchDialog), m_checkoutButton(0), m_diffButton(0), + m_logButton(0), m_refreshButton(0), m_deleteButton(0), m_localModel(new LocalBranchModel(gitClient(), this)), @@ -90,6 +91,9 @@ BranchDialog::BranchDialog(QWidget *parent) : m_diffButton = m_ui->buttonBox->addButton(tr("Diff"), QDialogButtonBox::ActionRole); connect(m_diffButton, SIGNAL(clicked()), this, SLOT(slotDiffSelected())); + m_logButton = m_ui->buttonBox->addButton(tr("Log"), QDialogButtonBox::ActionRole); + connect(m_logButton, SIGNAL(clicked()), this, SLOT(slotLog())); + m_refreshButton = m_ui->buttonBox->addButton(tr("Refresh"), QDialogButtonBox::ActionRole); connect(m_refreshButton, SIGNAL(clicked()), this, SLOT(slotRefresh())); @@ -168,6 +172,7 @@ void BranchDialog::slotEnableButtons(const QItemSelection &selected) m_checkoutButton->setEnabled(otherLocalSelected); m_diffButton->setEnabled(branchSelected); + m_logButton->setEnabled(branchSelected); m_deleteButton->setEnabled(otherLocalSelected); m_refreshButton->setEnabled(hasRepository); // Also disable <New Branch> entry of list view @@ -258,6 +263,18 @@ void BranchDialog::slotDiffSelected() gitClient()->diffBranch(m_repository, QStringList(), m_remoteModel->branchName(idx)); } +void BranchDialog::slotLog() +{ + int idx = selectedLocalBranchIndex(); + if (idx != -1) { + gitClient()->graphLog(m_repository, m_localModel->branchName(idx)); + return; + } + idx = selectedRemoteBranchIndex(); + if (idx != -1) + gitClient()->graphLog(m_repository, m_remoteModel->branchName(idx)); +} + /* Ask to stash away changes and then close dialog and do an asynchronous * checkout. */ void BranchDialog::slotCheckoutSelectedBranch() diff --git a/src/plugins/git/branchdialog.h b/src/plugins/git/branchdialog.h index bf21a746e34615aa7e300b790885d246409ac1d1..4fdabeaa88d99cda9d9723e371e0fc93f5124919 100644 --- a/src/plugins/git/branchdialog.h +++ b/src/plugins/git/branchdialog.h @@ -69,6 +69,7 @@ private slots: void slotCheckoutSelectedBranch(); void slotDeleteSelectedBranch(); void slotDiffSelected(); + void slotLog(); void slotRefresh(); void slotLocalBranchActivated(); void slotRemoteBranchActivated(const QModelIndex &); @@ -87,6 +88,7 @@ private: Ui::BranchDialog *m_ui; QPushButton *m_checkoutButton; QPushButton *m_diffButton; + QPushButton *m_logButton; QPushButton *m_refreshButton; QPushButton *m_deleteButton; diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index 74f778bd551f8b6c53a6384b966b4624bfc9866a..f81480bd3a7306462a65fda9c41078c91cea8c76 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -291,7 +291,7 @@ void GitClient::status(const QString &workingDirectory) static const char graphLogFormatC[] = "%h %an %s %ci"; // Create a graphical log. -void GitClient::graphLog(const QString &workingDirectory) +void GitClient::graphLog(const QString &workingDirectory, const QString & branch) { if (Git::Constants::debug) qDebug() << "log" << workingDirectory; @@ -304,7 +304,13 @@ void GitClient::graphLog(const QString &workingDirectory) arguments << (QLatin1String("--pretty=format:") + QLatin1String(graphLogFormatC)) << QLatin1String("--topo-order") << QLatin1String("--graph"); - const QString title = tr("Git Log"); + QString title; + if (branch.isEmpty()) { + title = tr("Git Log"); + } else { + title = tr("Git Log %1").arg(branch); + arguments << branch; + } const QString editorId = QLatin1String(Git::Constants::GIT_LOG_EDITOR_ID); const QString sourceFile = VCSBase::VCSBaseEditor::getSource(workingDirectory, QStringList()); VCSBase::VCSBaseEditor *editor = createVCSEditor(editorId, title, sourceFile, false, "logFileName", sourceFile); diff --git a/src/plugins/git/gitclient.h b/src/plugins/git/gitclient.h index a183a619099c4be1930553b512413500a816c168..dbf0ea58a9dd644cf9c9b9c155defaf6bbb5dd7e 100644 --- a/src/plugins/git/gitclient.h +++ b/src/plugins/git/gitclient.h @@ -87,7 +87,8 @@ public: const QString &branchName); void status(const QString &workingDirectory); - void graphLog(const QString &workingDirectory); + void graphLog(const QString &workingDirectory) { graphLog(workingDirectory, QString()); } + void graphLog(const QString &workingDirectory, const QString &branch); void log(const QString &workingDirectory, const QStringList &fileNames, bool enableAnnotationContextMenu = false); void blame(const QString &workingDirectory, const QString &fileName,