From c22471d3161b4b4a1ded20fc11764050d22a020c Mon Sep 17 00:00:00 2001 From: Andre Hartmann Date: Sun, 11 Feb 2024 12:34:02 +0100 Subject: [PATCH] Git: Disable upstream status for Detached HEAD It was always zero as Detached HEAD is a special branch that is not actively queried. It can be enabled later, but the quick fix is to disable it. Change-Id: Ib191e1b5551a13bc4911184e12e06a0b4dc28ddf Reviewed-by: Orgad Shaneh Reviewed-by: --- src/plugins/git/branchmodel.cpp | 7 +++++-- src/plugins/git/gitclient.h | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/plugins/git/branchmodel.cpp b/src/plugins/git/branchmodel.cpp index 14a59f0993b..ed80feeb16a 100644 --- a/src/plugins/git/branchmodel.cpp +++ b/src/plugins/git/branchmodel.cpp @@ -318,9 +318,12 @@ QVariant BranchModel::data(const QModelIndex &index, int role) const if (!node->isLocal() || !node->isLeaf()) break; - res += ' ' + arrowUp + QString::number(node->status.ahead); + if (node->status.ahead >= 0) + res += ' ' + arrowUp + QString::number(node->status.ahead); + if (!node->tracking.isEmpty()) { - res += ' ' + arrowDown + QString::number(node->status.behind); + if (node->status.behind >= 0) + res += ' ' + arrowDown + QString::number(node->status.behind); res += " [" + node->tracking + ']'; } break; diff --git a/src/plugins/git/gitclient.h b/src/plugins/git/gitclient.h index 3f8368c62eb..f0ed9ffc8eb 100644 --- a/src/plugins/git/gitclient.h +++ b/src/plugins/git/gitclient.h @@ -73,8 +73,8 @@ public: UpstreamStatus() = default; UpstreamStatus(int ahead, int behind) : ahead(ahead), behind(behind) {} - int ahead = 0; - int behind = 0; + int ahead = -1; + int behind = -1; }; struct Author {