diff --git a/src/plugins/git/instantblame.cpp b/src/plugins/git/instantblame.cpp index 29eeaaecedb..5a87cf06442 100644 --- a/src/plugins/git/instantblame.cpp +++ b/src/plugins/git/instantblame.cpp @@ -113,25 +113,33 @@ QString BlameMark::toolTipText(const CommitInfo &info) const { const ColorNames colors = GitClient::colorNames(); - QString result = QString( - "" - " " - " " - " " - " " - "
Blame %2Blame ParentFile at %2Log for line %4
" - "

" + QString actions; + if (!info.modified) { + actions = QString( + "" + " " + " " + " " + " " + "
Blame %1Blame ParentFile at %1Log for line %2
" + "

") + .arg(info.hash.left(8), QString::number(info.line)); + } + + const QString header = QString( "" - " " - " " - " " + " " + " " + " " "
commit%3
Author:%6 <%7>
Date:%9
commit%2
Author:%4 <%5>
Date:%7
" - "

%11

") - .arg(colors.hash, info.hash.left(8), info.hash, QString::number(info.line), + "

%9

") + .arg(colors.hash, info.hash, colors.author, info.author, info.authorMail, colors.date, info.authorDate.toString("yyyy-MM-dd hh:mm:ss"), colors.subject, info.subject); + QString result = actions + header; + QString diff; if (!info.oldLines.isEmpty()) { const QString removed = GitClient::styleColorName(TextEditor::C_REMOVED_LINE); @@ -276,12 +284,15 @@ void InstantBlame::setup() static CommitInfo parseBlameOutput(const QStringList &blame, const Utils::FilePath &filePath, int line, const Git::Internal::Author &author) { + static const QString uncommittedHash(40, '0'); + CommitInfo result; if (blame.size() <= 12) return result; const QStringList firstLineParts = blame.at(0).split(" "); result.hash = firstLineParts.first(); + result.modified = result.hash == uncommittedHash; result.author = blame.at(1).mid(7); result.authorMail = blame.at(2).mid(13).chopped(1); if (result.author == author.name || result.authorMail == author.email) @@ -407,8 +418,7 @@ void InstantBlame::perform() const CommitInfo info = parseBlameOutput(output.split('\n'), filePath, line, m_author); m_blameMark.reset(new BlameMark(filePath, line, info)); - static const QString uncommittedHash(40, '0'); - if (info.hash == uncommittedHash) + if (info.modified) return; // Get line diff: `git log -n 1 -p -L47,47:README.md a5c4c34c9ab4` diff --git a/src/plugins/git/instantblame.h b/src/plugins/git/instantblame.h index 48dc90118ac..bd70034d280 100644 --- a/src/plugins/git/instantblame.h +++ b/src/plugins/git/instantblame.h @@ -31,6 +31,7 @@ public: QString originalFileName; ///< relative file path from project root for the original file int line = -1; ///< current line number in current file int originalLine = -1; ///< original line number in the original file + bool modified = false; ///< line is locally modified (uncommitted) }; class BlameMark : public TextEditor::TextMark