indexabout

This is a web interface for Eclipse Git repositories. Many projects also use the Gerrit Code Review. For more information about Git, please see the Git Wiki page.

The contents of the Git repositories are made available under the terms and conditions of the Eclipse.org Software User Agreement.

NameDescriptionOwnerDiffstat
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/BlameCommandTest.java37
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/blame/BlameGeneratorTest.java75
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java1
3 files changed, 102 insertions, 11 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 cfae7ed..7e1c22c 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
@@ -115,39 +115,54 @@ public class BlameCommandTest extends RepositoryTestCase {
@Test
public void testRename() throws Exception {
+ testRename("file1.txt", "file2.txt");
+ }
+
+ @Test
+ public void testRenameInSubDir() throws Exception {
+ testRename("subdir/file1.txt", "subdir/file2.txt");
+ }
+
+ @Test
+ public void testMoveToOtherDir() throws Exception {
+ testRename("subdir/file1.txt", "otherdir/file1.txt");
+ }
+
+ private void testRename(final String sourcePath, final String destPath)
+ throws Exception {
Git git = new Git(db);
String[] content1 = new String[] { "a", "b", "c" };
- writeTrashFile("file.txt", join(content1));
- git.add().addFilepattern("file.txt").call();
+ writeTrashFile(sourcePath, join(content1));
+ git.add().addFilepattern(sourcePath).call();
RevCommit commit1 = git.commit().setMessage("create file").call();
- writeTrashFile("file1.txt", join(content1));
- git.add().addFilepattern("file1.txt").call();
- git.rm().addFilepattern("file.txt").call();
+ writeTrashFile(destPath, join(content1));
+ git.add().addFilepattern(destPath).call();
+ git.rm().addFilepattern(sourcePath).call();
git.commit().setMessage("moving file").call();
String[] content2 = new String[] { "a", "b", "c2" };
- writeTrashFile("file1.txt", join(content2));
- git.add().addFilepattern("file1.txt").call();
+ writeTrashFile(destPath, join(content2));
+ git.add().addFilepattern(destPath).call();
RevCommit commit3 = git.commit().setMessage("editing file").call();
BlameCommand command = new BlameCommand(db);
command.setFollowFileRenames(true);
- command.setFilePath("file1.txt");
+ command.setFilePath(destPath);
BlameResult lines = command.call();
assertEquals(commit1, lines.getSourceCommit(0));
assertEquals(0, lines.getSourceLine(0));
- assertEquals("file.txt", lines.getSourcePath(0));
+ assertEquals(sourcePath, lines.getSourcePath(0));
assertEquals(commit1, lines.getSourceCommit(1));
assertEquals(1, lines.getSourceLine(1));
- assertEquals("file.txt", lines.getSourcePath(1));
+ assertEquals(sourcePath, lines.getSourcePath(1));
assertEquals(commit3, lines.getSourceCommit(2));
assertEquals(2, lines.getSourceLine(2));
- assertEquals("file1.txt", lines.getSourcePath(2));
+ assertEquals(destPath, lines.getSourcePath(2));
}
@Test
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/blame/BlameGeneratorTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/blame/BlameGeneratorTest.java
index 657cf38..d021282 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/blame/BlameGeneratorTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/blame/BlameGeneratorTest.java
@@ -48,6 +48,7 @@ import static org.junit.Assert.assertTrue;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.blame.BlameGenerator;
+import org.eclipse.jgit.blame.BlameResult;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.RepositoryTestCase;
import org.eclipse.jgit.revwalk.RevCommit;
@@ -99,6 +100,80 @@ public class BlameGeneratorTest extends RepositoryTestCase {
}
@Test
+ public void testRenamedBoundLineDelete() throws Exception {
+ Git git = new Git(db);
+ final String FILENAME_1 = "subdir/file1.txt";
+ final String FILENAME_2 = "subdir/file2.txt";
+
+ String[] content1 = new String[] { "first", "second" };
+ writeTrashFile(FILENAME_1, join(content1));
+ git.add().addFilepattern(FILENAME_1).call();
+ RevCommit c1 = git.commit().setMessage("create file1").call();
+
+ // rename it
+ writeTrashFile(FILENAME_2, join(content1));
+ git.add().addFilepattern(FILENAME_2).call();
+ deleteTrashFile(FILENAME_1);
+ git.rm().addFilepattern(FILENAME_1).call();
+ git.commit().setMessage("rename file1.txt to file2.txt").call();
+
+ // and change the new file
+ String[] content2 = new String[] { "third", "first", "second" };
+ writeTrashFile(FILENAME_2, join(content2));
+ git.add().addFilepattern(FILENAME_2).call();
+ RevCommit c2 = git.commit().setMessage("change file2").call();
+
+ BlameGenerator generator = new BlameGenerator(db, FILENAME_2);
+ try {
+ generator.push(null, db.resolve(Constants.HEAD));
+ assertEquals(3, generator.getResultContents().size());
+
+ assertTrue(generator.next());
+ assertEquals(c2, generator.getSourceCommit());
+ assertEquals(1, generator.getRegionLength());
+ assertEquals(0, generator.getResultStart());
+ assertEquals(1, generator.getResultEnd());
+ assertEquals(0, generator.getSourceStart());
+ assertEquals(1, generator.getSourceEnd());
+ assertEquals(FILENAME_2, generator.getSourcePath());
+
+ assertTrue(generator.next());
+ assertEquals(c1, generator.getSourceCommit());
+ assertEquals(2, generator.getRegionLength());
+ assertEquals(1, generator.getResultStart());
+ assertEquals(3, generator.getResultEnd());
+ assertEquals(0, generator.getSourceStart());
+ assertEquals(2, generator.getSourceEnd());
+ assertEquals(FILENAME_1, generator.getSourcePath());
+
+ assertFalse(generator.next());
+ } finally {
+ generator.release();
+ }
+
+ // and test again with other BlameGenerator API:
+ generator = new BlameGenerator(db, FILENAME_2);
+ try {
+ generator.push(null, db.resolve(Constants.HEAD));
+ BlameResult result = generator.computeBlameResult();
+
+ assertEquals(3, result.getResultContents().size());
+
+ assertEquals(c2, result.getSourceCommit(0));
+ assertEquals(FILENAME_2, result.getSourcePath(0));
+
+ assertEquals(c1, result.getSourceCommit(1));
+ assertEquals(FILENAME_1, result.getSourcePath(1));
+
+ assertEquals(c1, result.getSourceCommit(2));
+ assertEquals(FILENAME_1, result.getSourcePath(2));
+
+ } finally {
+ generator.release();
+ }
+ }
+
+ @Test
public void testLinesAllDeletedShortenedWalk() throws Exception {
Git git = new Git(db);
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 5157364..028817f 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/blame/BlameGenerator.java
@@ -178,6 +178,7 @@ public class BlameGenerator {
SEEN = revPool.newFlag("SEEN");
reader = revPool.getObjectReader();
treeWalk = new TreeWalk(reader);
+ treeWalk.setRecursive(true);
}
/** @return repository being scanned for revision history. */

Back to the top

er-demo.git/aether/aether-update-site.git/acceleo/org.eclipse.acceleo.git/actf/org.eclipse.actf.visualization.git/chemclipse/org.eclipse.chemclipse.baselinedetec.git/amalgam/org.eclipse.amalgam.git/cdo/cdo.infrastructure.git/amp/org.eclipse.amp.git/cdo/cdo.git/bpmnmodeler/.git/amp/org.eclipse.amp.git/concierge/org.eclipse.concierge.git/amalgam/org.eclipse.amalgam.git/cdt/org.eclipse.cdt.old.git/gerrit/mdht/org.eclipse.mdht.git/app4mc/org.eclipse.app4mc.oslc.git/chemclipse/org.eclipse.chemclipse.amdiscalri.git/cdt/org.eclipse.cdt.edc.git/actf/org.eclipse.actf.examples.git/'>org.eclipse.actf.examples.git
technology.actf project repositoryGenie actf7 months
org.eclipse.actf.visualization.gittechnology.actf project repositoryGenie actf7 months
org.eclipse.actf.visualization.releng.gitACTF Visualization relengGenie actf3 years
acute
acute.gitUnnamed repository; edit this file 'description' to name the repository.Code Review8 months
agail
agail.gitUnnamed repository; edit this file 'description' to name the repository.Code Review17 months
ajdt
org.eclipse.ajdt.gitAspectJ Development Tools (AJDT) --- Eclipse based tooling for AspectJGenie ajdt5 weeks
amalgam
org.eclipse.amalgam.gitGenie amalgam4 weeks
amp
org.eclipse.amp.gitAgent Modeling Platform (AMP) http://eclipse.org/ampGenie amp5 years
apogy
apogy.gitUnnamed repository; edit this file 'description' to name the repository.Code Review6 weeks
app4mc
org.eclipse.app4mc.examples.gitUnnamed repository; edit this file 'description' to name the repository.Code Review3 months
org.eclipse.app4mc.gitApplication Platform Project for MultiCore (APP4MC) - ProjectCode Review5 days
org.eclipse.app4mc.oslc.gitUnnamed repository; edit this file 'description' to name the repository.Code Review8 months
org.eclipse.app4mc.releng.gitUnnamed repository; edit this file 'description' to name the repository.Code Review8 months
org.eclipse.app4mc.tools.gitUnnamed repository; edit this file 'description' to name the repository.Code Review3 weeks
org.eclipse.app4mc.web.gitApplication Platform Project for MultiCore (APP4MC) - RepositoryCode Review2 months
apricot
org.eclipse.apricot.gitApricot project repositoryGenie apricot6 years
aspectj
org.aspectj.gitaspectj project repositoryGenie aspectj5 days
org.aspectj.shadows.gitaspectj project repositoryGenie aspectj5 years
atf
org.eclipse.atf.gitatf project repositoryGenie atf6 years
babel
plugins.gitBabel messages editor and pluginsGenie babel13 months
server.gitBabel LAMP-based translation server project.Genie babel5 days
basyx
basyx.git[no description]Code Review3 weeks
bpel
org.eclipse.bpel.gitBPEL Designer ProjectGenie bpel2 months
bpmn2
org.eclipse.bpmn2.gitMDT BPMN2 metamodelCode Review10 months
bpmn2-modeler
org.eclipse.bpmn2-modeler.gitThis is the BPMN2 Modeler project repository.Genie bpmn2-modeler