Git: Improve detection of nested local branch

If the current branch was foo/bar it was not detected correctly.

Change-Id: Ic030a6f4659801c6da2716c272a418c89585e22f
Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
Orgad Shaneh
2017-03-26 16:44:07 +03:00
committed by Orgad Shaneh
parent 07921dee77
commit 5736ef2c54

View File

@@ -374,7 +374,7 @@ bool BranchModel::refresh(const QString &workingDirectory, QString *errorMessage
parseOutputLine(l);
if (m_currentBranch) {
if (m_currentBranch->parent == m_rootNode->children.at(LocalBranches))
if (m_currentBranch->isLocal())
m_currentBranch = nullptr;
setCurrentBranch();
}
@@ -391,11 +391,13 @@ void BranchModel::setCurrentBranch()
return;
BranchNode *local = m_rootNode->children.at(LocalBranches);
int pos = 0;
for (pos = 0; pos < local->count(); ++pos) {
if (local->children.at(pos)->name == currentBranch)
m_currentBranch = local->children[pos];
const QStringList branchParts = currentBranch.split('/');
for (const QString &branchPart : branchParts) {
local = local->childOfName(branchPart);
if (!local)
return;
}
m_currentBranch = local;
}
void BranchModel::renameBranch(const QString &oldName, const QString &newName)