summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst
diff options
context:
space:
mode:
authorKevin Sawicki <kevin@github.com>2011-09-04 14:46:06 -0700
committerChris Aniszczyk <zx@twitter.com>2011-09-30 14:22:46 -0700
commit37e4019fd98a213f3950b2a53efe95f73fda1c1b (patch)
treebc422c485f3ccceddb9e986f0fc738ac1fec65c0 /org.eclipse.jgit.test/tst
parenta4b5051880c259fc84771f9f5861e6e12689b5ac (diff)
downloadjgit-37e4019fd98a213f3950b2a53efe95f73fda1c1b.tar.gz
jgit-37e4019fd98a213f3950b2a53efe95f73fda1c1b.zip
Add blame unit test for file that is renamed twice.
Bug: 354507 Change-Id: I853774ecc1662d095a50a9668431c6e3ce4156c4 Signed-off-by: Kevin Sawicki <kevin@github.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-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 1f67807e46..cfae7ed6a5 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);