]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5677 Ignore whitespace when doing blame
authorJulien HENRY <julien.henry@sonarsource.com>
Fri, 10 Oct 2014 07:48:26 +0000 (09:48 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Tue, 14 Oct 2014 07:07:59 +0000 (09:07 +0200)
plugins/sonar-git-plugin/src/main/java/org/sonar/plugins/scm/git/JGitBlameCommand.java

index 4d02b1cfeda2079fef2bfd9e33ea73f02226379a..cfc044ad467829bc12a538cd540d3fb39fa34498 100644 (file)
@@ -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) {