Skip to content
Snippets Groups Projects
Commit 8e5edbec authored by Robert Loehning's avatar Robert Loehning
Browse files

VCS[git]: Allow diff with current or remote branch

parent 0d187323
No related branches found
No related tags found
No related merge requests found
......@@ -160,16 +160,15 @@ void BranchDialog::slotEnableButtons(const QItemSelection &selected)
}
// We can switch to or delete branches that are not current.
const bool hasRepository = !m_repository.isEmpty();
const int selectedLocalRow = selectedLocalBranchIndex();
const int currentLocalBranch = m_localModel->currentBranch();
const bool hasSelection = selectedLocalRow != -1 && !m_localModel->isNewBranchRow(selectedLocalRow);
const bool currentIsNotSelected = hasSelection && selectedLocalRow != currentLocalBranch;
const bool hasRepository = !m_repository.isEmpty();
const bool hasLocalSelection = selectedLocalRow != -1 && !m_localModel->isNewBranchRow(selectedLocalRow);
const bool otherLocalSelected = hasLocalSelection && selectedLocalRow != m_localModel->currentBranch();
const bool branchSelected = hasLocalSelection || selectedRemoteBranchIndex() != -1;
m_checkoutButton->setEnabled(currentIsNotSelected);
m_diffButton->setEnabled(currentIsNotSelected);
m_deleteButton->setEnabled(currentIsNotSelected);
m_checkoutButton->setEnabled(otherLocalSelected);
m_diffButton->setEnabled(branchSelected);
m_deleteButton->setEnabled(otherLocalSelected);
m_refreshButton->setEnabled(hasRepository);
// Also disable <New Branch> entry of list view
m_ui->localBranchListView->setEnabled(hasRepository);
......@@ -249,10 +248,14 @@ void BranchDialog::slotLocalBranchActivated()
void BranchDialog::slotDiffSelected()
{
const int idx = selectedLocalBranchIndex();
if (idx == -1)
int idx = selectedLocalBranchIndex();
if (idx != -1) {
gitClient()->diffBranch(m_repository, QStringList(), m_localModel->branchName(idx));
return;
gitClient()->diffBranch(m_repository, QStringList(), m_localModel->branchName(idx));
}
idx = selectedRemoteBranchIndex();
if (idx != -1)
gitClient()->diffBranch(m_repository, QStringList(), m_remoteModel->branchName(idx));
}
/* Ask to stash away changes and then close dialog and do an asynchronous
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment