Do not attempt to resolve describe-labels with less than four digits

Change-Id: I21dcd3cca3b41102fd898238d8d640dea25e0caf
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
This commit is contained in:
Robin Rosenberg 2011-09-06 17:37:53 +02:00
parent 654f7235ec
commit 602c869d7a
2 changed files with 5 additions and 1 deletions

View File

@ -191,6 +191,10 @@ public void testParseNonGitDescribe() throws IOException {
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);

View File

@ -599,7 +599,7 @@ private ObjectId resolveSimple(final String revstr) throws IOException {
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)) {