From cd8ea1f45b3aa7334ef2e775ec2fef8ae1453031 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Mon, 13 Feb 2023 20:41:50 +0200 Subject: [PATCH] Git: Call updateUpstreamStatus for all branches in a single place MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Calling it for each parsed line mixes unrelated logic. * I consider adding a cache later, but that will require data for all the remotes before this call. Change-Id: Ic3ee975fc6172f2a8848bc8d0a6620d4ccbf9cd2 Reviewed-by: André Hartmann --- src/plugins/git/branchmodel.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/plugins/git/branchmodel.cpp b/src/plugins/git/branchmodel.cpp index cb051693d6d..dbfbf4bfe84 100644 --- a/src/plugins/git/branchmodel.cpp +++ b/src/plugins/git/branchmodel.cpp @@ -218,6 +218,7 @@ public: bool hasTags() const { return rootNode->children.count() > Tags; } void parseOutputLine(const QString &line, bool force = false); void flushOldEntries(); + void updateAllUpstreamStatus(BranchNode *node); BranchModel *q; GitClient *client; @@ -422,6 +423,7 @@ bool BranchModel::refresh(const FilePath &workingDirectory, QString *errorMessag d->parseOutputLine(l); d->flushOldEntries(); + d->updateAllUpstreamStatus(d->rootNode->children.at(LocalBranches)); if (d->currentBranch) { if (d->currentBranch->isLocal()) d->currentBranch = nullptr; @@ -827,7 +829,6 @@ void BranchModel::Private::parseOutputLine(const QString &line, bool force) root->insert(nameParts, newNode); if (current) currentBranch = newNode; - q->updateUpstreamStatus(newNode); } void BranchModel::Private::flushOldEntries() @@ -902,6 +903,18 @@ void BranchModel::updateUpstreamStatus(BranchNode *node) process->start(); } +void BranchModel::Private::updateAllUpstreamStatus(BranchNode *node) +{ + if (!node) + return; + if (node->isLeaf()) { + q->updateUpstreamStatus(node); + return; + } + for (BranchNode *child : node->children) + updateAllUpstreamStatus(child); +} + QString BranchModel::toolTip(const QString &sha) const { // Show the sha description excluding diff as toolTip