To be compatible with git-rev-parse, commit~0 should resolve to commit, commit~1 to commit^, etc. Signed-off-by: Jonas Fonseca <fonseca@xxxxxxx> --- .../org/spearce/jgit/lib/T0008_testparserev.java | 9 +++++---- .../src/org/spearce/jgit/lib/Repository.java | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0008_testparserev.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0008_testparserev.java index 8883b8b..506f51f 100644 --- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0008_testparserev.java +++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/T0008_testparserev.java @@ -82,10 +82,11 @@ public void testRef_refname() throws IOException { } public void testDistance() throws IOException { - assertEquals("6e1475206e57110fcef4b92320436c1e9872a322",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~0").name()); - assertEquals("1203b03dc816ccbb67773f28b3c19318654b0bc8",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~1").name()); - assertEquals("bab66b48f836ed950c99134ef666436fb07a09a0",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~2").name()); - assertEquals("bab66b48f836ed950c99134ef666436fb07a09a0",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~02").name()); + assertEquals("49322bb17d3acc9146f98c97d078513228bbf3c0",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~0").name()); + assertEquals("6e1475206e57110fcef4b92320436c1e9872a322",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~1").name()); + assertEquals("1203b03dc816ccbb67773f28b3c19318654b0bc8",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~2").name()); + assertEquals("bab66b48f836ed950c99134ef666436fb07a09a0",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~3").name()); + assertEquals("bab66b48f836ed950c99134ef666436fb07a09a0",db.resolve("49322bb17d3acc9146f98c97d078513228bbf3c0~03").name()); } public void testTree() throws IOException { diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java index 730a267..894fe3b 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java +++ b/org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java @@ -688,7 +688,7 @@ else if (item.equals("")) { throw new RevisionSyntaxException( "Invalid ancestry length", revstr); } - while (dist >= 0) { + while (dist > 0) { final ObjectId[] parents = ((Commit) ref).getParentIds(); if (parents.length == 0) { refId = null; -- 1.6.0.1.451.gc8d31 -- Jonas Fonseca -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html