diff --git a/src/plugins/git/branchmodel.cpp b/src/plugins/git/branchmodel.cpp index ae4d6fd839e..8d90200952b 100644 --- a/src/plugins/git/branchmodel.cpp +++ b/src/plugins/git/branchmodel.cpp @@ -731,6 +731,7 @@ void BranchModel::setRemoteTracking(const QModelIndex &trackingIndex) const QString tracking = fullName(trackingIndex, true); d->client->synchronousSetTrackingBranch(d->workingDirectory, currentName, tracking); d->currentBranch->tracking = shortTracking; + updateUpstreamStatus(d->currentBranch); emit dataChanged(current, current); } @@ -840,17 +841,7 @@ void BranchModel::Private::parseOutputLine(const QString &line, bool force) root->insert(nameParts, newNode); if (current) currentBranch = newNode; - if (newNode->tracking.isEmpty()) - return; - VcsCommand *command = client->asyncUpstreamStatus(workingDirectory, newNode->name, newNode->tracking); - QObject::connect(command, &VcsCommand::stdOutText, newNode, [this, newNode](const QString &text) { - const QStringList split = text.trimmed().split('\t'); - QTC_ASSERT(split.size() == 2, return); - - newNode->setUpstreamStatus(UpstreamStatus(split.at(0).toInt(), split.at(1).toInt())); - const QModelIndex idx = q->nodeToIndex(newNode, 0); - emit q->dataChanged(idx, idx); - }); + q->updateUpstreamStatus(newNode); } void BranchModel::Private::flushOldEntries() @@ -898,6 +889,21 @@ void BranchModel::removeNode(const QModelIndex &idx) } } +void BranchModel::updateUpstreamStatus(BranchNode *node) +{ + if (node->tracking.isEmpty()) + return; + VcsCommand *command = d->client->asyncUpstreamStatus(d->workingDirectory, node->name, node->tracking); + QObject::connect(command, &VcsCommand::stdOutText, node, [this, node](const QString &text) { + const QStringList split = text.trimmed().split('\t'); + QTC_ASSERT(split.size() == 2, return); + + node->setUpstreamStatus(UpstreamStatus(split.at(0).toInt(), split.at(1).toInt())); + const QModelIndex idx = nodeToIndex(node, 0); + emit dataChanged(idx, idx); + }); +} + QString BranchModel::toolTip(const QString &sha) const { // Show the sha description excluding diff as toolTip diff --git a/src/plugins/git/branchmodel.h b/src/plugins/git/branchmodel.h index 2a0de65bbe4..7a2fa285123 100644 --- a/src/plugins/git/branchmodel.h +++ b/src/plugins/git/branchmodel.h @@ -92,6 +92,7 @@ private: BranchNode *indexToNode(const QModelIndex &index) const; QModelIndex nodeToIndex(BranchNode *node, int column) const; void removeNode(const QModelIndex &idx); + void updateUpstreamStatus(BranchNode *node); QString toolTip(const QString &sha) const;