diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2022-11-21 15:08:27 +0200 |
---|---|---|
committer | Orgad Shaneh <orgads@gmail.com> | 2022-11-21 15:49:56 +0000 |
commit | 252179b9383bb98ebfcaf89d0dc3d19a063d7669 (patch) | |
tree | 8dd8fdbc49ed6f470de7788ccde50fcd6b650e61 /src/plugins/git | |
parent | 4d63f2a5983c75b43a145efaa1a9b6787972c432 (diff) |
Git: Stop blame attempts for unmanaged files in the repository
A file that is in the repository directory, but not managed by Git should
not attempt to run instant blame on every cursor change.
Change-Id: Ia7daa2ae9980cea4363e010a98fb1e2f2a3ec05f
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Diffstat (limited to 'src/plugins/git')
-rw-r--r-- | src/plugins/git/gitplugin.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index d50bf9ac51..66969b4df5 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -430,6 +430,7 @@ public: Author m_author; int m_lastVisitedEditorLine = -1; QTimer *m_cursorPositionChangedTimer = nullptr; + QMetaObject::Connection m_blameCursorPosConn; GitSettingsPage settingPage{&m_settings}; @@ -1456,11 +1457,10 @@ void GitPluginPrivate::setupInstantBlame() if (qobject_cast<const VcsBaseEditorWidget *>(widget)) return; // Skip in VCS editors like log or blame - auto cursorPosConn = std::make_shared<QMetaObject::Connection>(); - *cursorPosConn = connect(widget, &QPlainTextEdit::cursorPositionChanged, this, - [this, cursorPosConn] { + m_blameCursorPosConn = connect(widget, &QPlainTextEdit::cursorPositionChanged, this, + [this] { if (!GitClient::instance()->settings().instantBlame.value()) { - disconnect(*cursorPosConn); + disconnect(m_blameCursorPosConn); return; } m_cursorPositionChangedTimer->start(500); @@ -1571,8 +1571,13 @@ void GitPluginPrivate::instantBlame() const QString lineString = QString("%1,%1").arg(line); const VcsCommand *command = GitClient::instance()->vcsExec( workingDirectory, {"blame", "-p", "-L", lineString, "--", filePath.toString()}, - nullptr, false, RunFlags::SuppressCommandLogging | RunFlags::ProgressiveOutput); + nullptr, false, RunFlags::NoOutput); connect(command, &VcsCommand::done, this, [command, filePath, line, this]() { + if (command->result() == ProcessResult::FinishedWithError && + command->cleanedStdErr().contains("no such path")) { + disconnect(m_blameCursorPosConn); + return; + } const QString output = command->cleanedStdOut(); const CommitInfo info = parseBlameOutput(output.split('\n'), filePath, m_author); m_blameMark.reset(new BlameMark(filePath, line, info)); |