diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index 85e01f3e9aa..0196a8cee8f 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -224,7 +224,7 @@ public: QString toolTipText(const CommitInfo &info) const { - const QString result = QString( + QString result = QString( "" " " " " @@ -234,6 +234,12 @@ public: "
commit%1
Author:%2 <%3>
") .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("

Note: Ignore whitespace changes or line moves" + " is enabled in the instant blame settings.

")); + } 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() diff --git a/src/plugins/git/gitsettings.cpp b/src/plugins/git/gitsettings.cpp index 62ef1f15eb2..79d85566986 100644 --- a/src/plugins/git/gitsettings.cpp +++ b/src/plugins/git/gitsettings.cpp @@ -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 diff --git a/src/plugins/git/gitsettings.h b/src/plugins/git/gitsettings.h index a48b5ccb2a9..f5a83c5e8a9 100644 --- a/src/plugins/git/gitsettings.h +++ b/src/plugins/git/gitsettings.h @@ -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;