Git: Stop Instant Blame when git returns empty blame data

That can happen for example, when having a file with active
Instant Blame open and choosing "Save As" to save a copy
of that file in a folder not under version control.

Also fix the related case, when the file is saved in the
same folder, but is not under version control yet.
In this case, let's remove the blame mark, otherwise it
will stay forever as we only stopped the cursor connection.

Fixes: QTCREATORBUG-29991
Change-Id: I6ffed869c18334ba87dbcded409d31ead21f4b25
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Andre Hartmann
2023-12-01 13:03:31 +01:00
committed by André Hartmann
parent f073db7f4c
commit c0d7835022

View File

@@ -1592,10 +1592,14 @@ void GitPluginPrivate::instantBlame()
const auto commandHandler = [this, filePath, line](const CommandResult &result) { const auto commandHandler = [this, filePath, line](const CommandResult &result) {
if (result.result() == ProcessResult::FinishedWithError && if (result.result() == ProcessResult::FinishedWithError &&
result.cleanedStdErr().contains("no such path")) { result.cleanedStdErr().contains("no such path")) {
disconnect(m_blameCursorPosConn); stopInstantBlame();
return; return;
} }
const QString output = result.cleanedStdOut(); const QString output = result.cleanedStdOut();
if (output.isEmpty()) {
stopInstantBlame();
return;
}
const CommitInfo info = parseBlameOutput(output.split('\n'), filePath, m_author); const CommitInfo info = parseBlameOutput(output.split('\n'), filePath, m_author);
m_blameMark.reset(new BlameMark(filePath, line, info)); m_blameMark.reset(new BlameMark(filePath, line, info));
}; };