summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorKevin Sawicki2011-09-04 17:46:06 (EDT)
committer Chris Aniszczyk2011-09-30 17:22:46 (EDT)
commit37e4019fd98a213f3950b2a53efe95f73fda1c1b (patch)
treebc422c485f3ccceddb9e986f0fc738ac1fec65c0
parenta4b5051880c259fc84771f9f5861e6e12689b5ac (diff)
downloadjgit-37e4019fd98a213f3950b2a53efe95f73fda1c1b.zip
jgit-37e4019fd98a213f3950b2a53efe95f73fda1c1b.tar.gz
jgit-37e4019fd98a213f3950b2a53efe95f73fda1c1b.tar.bz2
Add blame unit test for file that is renamed twice.refs/changes/35/4135/4
Bug: 354507 Change-Id: I853774ecc1662d095a50a9668431c6e3ce4156c4 Signed-off-by: Kevin Sawicki <kevin@github.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BlameCommandTest.java42
1 files changed, 42 insertions, 0 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 1f67807..cfae7ed 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
@@ -151,6 +151,48 @@ public class BlameCommandTest extends RepositoryTestCase {
}
@Test
+ public void testTwoRenames() throws Exception {
+ Git git = new Git(db);
+
+ // Commit 1: Add file.txt
+ String[] content1 = new String[] { "a" };
+ writeTrashFile("file.txt", join(content1));
+ git.add().addFilepattern("file.txt").call();
+ RevCommit commit1 = git.commit().setMessage("create file").call();
+
+ // Commit 2: Rename to file1.txt
+ writeTrashFile("file1.txt", join(content1));
+ git.add().addFilepattern("file1.txt").call();
+ git.rm().addFilepattern("file.txt").call();
+ git.commit().setMessage("moving file").call();
+
+ // Commit 3: Edit file1.txt
+ String[] content2 = new String[] { "a", "b" };
+ writeTrashFile("file1.txt", join(content2));
+ git.add().addFilepattern("file1.txt").call();
+ RevCommit commit3 = git.commit().setMessage("editing file").call();
+
+ // Commit 4: Rename to file2.txt
+ writeTrashFile("file2.txt", join(content2));
+ git.add().addFilepattern("file2.txt").call();
+ git.rm().addFilepattern("file1.txt").call();
+ git.commit().setMessage("moving file again").call();
+
+ BlameCommand command = new BlameCommand(db);
+ command.setFollowFileRenames(true);
+ command.setFilePath("file2.txt");
+ BlameResult lines = command.call();
+
+ assertEquals(commit1, lines.getSourceCommit(0));
+ assertEquals(0, lines.getSourceLine(0));
+ assertEquals("file.txt", lines.getSourcePath(0));
+
+ assertEquals(commit3, lines.getSourceCommit(1));
+ assertEquals(1, lines.getSourceLine(1));
+ assertEquals("file1.txt", lines.getSourcePath(1));
+ }
+
+ @Test
public void testDeleteTrailingLines() throws Exception {
Git git = new Git(db);