aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/git
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2022-10-11 16:28:02 +0300
committerOrgad Shaneh <orgads@gmail.com>2022-10-14 12:16:16 +0000
commit8394bb0a2b6801405a48207f301f0efb66f2debe (patch)
tree7cd21712f67096ac0f6de01efe393d58c896689b /src/plugins/git
parente757122843ecb411ec2bd01b70137427a23ce6f6 (diff)
Git: Improve tracking of external changes to HEAD
Instead of using FileSystemWatcher, emit repositoryChanged when refreshTopic is called. This reverts commit 2a8c48cb15d50b8686e5cb4f29a96f4431a0ec37. Fixes: QTCREATORBUG-21089 Change-Id: Iaee8a895f3bc087583cbdea11c6dc2c263694a86 Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Diffstat (limited to 'src/plugins/git')
-rw-r--r--src/plugins/git/branchmodel.cpp14
-rw-r--r--src/plugins/git/gitplugin.cpp47
2 files changed, 25 insertions, 36 deletions
diff --git a/src/plugins/git/branchmodel.cpp b/src/plugins/git/branchmodel.cpp
index 4deefcb734..2effa6f215 100644
--- a/src/plugins/git/branchmodel.cpp
+++ b/src/plugins/git/branchmodel.cpp
@@ -11,7 +11,6 @@
#include <vcsbase/vcsoutputwindow.h>
#include <utils/environment.h>
-#include <utils/filesystemwatcher.h>
#include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
#include <utils/stringutils.h>
@@ -229,7 +228,6 @@ public:
QString currentSha;
QDateTime currentDateTime;
QStringList obsoleteLocalBranches;
- Utils::FileSystemWatcher fsWatcher;
bool oldBranchesIncluded = false;
struct OldEntry
@@ -257,10 +255,6 @@ BranchModel::BranchModel(GitClient *client, QObject *parent) :
// Abuse the sha field for ref prefix
d->rootNode->append(new BranchNode(Tr::tr("Local Branches"), "refs/heads"));
d->rootNode->append(new BranchNode(Tr::tr("Remote Branches"), "refs/remotes"));
- connect(&d->fsWatcher, &Utils::FileSystemWatcher::fileChanged, this, [this] {
- QString errorMessage;
- refresh(d->workingDirectory, &errorMessage);
- });
}
BranchModel::~BranchModel()
@@ -422,13 +416,7 @@ bool BranchModel::refresh(const FilePath &workingDirectory, QString *errorMessag
return false;
}
- if (d->workingDirectory != workingDirectory) {
- d->workingDirectory = workingDirectory;
- d->fsWatcher.clear();
- const QString gitDir = d->client->findGitDirForRepository(workingDirectory);
- if (!gitDir.isEmpty())
- d->fsWatcher.addFile(gitDir + "/HEAD", Utils::FileSystemWatcher::WatchModifiedDate);
- }
+ d->workingDirectory = workingDirectory;
const QStringList lines = output.split('\n');
for (const QString &l : lines)
d->parseOutputLine(l);
diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp
index a6bdfbf32e..c77ce79bcd 100644
--- a/src/plugins/git/gitplugin.cpp
+++ b/src/plugins/git/gitplugin.cpp
@@ -85,29 +85,6 @@ namespace Git::Internal {
using GitClientMemberFunc = void (GitClient::*)(const FilePath &) const;
-class GitTopicCache : public IVersionControl::TopicCache
-{
-public:
- GitTopicCache(GitClient *client) :
- m_client(client)
- { }
-
-protected:
- FilePath trackFile(const FilePath &repository) override
- {
- const QString gitDir = m_client->findGitDirForRepository(repository);
- return gitDir.isEmpty() ? FilePath() : FilePath::fromString(gitDir + "/HEAD");
- }
-
- QString refreshTopic(const FilePath &repository) override
- {
- return m_client->synchronousTopic(repository);
- }
-
-private:
- GitClient *m_client;
-};
-
class GitReflogEditorWidget : public GitEditorWidget
{
public:
@@ -437,6 +414,30 @@ public:
static GitPluginPrivate *dd = nullptr;
+class GitTopicCache : public IVersionControl::TopicCache
+{
+public:
+ GitTopicCache(GitClient *client) :
+ m_client(client)
+ { }
+
+protected:
+ FilePath trackFile(const FilePath &repository) override
+ {
+ const QString gitDir = m_client->findGitDirForRepository(repository);
+ return gitDir.isEmpty() ? FilePath() : FilePath::fromString(gitDir + "/HEAD");
+ }
+
+ QString refreshTopic(const FilePath &repository) override
+ {
+ emit dd->repositoryChanged(repository);
+ return m_client->synchronousTopic(repository);
+ }
+
+private:
+ GitClient *m_client;
+};
+
GitPluginPrivate::~GitPluginPrivate()
{
cleanCommitMessageFile();