diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryResolveTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryResolveTest.java index c6ab8ba4f..4ca9ba020 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryResolveTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryResolveTest.java @@ -48,6 +48,8 @@ import java.io.IOException; +import org.eclipse.jgit.errors.IncorrectObjectTypeException; + public class RepositoryResolveTest extends SampleDataRepositoryTestCase { public void testObjectId_existing() throws IOException { @@ -140,4 +142,22 @@ public void testDerefTree() throws IOException { assertEquals("856ec208ae6cadac25a6d74f19b12bb27a24fe24",db.resolve("refs/tags/B10th^{tree}").name()); } + public void testParseGitDescribeOutput() throws IOException { + ObjectId exp = db.resolve("b"); + assertEquals(exp, db.resolve("B-g7f82283")); // old style + assertEquals(exp, db.resolve("B-6-g7f82283")); // new style + + assertEquals(exp, db.resolve("B-6-g7f82283^0")); + assertEquals(exp, db.resolve("B-6-g7f82283^{commit}")); + + try { + db.resolve("B-6-g7f82283^{blob}"); + fail("expected IncorrectObjectTypeException"); + } catch (IncorrectObjectTypeException badType) { + // Expected + } + + assertEquals(db.resolve("b^1"), db.resolve("B-6-g7f82283^1")); + assertEquals(db.resolve("b~2"), db.resolve("B-6-g7f82283~2")); + } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java index 078b293f4..8a0420568 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java @@ -375,8 +375,6 @@ public RefRename renameRef(final String fromRef, final String toRef) throws IOEx * Currently supported is combinations of these. *