forked from qt-creator/qt-creator
Git: Instant Blame: Use original line number for blame
The line might have been moved and therfore using the original line number asures the full blame is scrolled to the correct position. Change-Id: I07478d499af3509670a7d91771b2ee9777a06b3c Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
committed by
André Hartmann
parent
bfe1258d1b
commit
f005f2c4be
@@ -79,8 +79,8 @@ bool BlameMark::addToolTipContent(QLayout *target) const
|
|||||||
const QString originalFileName = m_info.originalFileName;
|
const QString originalFileName = m_info.originalFileName;
|
||||||
if (link.startsWith("blame")) {
|
if (link.startsWith("blame")) {
|
||||||
qCInfo(log).nospace().noquote() << "Blaming: \"" << path << "/" << originalFileName
|
qCInfo(log).nospace().noquote() << "Blaming: \"" << path << "/" << originalFileName
|
||||||
<< "\":" << m_info.line << " @ " << sha1;
|
<< "\":" << m_info.originalLine << " @ " << sha1;
|
||||||
gitClient().annotate(path, originalFileName, m_info.line, sha1);
|
gitClient().annotate(path, originalFileName, m_info.originalLine, sha1);
|
||||||
} else {
|
} else {
|
||||||
qCInfo(log).nospace().noquote() << "Showing file: \"" << path << "/"
|
qCInfo(log).nospace().noquote() << "Showing file: \"" << path << "/"
|
||||||
<< originalFileName << "\" @ " << sha1;
|
<< originalFileName << "\" @ " << sha1;
|
||||||
@@ -226,7 +226,8 @@ static CommitInfo parseBlameOutput(const QStringList &blame, const Utils::FilePa
|
|||||||
if (blame.size() <= 12)
|
if (blame.size() <= 12)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
result.sha1 = blame.at(0).left(40);
|
const QStringList firstLineParts = blame.at(0).split(" ");
|
||||||
|
result.sha1 = firstLineParts.first();
|
||||||
result.author = blame.at(1).mid(7);
|
result.author = blame.at(1).mid(7);
|
||||||
result.authorMail = blame.at(2).mid(13).chopped(1);
|
result.authorMail = blame.at(2).mid(13).chopped(1);
|
||||||
if (result.author == author.name || result.authorMail == author.email)
|
if (result.author == author.name || result.authorMail == author.email)
|
||||||
@@ -243,6 +244,10 @@ static CommitInfo parseBlameOutput(const QStringList &blame, const Utils::FilePa
|
|||||||
else
|
else
|
||||||
result.originalFileName = blame.at(11).mid(9);
|
result.originalFileName = blame.at(11).mid(9);
|
||||||
result.line = line;
|
result.line = line;
|
||||||
|
if (firstLineParts.size() > 1)
|
||||||
|
result.originalLine = firstLineParts.at(1).toInt();
|
||||||
|
else
|
||||||
|
result.originalLine = line;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -25,9 +25,10 @@ public:
|
|||||||
QString authorMail;
|
QString authorMail;
|
||||||
QDateTime authorTime;
|
QDateTime authorTime;
|
||||||
QString summary;
|
QString summary;
|
||||||
Utils::FilePath filePath;
|
Utils::FilePath filePath; ///< absolute file path for current file
|
||||||
QString originalFileName; // relative file path from project root
|
QString originalFileName; ///< relative file path from project root for the original file
|
||||||
int line = -1;
|
int line = -1; ///< current line number in current file
|
||||||
|
int originalLine = -1; ///< original line number in the original file
|
||||||
};
|
};
|
||||||
|
|
||||||
class BlameMark : public TextEditor::TextMark
|
class BlameMark : public TextEditor::TextMark
|
||||||
|
Reference in New Issue
Block a user