aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-10-10 09:48:26 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2014-10-14 09:07:59 +0200
commit8707b7ee842e74e3deed92d28ae5e3b01b63f23d (patch)
tree7d5f5df315035c7e79ca4d07e4801e08954d0552 /plugins
parent28d06e64fc9658e8d6b6947d1213a6e046aac2fc (diff)
downloadsonarqube-8707b7ee842e74e3deed92d28ae5e3b01b63f23d.tar.gz
sonarqube-8707b7ee842e74e3deed92d28ae5e3b01b63f23d.zip
SONAR-5677 Ignore whitespace when doing blame
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/JGitBlameCommand.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/JGitBlameCommand.java b/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/JGitBlameCommand.java
index 4d02b1cfeda..cfc044ad467 100644
--- a/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/JGitBlameCommand.java
+++ b/plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/JGitBlameCommand.java
@@ -21,6 +21,7 @@ package org.sonar.plugins.scm.git;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
+import org.eclipse.jgit.diff.RawTextComparator;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.RepositoryBuilder;
import org.slf4j.Logger;
@@ -76,7 +77,10 @@ public class JGitBlameCommand implements BlameCommand, BatchComponent {
private void blame(BlameResult result, Git git, File gitBaseDir, InputFile inputFile) throws GitAPIException {
String filename = pathResolver.relativePath(gitBaseDir, inputFile.file());
- org.eclipse.jgit.blame.BlameResult blameResult = git.blame().setFilePath(filename).call();
+ org.eclipse.jgit.blame.BlameResult blameResult = git.blame()
+ // Equivalent to -w command line option
+ .setTextComparator(RawTextComparator.WS_IGNORE_ALL)
+ .setFilePath(filename).call();
List<BlameLine> lines = new ArrayList<BlameLine>();
for (int i = 0; i < blameResult.getResultContents().size(); i++) {
if (blameResult.getSourceAuthor(i) == null || blameResult.getSourceCommit(i) == null || blameResult.getSourceCommitter(i) == null) {