diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2011-09-06 17:37:53 +0200 |
---|---|---|
committer | Robin Rosenberg <robin.rosenberg@dewire.com> | 2011-10-03 00:39:50 +0200 |
commit | 602c869d7a2b75f092ef96ab04fe1865ff317d5b (patch) | |
tree | 29a3e842414b3ec4fffceb4c9aff50037341857d | |
parent | 654f7235ec49d15641c0f3e54ee140017d18ac3d (diff) | |
download | jgit-602c869d7a2b75f092ef96ab04fe1865ff317d5b.tar.gz jgit-602c869d7a2b75f092ef96ab04fe1865ff317d5b.zip |
Do not attempt to resolve describe-labels with less than four digits
Change-Id: I21dcd3cca3b41102fd898238d8d640dea25e0caf
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryResolveTest.java | 4 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java | 2 |
2 files changed, 5 insertions, 1 deletions
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 d55856acea..e76994e8b8 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 f31217a967..4806ab922a 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)) { |