Git: Show detached HEAD in branches view when applicable

Fixes: QTCREATORBUG-21311
Change-Id: Ia4297d23a965d83ea2814bd1e41f35a3017b8e9b
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Orgad Shaneh
2018-11-10 21:14:21 +02:00
committed by Orgad Shaneh
parent e0a1b171f1
commit 92431932e3
5 changed files with 47 additions and 13 deletions

View File

@@ -298,12 +298,12 @@ bool BranchView::add()
trackedBranch = m_model->fullName(trackedIndex);
}
const bool isLocal = m_model->isLocal(trackedIndex);
const bool isTag = m_model->isTag(trackedIndex);
const bool isTracked = !m_model->isHead(trackedIndex) && !m_model->isTag(trackedIndex);
const QStringList localNames = m_model->localBranchNames();
QString suggestedName;
if (!isTag) {
if (isTracked) {
const QString suggestedNameBase = trackedBranch.mid(trackedBranch.lastIndexOf('/') + 1);
suggestedName = suggestedNameBase;
int i = 2;
@@ -315,7 +315,7 @@ bool BranchView::add()
BranchAddDialog branchAddDialog(localNames, true, this);
branchAddDialog.setBranchName(suggestedName);
branchAddDialog.setTrackedBranchName(isTag ? QString() : trackedBranch, !isLocal);
branchAddDialog.setTrackedBranchName(isTracked ? trackedBranch : QString(), !isLocal);
if (branchAddDialog.exec() == QDialog::Accepted) {
QModelIndex idx = m_model->addBranch(branchAddDialog.branchName(), branchAddDialog.track(), trackedIndex);