Browse Source

Merge "Resolve ~ with no trailing number as the first parent commit"

stable-1.3
Robin Rosenberg 13 years ago committed by Code Review
parent
commit
02729810f9
  1. 5
      org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RepositoryResolveTest.java
  2. 5
      org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java

5
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("1203b03dc816ccbb67773f28b3c19318654b0bc8",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~2").name());
assertEquals("bab66b48f836ed950c99134ef666436fb07a09a0",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~3").name()); assertEquals("bab66b48f836ed950c99134ef666436fb07a09a0",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~3").name());
assertEquals("bab66b48f836ed950c99134ef666436fb07a09a0",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~03").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 @Test

5
org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java

@ -496,14 +496,17 @@ public abstract class Repository {
if (!Character.isDigit(rev[l])) if (!Character.isDigit(rev[l]))
break; break;
} }
String distnum = new String(rev, i + 1, l - i - 1);
int dist; int dist;
if (l - i > 1) {
String distnum = new String(rev, i + 1, l - i - 1);
try { try {
dist = Integer.parseInt(distnum); dist = Integer.parseInt(distnum);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
throw new RevisionSyntaxException( throw new RevisionSyntaxException(
JGitText.get().invalidAncestryLength, revstr); JGitText.get().invalidAncestryLength, revstr);
} }
} else
dist = 1;
while (dist > 0) { while (dist > 0) {
RevCommit commit = (RevCommit) ref; RevCommit commit = (RevCommit) ref;
if (commit.getParentCount() == 0) { if (commit.getParentCount() == 0) {

Loading…
Cancel
Save