forked from qt-creator/qt-creator
Git: Ignore irrelevant changes in instant blame
Optionally ignore whitespace changes or line moves to only show the last real code changes. Feature is disabled by default. Fixes: QTCREATORBUG-29378 Change-Id: Ia2d5ad926f4098554b1ed3365bffadd4e2063e8e Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
This commit is contained in:
committed by
André Hartmann
parent
497bcbbf97
commit
e49ac10cb1
@@ -224,7 +224,7 @@ public:
|
||||
|
||||
QString toolTipText(const CommitInfo &info) const
|
||||
{
|
||||
const QString result = QString(
|
||||
QString result = QString(
|
||||
"<table>"
|
||||
" <tr><td>commit</td><td>%1</td></tr>"
|
||||
" <tr><td>Author:</td><td>%2 <%3></td></tr>"
|
||||
@@ -234,6 +234,12 @@ public:
|
||||
"</table>")
|
||||
.arg(info.sha1, info.author, info.authorMail,
|
||||
info.authorTime.toString("yyyy-MM-dd hh:mm:ss"), info.summary);
|
||||
|
||||
if (settings().instantBlameIgnoreSpaceChanges()
|
||||
|| settings().instantBlameIgnoreLineMoves()) {
|
||||
result.append(Tr::tr("<p><b>Note:</b> Ignore whitespace changes or line moves"
|
||||
" is enabled in the instant blame settings.</p>"));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
@@ -1574,9 +1580,14 @@ void GitPluginPrivate::instantBlame()
|
||||
const CommitInfo info = parseBlameOutput(output.split('\n'), filePath, m_author);
|
||||
m_blameMark.reset(new BlameMark(filePath, line, info));
|
||||
};
|
||||
gitClient().vcsExecWithHandler(workingDirectory,
|
||||
{"blame", "-p", "-L", lineString, "--", filePath.toString()},
|
||||
this, commandHandler, RunFlags::NoOutput, m_codec);
|
||||
QStringList options = {"blame", "-p"};
|
||||
if (settings().instantBlameIgnoreSpaceChanges())
|
||||
options.append("-w");
|
||||
if (settings().instantBlameIgnoreLineMoves())
|
||||
options.append("-M");
|
||||
options.append({"-L", lineString, "--", filePath.toString()});
|
||||
gitClient().vcsExecWithHandler(workingDirectory, options, this,
|
||||
commandHandler, RunFlags::NoOutput, m_codec);
|
||||
}
|
||||
|
||||
void GitPluginPrivate::stopInstantBlame()
|
||||
|
@@ -89,6 +89,18 @@ GitSettings::GitSettings()
|
||||
instantBlame.setLabelText(Tr::tr("Add instant blame annotations to editor"));
|
||||
instantBlame.setToolTip(
|
||||
Tr::tr("Annotate the current line in the editor with Git \"blame\" output."));
|
||||
instantBlameIgnoreSpaceChanges.setSettingsKey("GitInstantIgnoreSpaceChanges");
|
||||
instantBlameIgnoreSpaceChanges.setDefaultValue(false);
|
||||
instantBlameIgnoreSpaceChanges.setLabelText(
|
||||
Tr::tr("Ignore whitespace changes"));
|
||||
instantBlameIgnoreSpaceChanges.setToolTip(
|
||||
Tr::tr("Finds the commit that introduced the last real code changes to the line."));
|
||||
instantBlameIgnoreLineMoves.setSettingsKey("GitInstantIgnoreLineMoves");
|
||||
instantBlameIgnoreLineMoves.setDefaultValue(false);
|
||||
instantBlameIgnoreLineMoves.setLabelText(
|
||||
Tr::tr("Ignore line moves"));
|
||||
instantBlameIgnoreLineMoves.setToolTip(
|
||||
Tr::tr("Finds the commit that introduced the line before it was moved."));
|
||||
|
||||
graphLog.setSettingsKey("GraphLog");
|
||||
|
||||
@@ -137,7 +149,8 @@ GitSettings::GitSettings()
|
||||
|
||||
Group {
|
||||
title(Tr::tr("Instant Blame")),
|
||||
Row { instantBlame }
|
||||
instantBlame.groupChecker(),
|
||||
Row { instantBlameIgnoreSpaceChanges, instantBlameIgnoreLineMoves, st },
|
||||
},
|
||||
|
||||
st
|
||||
|
@@ -38,6 +38,8 @@ public:
|
||||
Utils::IntegerAspect lastResetIndex{this};
|
||||
Utils::BoolAspect refLogShowDate{this};
|
||||
Utils::BoolAspect instantBlame{this};
|
||||
Utils::BoolAspect instantBlameIgnoreSpaceChanges{this};
|
||||
Utils::BoolAspect instantBlameIgnoreLineMoves{this};
|
||||
|
||||
mutable Utils::FilePath resolvedBinPath;
|
||||
mutable bool tryResolve = true;
|
||||
|
Reference in New Issue
Block a user