diff options
author | Robin Rosenberg <robin.rosenberg@dewire.com> | 2012-01-14 20:28:52 -0500 |
---|---|---|
committer | Code Review <codereview-daemon@eclipse.org> | 2012-01-14 20:28:52 -0500 |
commit | 02729810f9246b9f332945f730d65c68f118d489 (patch) | |
tree | b7317309ad2a053374c64e9ac187675a2612c4c5 | |
parent | b8830d7bbbc206f3f56d06b21814b14b51d69f4f (diff) | |
parent | c963e7aacf4d8eaed0081ad31a29344a3cd9cd5a (diff) | |
download | jgit-02729810f9246b9f332945f730d65c68f118d489.tar.gz jgit-02729810f9246b9f332945f730d65c68f118d489.zip |
Merge "Resolve ~ with no trailing number as the first parent commit"
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryResolveTest.java | 5 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java | 17 |
2 files changed, 15 insertions, 7 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 e76994e8b8..aab3b7ade5 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 @@ -111,6 +111,11 @@ public class RepositoryResolveTest extends SampleDataRepositoryTestCase { assertEquals("1203b03dc816ccbb67773f28b3c19318654b0bc8",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~2").name()); assertEquals("bab66b48f836ed950c99134ef666436fb07a09a0",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~3").name()); assertEquals("bab66b48f836ed950c99134ef666436fb07a09a0",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~03").name()); + assertEquals("6e1475206e57110fcef4b92320436c1e9872a322",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~").name()); + assertEquals("1203b03dc816ccbb67773f28b3c19318654b0bc8",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~~").name()); + assertEquals("bab66b48f836ed950c99134ef666436fb07a09a0",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~~~").name()); + assertEquals("1203b03dc816ccbb67773f28b3c19318654b0bc8",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~~1").name()); + assertEquals("1203b03dc816ccbb67773f28b3c19318654b0bc8",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~~~0").name()); } @Test 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 1b649bba52..cf74df638b 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java @@ -496,14 +496,17 @@ public abstract class Repository { if (!Character.isDigit(rev[l])) break; } - String distnum = new String(rev, i + 1, l - i - 1); int dist; - try { - dist = Integer.parseInt(distnum); - } catch (NumberFormatException e) { - throw new RevisionSyntaxException( - JGitText.get().invalidAncestryLength, revstr); - } + if (l - i > 1) { + String distnum = new String(rev, i + 1, l - i - 1); + try { + dist = Integer.parseInt(distnum); + } catch (NumberFormatException e) { + throw new RevisionSyntaxException( + JGitText.get().invalidAncestryLength, revstr); + } + } else + dist = 1; while (dist > 0) { RevCommit commit = (RevCommit) ref; if (commit.getParentCount() == 0) { |