diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2018-11-11 23:08:13 +0200 |
---|---|---|
committer | Orgad Shaneh <orgads@gmail.com> | 2019-01-09 12:39:01 +0000 |
commit | 2a8c48cb15d50b8686e5cb4f29a96f4431a0ec37 (patch) | |
tree | e02c8ed1188c4dc96d06b13d05ad564702debd58 /src/plugins/git | |
parent | ce43f6fbb4e6c652f822efba6679c5ea796c96a4 (diff) |
Git: Track external changes to HEAD
Fixes: QTCREATORBUG-21089
Change-Id: Ifcbefd4f57bfdb5c726eced194076503c1dcb497
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'src/plugins/git')
-rw-r--r-- | src/plugins/git/branchmodel.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/plugins/git/branchmodel.cpp b/src/plugins/git/branchmodel.cpp index 412f2ac284..cd2af5b02b 100644 --- a/src/plugins/git/branchmodel.cpp +++ b/src/plugins/git/branchmodel.cpp @@ -30,6 +30,7 @@ #include <vcsbase/vcsoutputwindow.h> #include <vcsbase/vcscommand.h> +#include <utils/filesystemwatcher.h> #include <utils/qtcassert.h> #include <QDateTime> @@ -217,6 +218,7 @@ public: QString currentSha; QDateTime currentDateTime; QStringList obsoleteLocalBranches; + Utils::FileSystemWatcher fsWatcher; bool oldBranchesIncluded = false; }; @@ -233,6 +235,10 @@ BranchModel::BranchModel(GitClient *client, QObject *parent) : // Abuse the sha field for ref prefix d->rootNode->append(new BranchNode(tr("Local Branches"), "refs/heads")); d->rootNode->append(new BranchNode(tr("Remote Branches"), "refs/remotes")); + connect(&d->fsWatcher, &Utils::FileSystemWatcher::fileChanged, this, [this] { + QString errorMessage; + refresh(d->workingDirectory, &errorMessage); + }); } BranchModel::~BranchModel() @@ -388,7 +394,13 @@ bool BranchModel::refresh(const QString &workingDirectory, QString *errorMessage return false; } - d->workingDirectory = workingDirectory; + if (d->workingDirectory != workingDirectory) { + d->workingDirectory = workingDirectory; + d->fsWatcher.removeFiles(d->fsWatcher.files()); + const QString gitDir = d->client->findGitDirForRepository(workingDirectory); + if (!gitDir.isEmpty()) + d->fsWatcher.addFile(gitDir + "/HEAD", Utils::FileSystemWatcher::WatchModifiedDate); + } const QStringList lines = output.split('\n'); for (const QString &l : lines) parseOutputLine(l); |