From 62c60c6d1c01990136fd39765a7975287fdfcd4c Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Fri, 13 May 2016 15:44:35 +0300 Subject: [PATCH] Git: Filter obsolete branch names when adding a branch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTCREATORBUG-16264 Change-Id: Ifcb04c7740ab274be590f53757e013da43ad96f1 Reviewed-by: André Hartmann --- src/plugins/git/branchmodel.cpp | 9 +++++++-- src/plugins/git/branchmodel.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/plugins/git/branchmodel.cpp b/src/plugins/git/branchmodel.cpp index ae9746eef9c..e6a53ca330c 100644 --- a/src/plugins/git/branchmodel.cpp +++ b/src/plugins/git/branchmodel.cpp @@ -337,6 +337,7 @@ void BranchModel::clear() m_rootNode->children.takeLast(); m_currentBranch = 0; + m_obsoleteLocalBranches.clear(); } bool BranchModel::refresh(const QString &workingDirectory, QString *errorMessage) @@ -446,7 +447,7 @@ QStringList BranchModel::localBranchNames() const if (!m_rootNode || !m_rootNode->count()) return QStringList(); - return m_rootNode->children.at(LocalBranches)->childrenNames(); + return m_rootNode->children.at(LocalBranches)->childrenNames() + m_obsoleteLocalBranches; } QString BranchModel::sha(const QModelIndex &idx) const @@ -657,8 +658,12 @@ void BranchModel::parseOutputLine(const QString &line) if (!strDateTime.isEmpty()) { const uint timeT = strDateTime.leftRef(strDateTime.indexOf(QLatin1Char(' '))).toUInt(); const int age = QDateTime::fromTime_t(timeT).daysTo(QDateTime::currentDateTime()); - if (age > Constants::OBSOLETE_COMMIT_AGE_IN_DAYS) + if (age > Constants::OBSOLETE_COMMIT_AGE_IN_DAYS) { + const QString heads = "refs/heads/"; + if (fullName.startsWith(heads)) + m_obsoleteLocalBranches.append(fullName.mid(heads.size())); return; + } } } bool showTags = m_client->settings().boolValue(GitSettings::showTagsKey); diff --git a/src/plugins/git/branchmodel.h b/src/plugins/git/branchmodel.h index 214061b208b..210a9b78585 100644 --- a/src/plugins/git/branchmodel.h +++ b/src/plugins/git/branchmodel.h @@ -95,6 +95,7 @@ private: BranchNode *m_rootNode; BranchNode *m_currentBranch = nullptr; QString m_currentSha; + QStringList m_obsoleteLocalBranches; bool m_oldBranchesIncluded = false; };