summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorRüdiger Herrmann <ruediger.herrmann@gmx.de>2015-11-12 15:54:13 +0100
committerRüdiger Herrmann <ruediger.herrmann@gmx.de>2015-11-12 15:56:36 +0100
commite18444de30f1f019b5f7f0a463da42a884cb6a9a (patch)
tree71c213cdd821fcbdfbd54c6e8c0735ac70b48973 /org.eclipse.jgit.test
parent26451406782245ac6ee4cc976cf9d74ce6292592 (diff)
downloadjgit-e18444de30f1f019b5f7f0a463da42a884cb6a9a.tar.gz
jgit-e18444de30f1f019b5f7f0a463da42a884cb6a9a.zip
Fix MissingObjectException in RenameDetector
When attempting to determine the size of a blob that does not exist, the RenameDetector throws a MissingObjectException. The fix is to return a size of zero if the size is requested for a blob id that doesn't exist. Bug: 481577 Change-Id: I4e86276039c630617610cc51d0eefa56d7d3952f Signed-off-by: Rüdiger Herrmann <ruediger.herrmann@gmx.de>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RenameDetectorTest.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RenameDetectorTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RenameDetectorTest.java
index e83ef772ff..4315be9e49 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RenameDetectorTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RenameDetectorTest.java
@@ -48,6 +48,7 @@ import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import java.util.Arrays;
import java.util.List;
import org.eclipse.jgit.diff.DiffEntry.ChangeType;
@@ -227,6 +228,19 @@ public class RenameDetectorTest extends RepositoryTestCase {
}
@Test
+ public void testExactRename_UnstagedFile() throws Exception {
+ ObjectId aId = blob("foo");
+ DiffEntry a = DiffEntry.delete(PATH_A, aId);
+ DiffEntry b = DiffEntry.add(PATH_B, aId);
+
+ rd.addAll(Arrays.asList(a, b));
+ List<DiffEntry> entries = rd.compute();
+
+ assertEquals(1, entries.size());
+ assertRename(a, b, 100, entries.get(0));
+ }
+
+ @Test
public void testInexactRename_OnePair() throws Exception {
ObjectId aId = blob("foo\nbar\nbaz\nblarg\n");
ObjectId bId = blob("foo\nbar\nbaz\nblah\n");
@@ -430,6 +444,23 @@ public class RenameDetectorTest extends RepositoryTestCase {
}
@Test
+ public void testNoRenames_UntrackedFile() throws Exception {
+ ObjectId aId = blob("foo");
+ ObjectId bId = ObjectId
+ .fromString("3049eb6eee7e1318f4e78e799bf33f1e54af9cbf");
+
+ DiffEntry a = DiffEntry.delete(PATH_A, aId);
+ DiffEntry b = DiffEntry.add(PATH_B, bId);
+
+ rd.addAll(Arrays.asList(a, b));
+ List<DiffEntry> entries = rd.compute();
+
+ assertEquals(2, entries.size());
+ assertSame(a, entries.get(0));
+ assertSame(b, entries.get(1));
+ }
+
+ @Test
public void testBreakModify_BreakAll() throws Exception {
ObjectId aId = blob("foo");
ObjectId bId = blob("bar");