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 d55856ace..e76994e8b 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 @@ -191,6 +191,10 @@ public class RepositoryResolveTest extends SampleDataRepositoryTestCase { assertEquals(id, db.resolve("refs/heads/foo-g032c")); assertEquals(id, db.resolve("foo-g032c")); + assertNull(db.resolve("foo-g032")); + assertNull(db.resolve("foo-g03")); + assertNull(db.resolve("foo-g0")); + assertNull(db.resolve("foo-g")); ru = db.updateRef("refs/heads/foo-g032c-dev"); ru.setNewObjectId(id); 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 f31217a96..4806ab922 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java @@ -599,7 +599,7 @@ public abstract class Repository { return resolveAbbreviation(revstr); int dashg = revstr.indexOf("-g"); - if ((dashg + 4) < revstr.length() && 0 <= dashg + if ((dashg + 5) < revstr.length() && 0 <= dashg && isHex(revstr.charAt(dashg + 2)) && isHex(revstr.charAt(dashg + 3)) && isAllHex(revstr, dashg + 4)) {