forked from qt-creator/qt-creator
Git: Improve tracking of external changes to HEAD
Instead of using FileSystemWatcher, emit repositoryChanged when
refreshTopic is called.
This reverts commit 2a8c48cb15
.
Fixes: QTCREATORBUG-21089
Change-Id: Iaee8a895f3bc087583cbdea11c6dc2c263694a86
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
e757122843
commit
8394bb0a2b
@@ -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);
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user