summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Pearce <sop@google.com>2014-05-04 14:37:14 -0400
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2014-05-04 14:37:14 -0400
commit561121e111fd756136590b6dc52f273177a4c1f5 (patch)
tree6586c4d7bdd806dc4daaa877f68760718cbd959c
parent6cc9bb79c84386830cf5e2a72574cb2273c760bd (diff)
parentc2fb432cdee34f2bd198668e6dffd557578a976c (diff)
downloadjgit-561121e111fd756136590b6dc52f273177a4c1f5.tar.gz
jgit-561121e111fd756136590b6dc52f273177a4c1f5.zip
Merge "blame: Fix merges, where merge result differs only by whitespace"
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BlameCommandTest.java31
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java5
2 files changed, 34 insertions, 2 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BlameCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BlameCommandTest.java
index 743e16de04..0745eb6c8d 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BlameCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BlameCommandTest.java
@@ -47,8 +47,10 @@ import static org.junit.Assert.assertNotNull;
import java.io.File;
+import org.eclipse.jgit.api.MergeCommand.FastForwardMode;
import org.eclipse.jgit.api.ResetCommand.ResetType;
import org.eclipse.jgit.blame.BlameResult;
+import org.eclipse.jgit.diff.RawTextComparator;
import org.eclipse.jgit.junit.RepositoryTestCase;
import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.CoreConfig.AutoCRLF;
@@ -456,4 +458,33 @@ public class BlameCommandTest extends RepositoryTestCase {
assertEquals(merge, lines.getSourceCommit(3));
assertEquals(base, lines.getSourceCommit(4));
}
+
+ @Test
+ public void testWhitespaceMerge() throws Exception {
+ Git git = new Git(db);
+ RevCommit base = commitFile("file.txt", join("0", "1", "2"), "master");
+ RevCommit side = commitFile("file.txt", join("0", "1", " 2 side "),
+ "side");
+
+ checkoutBranch("refs/heads/master");
+ git.merge().setFastForward(FastForwardMode.NO_FF).include(side).call();
+
+ // change whitespace, so the merge content is not identical to side, but
+ // is the same when ignoring whitespace
+ writeTrashFile("file.txt", join("0", "1", "2 side"));
+ RevCommit merge = git.commit().setAll(true).setMessage("merge")
+ .setAmend(true)
+ .call();
+
+ BlameCommand command = new BlameCommand(db);
+ command.setFilePath("file.txt")
+ .setTextComparator(RawTextComparator.WS_IGNORE_ALL)
+ .setStartCommit(merge.getId());
+ BlameResult lines = command.call();
+
+ assertEquals(3, lines.getResultContents().size());
+ assertEquals(base, lines.getSourceCommit(0));
+ assertEquals(base, lines.getSourceCommit(1));
+ assertEquals(side, lines.getSourceCommit(2));
+ }
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java b/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java
index ca695d2a8b..a54ef56697 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java
@@ -768,8 +768,9 @@ public class BlameGenerator {
}
p.regionList = n.regionList;
- push(p);
- return false;
+ n.regionList = null;
+ parents[pIdx] = p;
+ break;
}
p.takeBlame(editList, n);